OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | March 2006 Index

<--  Date Index  --> <--  Thread Index  -->

CVS update of aokell/src/org/objectweb/fractal/aokell/lib (14 files)


    Date: Wednesday, March 29, 2006 @ 20:56:10
  Author: seintur
    Path: /cvsroot/fractal/aokell/src/org/objectweb/fractal/aokell/lib

   Added: interf/CompositeExtItfManager.java
          interf/CompositeIntItfManager.java interf/InterfaceManager.java
          interf/PrimitiveExtItfManager.java
Modified: InterfaceImpl.java
          control/binding/AbstractBindingControllerImpl.java
          control/binding/BindingControllerItf.java
          control/binding/CompositeAutoBindingControllerImpl.java
          control/binding/CompositeBindingControllerImpl.java
          control/binding/PrimitiveAutoBindingControllerImpl.java
          control/component/CompositeComponentImpl.java
          control/content/ContentControllerImpl.java
          control/content/ContentControllerItf.java
 Removed: CloneableItf.java

New (simpler, more modular) implementation of the binding, content and 
component controllers.


---------------------------------------------------------+
 CloneableItf.java                                       |   35 -
 InterfaceImpl.java                                      |   46 +-
 control/binding/AbstractBindingControllerImpl.java      |  272 +++++++------
 control/binding/BindingControllerItf.java               |    7 
 control/binding/CompositeAutoBindingControllerImpl.java |    8 
 control/binding/CompositeBindingControllerImpl.java     |   61 +--
 control/binding/PrimitiveAutoBindingControllerImpl.java |    8 
 control/component/CompositeComponentImpl.java           |   45 --
 control/content/ContentControllerImpl.java              |  276 ++------------
 control/content/ContentControllerItf.java               |   45 +-
 interf/CompositeExtItfManager.java                      |   85 ++++
 interf/CompositeIntItfManager.java                      |  100 +++++
 interf/InterfaceManager.java                            |   85 ++++
 interf/PrimitiveExtItfManager.java                      |  258 +++++++++++++
 14 files changed, 836 insertions(+), 495 deletions(-)


Index: aokell/src/org/objectweb/fractal/aokell/lib/CloneableItf.java
diff -u aokell/src/org/objectweb/fractal/aokell/lib/CloneableItf.java:1.1 
aokell/src/org/objectweb/fractal/aokell/lib/CloneableItf.java:removed
--- aokell/src/org/objectweb/fractal/aokell/lib/CloneableItf.java:1.1   Sat 
Feb 11 06:43:58 2006
+++ aokell/src/org/objectweb/fractal/aokell/lib/CloneableItf.java       Wed 
Mar 29 20:56:11 2006
@@ -1,35 +0,0 @@
-/***
- * AOKell
- * Copyright (C) 2005 INRIA, France Telecom
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Contact: Lionel.Seinturier@xxxxxxx
- *
- * Author: Lionel Seinturier
- */
-
-package org.objectweb.fractal.aokell.lib;
-
-/**
- * An interface for cloneable classes providing a public clone() method.
- * 
- * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- */
-public interface CloneableItf extends Cloneable {
-    
-    public Object clone();
-
-}
Index: aokell/src/org/objectweb/fractal/aokell/lib/InterfaceImpl.java
diff -u aokell/src/org/objectweb/fractal/aokell/lib/InterfaceImpl.java:1.2 
aokell/src/org/objectweb/fractal/aokell/lib/InterfaceImpl.java:1.3
--- aokell/src/org/objectweb/fractal/aokell/lib/InterfaceImpl.java:1.2  Tue 
Mar  7 13:11:50 2006
+++ aokell/src/org/objectweb/fractal/aokell/lib/InterfaceImpl.java      Wed 
Mar 29 20:56:10 2006
@@ -23,6 +23,7 @@
 
 package org.objectweb.fractal.aokell.lib;
 
+import org.objectweb.fractal.aokell.AOKell;
 import org.objectweb.fractal.api.Component;
 import org.objectweb.fractal.api.Interface;
 import org.objectweb.fractal.api.NoSuchInterfaceException;
@@ -36,7 +37,7 @@
  * 
  * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
  */
-public class InterfaceImpl implements Interface, CloneableItf {
+public class InterfaceImpl implements Interface {
     
     private Component fcItfOwner;
     private String fcItfName;
@@ -154,26 +155,43 @@
 
     
     // ------------------------------------------------------------------
-    // Implementation of the CloneableItf interface
+    // Implementation of a mechanism for cloning InterfaceImpl instances
     // ------------------------------------------------------------------
     
     /*
-     * clone() is required and could not be replaced by a constructor.
+     * The following method could not be replaced by a constructor.
      * We need in ComponentImpl to be able to create instances of sub-classes
-     * of InterfaceImpl generated on the fly in 
org.objectweb.fractal.aokell.lib.asm. 
+     * of InterfaceImpl generated on the fly in
+     * org.objectweb.fractal.aokell.lib.asm.
+     * 
+     *  The following method could be replaced by redefining clone() 
inherited
+     *  from Object. However this would not work for the J2ME compliant 
version
+     *  of AOKell as clone() is not part of the CLDC API. To avoid having two
+     *  different versions of the cloning mechanism, the following scheme, 
which
+     *  fits both cases, has been implemented. 
      */
-    public Object clone() {
-        InterfaceImpl clone = null;
+    
+    /**
+     * Return a clone of the given InterfaceImpl.
+     */
+    public static InterfaceImpl clone( InterfaceImpl src ) {
+        
+        String clname = src.getClass().getName();
+        
+        InterfaceImpl target = null;
         try {
-            clone = (InterfaceImpl) super.clone();
+            Class cl = AOKell.loadClass(clname);
+            target = (InterfaceImpl) cl.newInstance();
         }
-        catch(CloneNotSupportedException cnse) {
-            throw new RuntimeException(cnse);
+        catch( Exception e ) {
+            throw new RuntimeException(e.getMessage());
         }
-        clone.fcItfOwner = fcItfOwner;
-        clone.fcItfName = fcItfName;
-        clone.fcItfType = fcItfType;
-        clone.fcInternalItf = fcInternalItf;
-        return clone;
+        
+        target.setFcItfOwner( src.getFcItfOwner() );
+        target.setFcItfName( src.getFcItfName() );
+        target.setFcItfType( src.getFcItfType() );
+        target.setFcInternalItf( src.isFcInternalItf() );
+        
+        return target;
     }
 }
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/AbstractBindingControllerImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/AbstractBindingControllerImpl.java:1.7
 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/AbstractBindingControllerImpl.java:1.8
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/AbstractBindingControllerImpl.java:1.7
  Sun Mar 26 16:41:51 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/AbstractBindingControllerImpl.java
      Wed Mar 29 20:56:10 2006
@@ -99,11 +99,15 @@
         // Get currently bound interface names
         Set names = new HashSet(bindings.keySet());
         
-        // Add singleton client interfaces which may not be currently bound.
-        List cltItfs = getFcSingletonClientItfs();        
-        for (Iterator iter = cltItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            names.add( itf.getFcItfName() );
+        // Add boundable interfaces not currently bound
+        Object[] itfs = getFcInterfaces();
+        for (int i = 0; i < itfs.length; i++) {
+            Interface itf = (Interface) itfs[i];
+            InterfaceType it = (InterfaceType) itf.getFcItfType();
+            if( it.isFcClientItf() &&
+                ! 
FractalHelper.isFcControllerInterfaceName(itf.getFcItfName()) ) {
+                names.add( itf.getFcItfName() );
+            }
         }
         
         return (String[]) names.toArray(new String[names.size()]);        
@@ -145,35 +149,40 @@
             return componentBinding;
         }
         
-        Object bound = bindings.get(arg0);
+        if( bindings.containsKey(arg0) ) {
+            return bindings.get(arg0);
+        }
 
         // Bindings for collection interfaces are registered with the name of
         // the interface followed by a suffix (0, 1, 2, ...). Hence looking 
up
         // only the interface name returns null. We then return as a List
         // all the interfaces whose binding name starts with the prefix.
         
-        if( bound==null ) {
-            
-            // throw NoSuchInterfaceException if the interface does not exist
-            Interface itf = (Interface) getFcClientItf(arg0);            
-            InterfaceType it = (InterfaceType) itf.getFcItfType();
-            
-            if( it.isFcCollectionItf() ) {
-                Set sorted = new TreeSet(bindings.keySet());
-                List bounds = null;
-                for (Iterator iter = sorted.iterator(); iter.hasNext();) {
-                    String element = (String) iter.next();
-                    if( element.startsWith(arg0) ) {
-                        if( bounds == null )
-                            bounds = new ArrayList();
-                        bounds.add( bindings.get(element) );
-                    }
+        // throw NoSuchInterfaceException if the interface does not exist
+        Interface itf = (Interface) getFcBoundableInterface(arg0);           
 
+        InterfaceType it = (InterfaceType) itf.getFcItfType();
+        
+        if( it.isFcCollectionItf() ) {
+            Set sorted = new TreeSet(bindings.keySet());
+            List bounds = null;
+            for (Iterator iter = sorted.iterator(); iter.hasNext();) {
+                String element = (String) iter.next();
+                if( element.startsWith(arg0) ) {
+                    if( bounds == null )
+                        bounds = new ArrayList();
+                    bounds.add( bindings.get(element) );
                 }
-                return bounds;
             }
+            return bounds;
         }
         
-        return bound;
+        /*
+         * When this point is reached, the interface exists but this is not a
+         * collection interface (hence this is a singleton interface), and 
it is
+         * not bound.
+         */
+        
+        return null;
     }
 
     /**
@@ -202,8 +211,18 @@
             return;
         }
         
-        // throw NoSuchInterfaceException if the interface does not exist
-        Interface itf = (Interface) getFcClientItf(arg0);
+        Interface itf = null;
+        try {
+            itf = (Interface) getFcBoundableInterface(arg0);
+        }
+        catch( NoSuchInterfaceException nsie ) {
+            /*
+             * Try to register the interface with the component controller or
+             * the content controller (for composites).
+             * May throw NoSuchInterfaceException again.
+             */
+            itf = registerFcInterface(arg0);
+        }
         InterfaceType it = (InterfaceType) itf.getFcItfType();
         
         // Test whether the binding is legal
@@ -224,7 +243,7 @@
         Component dstItfOwner = dstItf.getFcItfOwner();
         BindingControllerItf bc =
             FractalHelper.getBindingControllerItf(dstItfOwner);
-        bc.reverseBindFc( dstItf.getFcItfName(), itf );
+        bc.reverseBindFc( dstItf.getFcItfName(), itf );        
     }
     
     /**
@@ -287,7 +306,7 @@
         }
 
         // throw NoSuchInterfaceException if the interface does not exist
-        Interface itf = (Interface) getFcClientItf(arg0);
+        Interface itf = (Interface) getFcBoundableInterface(arg0);
         
         // Test whether the interface is bound
         if( !bindings.containsKey(arg0) ) {
@@ -303,8 +322,17 @@
         // Remove the reverse binding
         Interface dstItf = (Interface) arg1;
         Component dstItfOwner = dstItf.getFcItfOwner();
-        BindingControllerItf bc = 
FractalHelper.getBindingControllerItf(dstItfOwner);
-        bc.reverseUnbindFc( dstItf.getFcItfName(), itf );
+        String dstItfName = dstItf.getFcItfName();
+        BindingControllerItf bc =
+            FractalHelper.getBindingControllerItf(dstItfOwner);
+        bc.reverseUnbindFc( dstItfName, itf );
+
+        /*
+         * Unregister the source interface from its component controllers
+         * (needed for collection).
+         */
+        ComponentItf compctrl = MembraneHelper.getFcCompCtrl(this.compctrl);
+        compctrl.unregisterFcInterface(arg0);
     }
 
     
@@ -384,26 +412,6 @@
         return ! reverseBindings.isEmpty();
     }
     
-    /**
-     * Add the names of currently bound interfaces to the given list.
-     */
-    public void addFcCollectionInterfaceNames( List cltItfNames ) {
-        
-        ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-        List collectionItfs = c.getFcCollectionInterfaces();
-        
-        for (Iterator iter = collectionItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            for (Iterator iter2 = bindings.keySet().iterator();
-                    iter2.hasNext();) {
-                String key = (String) iter2.next();
-                if( key.startsWith(itf.getFcItfName()) ) {
-                    cltItfNames.add(key);
-                }
-            }
-        }
-    }
-    
 
     // --------------------------------------------------------------
     // Implementation specific
@@ -427,32 +435,6 @@
     }
     
     /**
-     * Return the interface whose name is given.
-     */
-    protected Object getFcClientItf(String itfName)
-    throws NoSuchInterfaceException {        
-        ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-        return c.getFcClientInterface(itfName);
-    }
-    
-    /**
-     * Return the list of client interfaces for the component attached to 
this
-     * controller.
-     */
-    protected List getFcSingletonClientItfs() {
-        
-        List clientItfs = new ArrayList();
-        
-        ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-
-        // Add client external interfaces
-        List sbi = c.getFcSingletonClientInterfaces();
-        clientItfs.addAll(sbi);
-        
-        return clientItfs;
-    }
-    
-    /**
      * @return    return true if it1 is assignable from it2
      */
     private static boolean isAssignableFrom(
@@ -492,41 +474,57 @@
         if( ! isAssignableFrom(it,targetItfType) )
             throw new IllegalBindingException(
                     "Target interface "+targetItfName+
-                    " is not a sub-type of source interface "+
+                    " is not a sub-type of the source interface "+
                     arg0+" type");
         
-//        // Test for export bindings
-//        if( ContentControllerImpl.isFcContainedIn(target,component) ) {
-//            if( it.isFcClientItf() ) {
-//                throw new IllegalBindingException(it+" is client");
-//            }
-//            if( targetItfType.isFcClientItf() ) {
-//                throw new IllegalBindingException(targetItfType+" is 
client");
-//            }
-//        }        
-//        // Test for import bindings
-//        else if( ContentControllerImpl.isFcContainedIn(component,target) ) 
{
-//            if( ! it.isFcClientItf() ) {
-//                throw new IllegalBindingException(it+" is server");
-//            }
-//            if( ( targetItf.isFcInternalItf() &&
-//                  targetItfType.isFcClientItf() )
-//                ||
-//                ( ! targetItf.isFcInternalItf() &&
-//                  ! targetItfType.isFcClientItf() ) ) {
-//                throw new IllegalBindingException(targetItfType+" is 
server");
-//            }
-//        }        
-//        // Test for normal bindings
-//        else {
-            if( ! it.isFcClientItf() ) {
-                throw new IllegalBindingException(it+" is server");
-            }
-            if( targetItfType.isFcClientItf() ) {
-                throw new IllegalBindingException(targetItfType+" is 
client");
+        if( ! it.isFcClientItf() ) {
+            throw new IllegalBindingException(it+" is server");
+        }
+        
+        if( targetItfType.isFcClientItf() ) {
+            throw new IllegalBindingException(targetItfType+" is client");
+        }                
+    }
+    
+    protected Object[] getFcInterfaces() {
+        Component compctrl = MembraneHelper.getFcCompCtrlImpl(this.compctrl);
+        return compctrl.getFcInterfaces();
+    }
+    
+    protected Object getFcBoundableInterface( String interfaceName )
+    throws NoSuchInterfaceException {
+        
+        Object[] itfs = getFcInterfaces();
+        for (int i = 0; i < itfs.length; i++) {
+            
+            Interface itf = (Interface) itfs[i];
+            String itfName = itf.getFcItfName();
+            InterfaceType it = (InterfaceType) itf.getFcItfType();
+            
+            if( itfName.equals(interfaceName) &&
+                it.isFcClientItf() && 
+                ! FractalHelper.isFcControllerInterfaceName(itfName) ) {
+                    return itf;
             }
-//        }
-                
+
+        }
+        
+        throw new NoSuchInterfaceException(interfaceName);
+    }
+    
+    /**
+     * Register a new interface with the component controller. This method is
+     * used for registering new instances of a collection interface.
+     * 
+     * @throws NoSuchInterfaceException
+     *      if the interface is not a collection interface
+     */
+    protected Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException {
+        
+        ComponentItf compctrl = MembraneHelper.getFcCompCtrl(this.compctrl);
+        Interface itf = compctrl.registerFcInterface(interfaceName);
+        return itf;
     }
     
     
@@ -597,16 +595,14 @@
         for (Iterator iter = bindings.entrySet().iterator(); 
iter.hasNext();) {
             Map.Entry entry = (Map.Entry) iter.next();
             String srcItfName = (String) entry.getKey();
+            Interface dstItf = (Interface) entry.getValue();
             
-            if( ! srcItfName.equals("component") ) {
-                Interface dstItf = (Interface) entry.getValue();
-                try {
-                    cloneBinding(srcItfName,dstItf,newContent,newBc);
-                }
-                catch(Exception e) {
-                    e.printStackTrace();
-                    throw new CloneCtrlException(e);
-                }
+            try {
+                cloneBinding(srcItfName,dstItf,newContent,newBc);
+            }
+            catch(Exception e) {
+                e.printStackTrace();
+                throw new CloneCtrlException(e);
             }
         }
     }
@@ -634,22 +630,42 @@
         
         if( dstBound == null ) {
             /*
-             * Trying to clone a binding starting from the cloned components
-             * and targeting a component which is outside the scope of the
-             * cloned components.
+             * Trying to clone a binding which starts from one of the cloned
+             * components and which targets a component outside of the scope 
of
+             * the cloned components.
              */
             return;
         }
         
-        // Check whether the old binding was toward an internal or an 
external
-        // interface
-        Object dstBoundItf = null;
-        if( boundItf.isFcInternalItf() ) {
-            ContentController cc = 
FractalHelper.getContentControllerItf(dstBound);
-            dstBoundItf = cc.getFcInternalInterface(boundItfName);
+        Interface dstBoundItf =
+            (Interface) dstBound.getFcInterface(boundItfName);
+        
+        ContentController cc = null;
+        try {
+            cc = FractalHelper.getContentControllerItf(dstBound);
+            
+            /*
+             * The target component is composite.
+             * 
+             * The server interface may be:
+             * - external, if the target component is located at the same
+             *   hierarchical level as the source component in the 
containment
+             *   hierarchy,
+             * - internal, if the target component encloses the source
+             *   component.
+             * Always return the server interface. 
+             */
+            InterfaceType it = (InterfaceType) dstBoundItf.getFcItfType();
+            if( it.isFcClientItf() ) {
+                dstBoundItf =
+                    (Interface) cc.getFcInternalInterface(boundItfName);     
           
+            }
         }
-        else {
-            dstBoundItf = dstBound.getFcInterface(boundItfName);
+        catch( RuntimeException re ) {
+            /*
+             * The target component is primitive.
+             * Nothing else to do.
+             */
         }
         
         // Record the new binding
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/BindingControllerItf.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/BindingControllerItf.java:1.1
 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/BindingControllerItf.java:1.2
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/BindingControllerItf.java:1.1
   Sat Feb 11 06:43:52 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/BindingControllerItf.java
       Wed Mar 29 20:56:10 2006
@@ -23,8 +23,6 @@
 
 package org.objectweb.fractal.aokell.lib.control.binding;
 
-import java.util.List;
-
 import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
 import org.objectweb.fractal.api.control.BindingController;
 import org.objectweb.fractal.api.type.InterfaceType;
@@ -89,9 +87,4 @@
      * binding
      */
     public boolean isFcReverseBound();        
-
-    /**
-     * Add the names of currently bound interface names to the given list.
-     */
-    public void addFcCollectionInterfaceNames( List cltItfNames );
 }
\ No newline at end of file
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeAutoBindingControllerImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeAutoBindingControllerImpl.java:1.2
 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeAutoBindingControllerImpl.java:1.3
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeAutoBindingControllerImpl.java:1.2
     Wed Feb 22 13:33:57 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeAutoBindingControllerImpl.java
 Wed Mar 29 20:56:10 2006
@@ -70,7 +70,7 @@
             return;
         }
         
-        Interface clientItf = (Interface) getFcClientItf(clientItfName);
+        Interface clientItf = (Interface) 
getFcBoundableInterface(clientItfName);
         InterfaceType clientItfType = (InterfaceType) 
clientItf.getFcItfType();
         
         if (clientItfType.isFcCollectionItf()) {
@@ -145,11 +145,11 @@
     throws NoSuchInterfaceException, IllegalBindingException,
     IllegalLifeCycleException {
         
-        super.unbindFc(clientItfName);
-        
-        Interface clientItf = (Interface) getFcClientItf(clientItfName);
+        Interface clientItf = (Interface) 
getFcBoundableInterface(clientItfName);
         InterfaceType clientItfType = (InterfaceType) 
clientItf.getFcItfType();
         
+        super.unbindFc(clientItfName);        
+        
         if (clientItfType.isFcCollectionItf()) {
           ContentController cc;
           try {
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeBindingControllerImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeBindingControllerImpl.java:1.2
 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeBindingControllerImpl.java:1.3
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeBindingControllerImpl.java:1.2
 Wed Feb 15 03:03:46 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/CompositeBindingControllerImpl.java
     Wed Mar 29 20:56:10 2006
@@ -23,12 +23,13 @@
 
 package org.objectweb.fractal.aokell.lib.control.binding;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.objectweb.fractal.aokell.lib.control.content.ContentControllerItf;
 import org.objectweb.fractal.aokell.lib.util.MembraneHelper;
+import org.objectweb.fractal.api.Interface;
 import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.control.ContentController;
+import org.objectweb.fractal.api.type.InterfaceType;
+
 
 
 /**
@@ -49,43 +50,37 @@
     // Implementation specific
     // --------------------------------------------------------------
     
-    /**
-     * Return the interface whose name is given.
-     */
-    protected Object getFcClientItf(String itfName)
-        throws NoSuchInterfaceException {
+    protected Object[] getFcInterfaces() {
+        
+        ContentController cc = 
MembraneHelper.getFcContentCtrl(this.compctrl);
+        Object[] i1 = super.getFcInterfaces();
+        Object[] i2 = cc.getFcInternalInterfaces();
         
-        try {
-            return super.getFcClientItf(itfName);
-        }
-        catch( NoSuchInterfaceException nsie ) {}
-            
-        /*
-         * The interface has not been found in the external interfaces.
-         * Lookup in the internal interfaces.
-         * The call does not necessarily succeed and may throw 
NoSuchInterface
-         */
-        ContentControllerItf cc = MembraneHelper.getFcContentCtrl(compctrl);
-        return cc.getFcInternalClientInterface(itfName);
+        Object[] all = new Object[ i1.length + i2.length ];
+        System.arraycopy(i1,0,all,0,i1.length);
+        System.arraycopy(i2,0,all,i1.length,i2.length);
+        
+        return all;
     }
-    
+
     /**
-     * Return the list of client interfaces for the component attached to 
this
-     * controller.
+     * Register a new interface with the component controller. This method is
+     * used for registering new instances of a collection interface.
+     * 
+     * @throws NoSuchInterfaceException
+     *      if the interface is not a collection interface
      */
-    protected List getFcSingletonClientItfs() {
-        
-        List clientItfs = new ArrayList();
+    protected Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException {
         
-        // Add client external interfaces
-        clientItfs.addAll(super.getFcSingletonClientItfs());
+        Interface extitf = super.registerFcInterface(interfaceName);
         
-        // Add client internal interfaces (if relevant)
-        ContentControllerItf cc = MembraneHelper.getFcContentCtrl(compctrl);
-        List isbi = cc.getFcInternalSingletonClientInterfaces();
-        clientItfs.addAll(isbi);
+        ContentControllerItf cc = 
MembraneHelper.getFcContentCtrl(this.compctrl);
+        Interface intitf = cc.registerFcInterface(interfaceName);
         
-        return clientItfs;
+        return
+            ( ((InterfaceType)extitf.getFcItfType()).isFcClientItf() ) ?
+            extitf : intitf ;
     }
     
 }
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/PrimitiveAutoBindingControllerImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/PrimitiveAutoBindingControllerImpl.java:1.2
 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/PrimitiveAutoBindingControllerImpl.java:1.3
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/PrimitiveAutoBindingControllerImpl.java:1.2
     Wed Feb 22 13:33:57 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/binding/PrimitiveAutoBindingControllerImpl.java
 Wed Mar 29 20:56:10 2006
@@ -70,7 +70,7 @@
             return;
         }
         
-        Interface clientItf = (Interface) getFcClientItf(clientItfName);
+        Interface clientItf = (Interface) 
getFcBoundableInterface(clientItfName);
         InterfaceType clientItfType = (InterfaceType) 
clientItf.getFcItfType();
         
         if (clientItfType.isFcCollectionItf()) {
@@ -145,11 +145,11 @@
     throws NoSuchInterfaceException, IllegalBindingException,
     IllegalLifeCycleException {
         
-        super.unbindFc(clientItfName);
-        
-        Interface clientItf = (Interface) getFcClientItf(clientItfName);
+        Interface clientItf = (Interface) 
getFcBoundableInterface(clientItfName);
         InterfaceType clientItfType = (InterfaceType) 
clientItf.getFcItfType();
         
+        super.unbindFc(clientItfName);
+        
         if (clientItfType.isFcCollectionItf()) {
           ContentController cc;
           try {
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.4
 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.5
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java:1.4
       Sun Mar 26 14:24:34 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/component/CompositeComponentImpl.java
   Wed Mar 29 20:56:10 2006
@@ -23,10 +23,7 @@
 
 package org.objectweb.fractal.aokell.lib.control.component;
 
-import org.objectweb.fractal.aokell.AOKell;
-import org.objectweb.fractal.api.Component;
-import org.objectweb.fractal.api.Interface;
-import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.aokell.lib.interf.CompositeExtItfManager;
 
 
 /**
@@ -39,45 +36,7 @@
     implements ComponentItf {  // Needed for fractalrmi
 
     public CompositeComponentImpl() {
-        super();
-    }
-    
-    
-    // ------------------------------------------------------------------
-    // Implementation specific methods
-    // ------------------------------------------------------------------
-    
-    /**
-     * Get the Interface instance associated to the given interface type for 
the
-     * given component.
-     */
-    protected Interface getFcInterface( InterfaceType it, Component itfOwner 
) {
-        
-        Object contentPart = getContentPart();
-        if( contentPart != null ) {
-            /*
-             * For composites which define a content, determine whether the
-             * content implements the interface.
-             * Very unlikely case, but seen once in Julia JUnit tests.
-             */
-            Class jit = null;
-            try {
-                jit = AOKell.loadClass(it.getFcItfSignature());
-            }
-            catch( ClassNotFoundException cnfe ) {
-                /*
-                 * Shouldn't occur. Arrived at this point, the existence of 
the
-                 * Java signature associated to the interface should have
-                 * already been checked.
-                 */
-                throw new RuntimeException(cnfe.getMessage());
-            }
-            if( jit.isAssignableFrom(contentPart.getClass()) ) {
-                return getProxyInterface(it,itfOwner,getContentPart(),false);
-            }
-        }
-                
-        return getProxyInterface(it,itfOwner,getContentPart(),true);
+        im = new CompositeExtItfManager();
     }
     
 }
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerImpl.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerImpl.java:1.4
 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerImpl.java:1.5
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerImpl.java:1.4
  Fri Feb 24 14:22:16 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerImpl.java
      Wed Mar 29 20:56:10 2006
@@ -24,44 +24,45 @@
 package org.objectweb.fractal.aokell.lib.control.content;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.objectweb.fractal.aokell.lib.CloneableItf;
-import org.objectweb.fractal.aokell.lib.InterfaceImpl;
 import org.objectweb.fractal.aokell.lib.control.CloneCtrlException;
 import org.objectweb.fractal.aokell.lib.control.Controller;
 import org.objectweb.fractal.aokell.lib.control.binding.BindingControllerItf;
-import org.objectweb.fractal.aokell.lib.control.component.ComponentItf;
 import org.objectweb.fractal.aokell.lib.control.superc.SuperControllerItf;
-import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
+import org.objectweb.fractal.aokell.lib.interf.CompositeIntItfManager;
+import org.objectweb.fractal.aokell.lib.interf.InterfaceManager;
 import org.objectweb.fractal.aokell.lib.util.FractalHelper;
 import org.objectweb.fractal.aokell.lib.util.MembraneHelper;
 import org.objectweb.fractal.api.Component;
 import org.objectweb.fractal.api.Interface;
 import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
 import org.objectweb.fractal.api.control.ContentController;
 import org.objectweb.fractal.api.control.IllegalContentException;
 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
 import org.objectweb.fractal.api.control.LifeCycleController;
 import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.util.Fractal;
 
 
 /**
- * Implementation for the content controller.
+ * Implementation for the {@link ContentController}.
  * 
  * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
  */
 public class ContentControllerImpl
     implements ContentControllerItf, Controller {
     
-    /**
-     * The list of components under the control of this controller.
-     * The type should be List<Component>.
-     */
+    /** The list of components under the control of this controller. */
+    // List<Component>
     private List content = new ArrayList();
+    
+    /** The manager for internal interfaces associated with this controller. 
*/
+    private InterfaceManager im = new CompositeIntItfManager();
 
+    
     public ContentControllerImpl() {}
     
     
@@ -69,63 +70,17 @@
     // ContentController interface
     // --------------------------------------------------------------
     
-    private Object[] internalInterfacesArray;
-    
     /**
-     * @return  the array of internal Interface instances implemented by this
-     * component
+     * Return the array of internal Interface instances implemented by this
+     * component.
      */
     public Object[] getFcInternalInterfaces() {
-        if( internalInterfacesArray == null ) {
-            List singletonItfs = getFcInternalSingletonInterfaces();
-            internalInterfacesArray =
-                singletonItfs.toArray(new Object[singletonItfs.size()]);
-        }
-        
-        // TODO collection interfaces currently bound (see 
Component.getFcInterfaces())
-        
-        return internalInterfacesArray;
+        return im.getFcInterfaces();
     }
 
     public Object getFcInternalInterface(String interfaceName)
     throws NoSuchInterfaceException {
-        
-        // Lookup the name in the singleton Interface list
-        List singletonItfs = getFcInternalSingletonInterfaces();
-        for (Iterator iter = singletonItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            if( itf.getFcItfName().equals(interfaceName) ) {
-                return itf;
-            }            
-        }
-        
-        // Lookup the name in the collection Interface list
-        List collectionItfs = getFcInternalCollectionInterfaces();
-        for (Iterator iter = collectionItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            if( itf.getFcItfName().equals(interfaceName) ) {
-                return itf;
-            }            
-        }
-        
-        /*
-         * The interface has not been found in the collection interface list.
-         * A possible cause if that a interface name such as foo004 is looked
-         * up. In such a case the corresponding Interface instance must be
-         * generated on the fly, and registered into the list of collection
-         * interfaces.
-         */
-        for (Iterator iter = collectionItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            if( interfaceName.startsWith(itf.getFcItfName()) ) {
-                InterfaceImpl clone = (InterfaceImpl) 
((CloneableItf)itf).clone();
-                clone.setFcItfName(interfaceName);
-                collectionItfs.add(clone);
-                return clone;
-            }            
-        }
-        
-        throw new NoSuchInterfaceException(interfaceName);
+        return im.getFcInterface(interfaceName);
     }
 
     public Component[] getFcSubComponents() {
@@ -202,70 +157,49 @@
     // --------------------------------------------------------------
     
     /**
-     * Return the list of client internal interfaces.
+     * Declare a new controller implemented by the component.
      */
-    public List getFcInternalSingletonClientInterfaces() {
-        
-        List clientItfs = new ArrayList();
-        
-        // Add client singleton internal interfaces
-        List singletonItfs = getFcInternalSingletonInterfaces();
-        for (Iterator iter = singletonItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            InterfaceType it = (InterfaceType) itf.getFcItfType();
-            if( it.isFcClientItf() ) {
-                clientItfs.add(itf);
-            }            
-        }
-        
-//        // Add client collection internal interfaces
-//        List collectionItfs = getFcInternalCollectionInterfaces();
-//        for (Iterator iter = collectionItfs.iterator(); iter.hasNext();) {
-//            Interface itf = (Interface) iter.next();
-//            InterfaceType it = (InterfaceType) itf.getFcItfType();
-//            if( it.isFcClientItf() ) {
-//                clientItfs.add(itf);
-//            }            
-//        }
-        
-        return clientItfs;
+    public void addFcController( InterfaceType it, Object ctrl ) {
+        im.registerFcControlInterface(it,ctrl);
+    }
+    
+    /**
+     * Initialize parameters required for managing internal interfaces
+     * associated with this content controller. This method is invoked by the
+     * membrane factory.
+     */
+    public void initFc(
+            Type type, Object controllerDesc, Object contentDesc,
+            Component compctrlimpl, Object contentPart ) {
+        im.initFc(type,compctrlimpl,contentPart);
+    }
+    
+    /**
+     * Register a new collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException {
+        return im.registerFcInterface(interfaceName);
     }
 
     /**
-     * Return the instance implementing the given client internal interface
-     * name. This method is a clone for getFcInternalInterface(String).
+     * Unregister a collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
      */
-    public Object getFcInternalClientInterface(String interfaceName)
+    public void unregisterFcInterface( String interfaceName )
     throws NoSuchInterfaceException {
-        
-        // Lookup the name in the singleton Interface list
-        List singletonItfs = getFcInternalSingletonInterfaces();
-        for (Iterator iter = singletonItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            InterfaceType it = (InterfaceType) itf.getFcItfType();
-            if( it.isFcClientItf() &&
-                itf.getFcItfName().equals(interfaceName) ) {
-                return itf;
-            }            
-        }
-        
-        /*
-         * Lookup the name in the collection Interface list.
-         * When such an interface is looked up its name is something like 
foo004
-         * which does not exists as an interface name (but foo does).
-         * See TestBindingController.
-         */
-        List collectionItfs = getFcInternalCollectionInterfaces();
-        for (Iterator iter = collectionItfs.iterator(); iter.hasNext();) {
-            Interface itf = (Interface) iter.next();
-            InterfaceType it = (InterfaceType) itf.getFcItfType();
-            if( it.isFcClientItf() &&
-                interfaceName.startsWith(itf.getFcItfName()) ) {
-                return itf;
-            }            
-        }
-        
-        throw new NoSuchInterfaceException(interfaceName);
+        im.unregisterFcInterface(interfaceName);
     }
 
     
@@ -282,106 +216,6 @@
                     "Component "+arg0+" must be stopped before removed");
     }
     
-    private List singletonInterfaces;
-    
-    /**
-     * @return  the list of internal singleton Interface instances 
implemented
-     * by this component
-     */
-    private List getFcInternalSingletonInterfaces() {
-        if( singletonInterfaces == null ) {
-            List isbi = getFcInternalSingletonBusinessInterfaces();
-            List isci = getFcInternalSingletonControlInterfaces();
-            singletonInterfaces = new ArrayList( isbi.size() + isci.size() );
-            singletonInterfaces.addAll( isbi );
-            singletonInterfaces.addAll( isci );
-        }
-        return singletonInterfaces;        
-    }
-
-    private List singletonBusinessInterfaces;
-    
-    /**
-     * @return  the list of internal singleton business Interface instances 
-     * implemented by this component
-     */
-    private List getFcInternalSingletonBusinessInterfaces() {
-        if( singletonBusinessInterfaces == null ) {
-            ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-            List itfs = c.getFcSingletonBusinessInterfaces();
-            singletonBusinessInterfaces = getFcInternalInterfaces(itfs);
-        }
-        return singletonBusinessInterfaces;        
-    }
-
-    private List singletonControlInterfaces;
-    
-    /**
-     * @return  the list of internal singleton control Interface instances 
-     * implemented by this component
-     */
-    private List getFcInternalSingletonControlInterfaces() {
-        if( singletonControlInterfaces == null ) {
-            ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-            List itfs = c.getFcSingletonControlInterfaces();
-            singletonControlInterfaces = getFcInternalInterfaces(itfs);
-        }
-        return singletonControlInterfaces;        
-    }
-
-    private List collectionInterfaces;
-    
-    /**
-     * @return  the list of internal collection Interface instances 
implemented
-     * by this component
-     */
-    private List getFcInternalCollectionInterfaces() {
-        if( collectionInterfaces == null ) {
-            ComponentItf c = MembraneHelper.getFcCompCtrl(compctrl);
-            List itfs = c.getFcCollectionInterfaces();
-            collectionInterfaces = getFcInternalInterfaces(itfs);
-        }
-        return collectionInterfaces;
-    }
-
-    /**
-     * Given a list of external Interface instances,
-     * return the list of internal ones.
-     */
-    private static List getFcInternalInterfaces( List itfs ) {
-        
-        List externalItfs = new ArrayList(itfs.size());
-        for (Iterator iter = itfs.iterator(); iter.hasNext();) {
-            
-            // Clone business Interfaces
-            Interface itf = (Interface) iter.next();
-            String itfName = itf.getFcItfName();
-            if( ! FractalHelper.isFcControllerInterfaceName(itfName) ) {
-                
-                InterfaceImpl clone =
-                    (InterfaceImpl) ((CloneableItf)itf).clone();
-                
-                // The clone Interface is internal
-                clone.setFcInternalItf(true);
-                
-                // Change the type of the clone Interface (client <-> server)
-                InterfaceType it = (InterfaceType) itf.getFcItfType();
-                InterfaceType cloneit = 
-                    new InterfaceTypeImpl(
-                            it.getFcItfName(),
-                            it.getFcItfSignature(),
-                            ! it.isFcClientItf(), // client <-> server
-                            it.isFcOptionalItf(),
-                            it.isFcCollectionItf() );
-                clone.setFcItfType(cloneit);
-                
-                externalItfs.add(clone);                
-            }
-        }
-        
-        return externalItfs;
-    }
-    
     /**
      * Return true if the given src component is contained in the given dst
      * component.
@@ -396,11 +230,11 @@
         
         ContentController cc = null;
         try {
-            cc = 
org.objectweb.fractal.util.Fractal.getContentController(dst);
+            cc = Fractal.getContentController(dst);
         }
         catch(NoSuchInterfaceException nsie) {
             // dst is not a composite
-            // Should we propagate NoSuchInterfaceException instead ?
+            // Should we propagate NoSuchInterfaceException instead?
             return false;
         }
         
@@ -432,7 +266,7 @@
      * controller.
      */
     public void setFcCompCtrl( Component compctrl ) {
-        this.compctrl = compctrl;
+        this.compctrl = compctrl;        
     }
     
     /**
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerItf.java
diff -u 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerItf.java:1.1
 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerItf.java:1.2
--- 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerItf.java:1.1
   Sat Feb 11 06:43:53 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/control/content/ContentControllerItf.java
       Wed Mar 29 20:56:10 2006
@@ -1,9 +1,10 @@
 package org.objectweb.fractal.aokell.lib.control.content;
 
-import java.util.List;
-
 import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
 import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
 import org.objectweb.fractal.api.control.ContentController;
 import org.objectweb.fractal.api.type.InterfaceType;
 
@@ -24,8 +25,40 @@
                 ContentControllerItf.class.getName(),
                 false, false, false );
 
-    public List getFcInternalSingletonClientInterfaces();
-    
-    public Object getFcInternalClientInterface(String interfaceName)
-        throws NoSuchInterfaceException;
+    /**
+     * Declare a new controller implemented by the component.
+     */
+    public void addFcController( InterfaceType it, Object ctrl );
+
+    /**
+     * Register a new collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * declared in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException;
+
+    /**
+     * Unregister a collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * declared in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public void unregisterFcInterface( String interfaceName )
+    throws NoSuchInterfaceException;
+
+    /**
+     * Initialize parameters required for managing internal interfaces
+     * associated with this content controller.
+     */
+    public void initFc(
+            Type type, Object controllerDesc, Object contentDesc,
+            Component compctrlimpl, Object contentPart );
 }
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeExtItfManager.java
diff -u /dev/null 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeExtItfManager.java:1.1
--- /dev/null   Wed Mar 29 20:56:11 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeExtItfManager.java
      Wed Mar 29 20:56:10 2006
@@ -0,0 +1,85 @@
+/***
+ * AOKell
+ * Copyright (C) 2005-2006 INRIA, France Telecom
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+package org.objectweb.fractal.aokell.lib.interf;
+
+import org.objectweb.fractal.aokell.AOKell;
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.type.InterfaceType;
+
+/**
+ * A manager for external interfaces of composite components.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public class CompositeExtItfManager extends PrimitiveExtItfManager {
+    
+    // --------------------------------------------------------------
+    // Implementation specific
+    // --------------------------------------------------------------
+    
+    /**
+     * Get the {@link Interface} instance associated to the given interface 
type
+     * for the given component.
+     */
+    protected Interface getFcInterface(
+            InterfaceType it, Component itfOwner, Object content,
+            boolean isFcInternalInterface ) {
+        
+        if( content != null ) {
+            /*
+             * For composites which define a content, determine whether the
+             * content implements the interface.
+             * Very unlikely case, but seen once in Julia JUnit tests.
+             */
+            Class jit = null;
+            try {
+                jit = AOKell.loadClass(it.getFcItfSignature());
+            }
+            catch( ClassNotFoundException cnfe ) {
+                /*
+                 * Shouldn't occur. Arrived at this point, the existence of 
the
+                 * Java signature associated to the interface should have
+                 * already been checked.
+                 */
+                throw new RuntimeException(cnfe.getMessage());
+            }
+            if( jit.isAssignableFrom(content.getClass()) ) {
+                return
+                    getProxyInterface(
+                            it,itfOwner,content,
+                            isFcInternalInterface,
+                            false   // implemented
+                    );
+            }
+        }
+                
+        return
+            getProxyInterface(
+                    it,itfOwner,content,
+                    false,  // external
+                    true    // boundable
+            );
+    }
+    
+}
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeIntItfManager.java
diff -u /dev/null 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeIntItfManager.java:1.1
--- /dev/null   Wed Mar 29 20:56:11 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/interf/CompositeIntItfManager.java
      Wed Mar 29 20:56:10 2006
@@ -0,0 +1,100 @@
+/***
+ * AOKell
+ * Copyright (C) 2005-2006 INRIA, France Telecom
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+package org.objectweb.fractal.aokell.lib.interf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
+import org.objectweb.fractal.aokell.lib.util.FractalHelper;
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.type.InterfaceType;
+
+/**
+ * A manager for internal interfaces of composite components.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public class CompositeIntItfManager extends CompositeExtItfManager {
+    
+    public Object[] getFcInterfaces() {
+        
+        // Remove internal control interfaces
+        List l = new ArrayList();
+        Object[] itfs = super.getFcInterfaces();
+        for (int i = 0; i < itfs.length; i++) {
+            Interface itf = (Interface) itfs[i];
+            if( ! 
FractalHelper.isFcControllerInterfaceName(itf.getFcItfName()) ) {
+                l.add(itf);
+            }
+        }
+        
+        return l.toArray();
+    }
+    
+    // --------------------------------------------------------------
+    // Implementation specific
+    // --------------------------------------------------------------
+    
+    /**
+     * Register a new control interface.
+     */
+    public Interface registerFcControlInterface( InterfaceType it, Object 
ctrl ){
+        InterfaceType newit = newSymetricInterfaceType(it);
+        return super.registerFcControlInterface(newit,ctrl);
+    }
+
+    /**
+     * Get the {@link Interface} instance associated to the given interface 
type
+     * for the given component.
+     */
+    protected Interface getFcInterface(
+            InterfaceType it, Component itfOwner, Object content,
+            boolean isFcInternalInterface ) {
+        
+        InterfaceType newit = newSymetricInterfaceType(it);
+        return
+            getProxyInterface(
+                newit,itfOwner,content,
+                true,   // internal
+                true    // boundable
+            );
+    }
+    
+    /**
+     * Return a copy of the given interface type where the client role is
+     * transformed into server and the server role is transformed into 
client.
+     */
+    private static InterfaceType newSymetricInterfaceType( InterfaceType it 
) {
+        return
+            new InterfaceTypeImpl(
+                    it.getFcItfName(),
+                    it.getFcItfSignature(),
+                    ! it.isFcClientItf(),   // client <-> server
+                    it.isFcOptionalItf(),
+                    it.isFcCollectionItf()
+            );        
+    }
+    
+}
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/interf/InterfaceManager.java
diff -u /dev/null 
aokell/src/org/objectweb/fractal/aokell/lib/interf/InterfaceManager.java:1.1
--- /dev/null   Wed Mar 29 20:56:11 2006
+++ aokell/src/org/objectweb/fractal/aokell/lib/interf/InterfaceManager.java  
  Wed Mar 29 20:56:10 2006
@@ -0,0 +1,85 @@
+/***
+ * AOKell
+ * Copyright (C) 2005-2006 INRIA, France Telecom
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+package org.objectweb.fractal.aokell.lib.interf;
+
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.type.InterfaceType;
+
+/**
+ * This class manages {@link Interface} instances.
+ * The component and the content controllers delegate to instances of this 
type
+ * the management of their interfaces.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public interface InterfaceManager {
+    
+    public void initFc( Type type, Component compctrlimpl, Object 
contentPart );
+    
+    /**
+     * Return the instance implementing the {@link Interface} corresponding 
to
+     * the given name. The returned value is of type Object to be compatible
+     * with the {@link org.objectweb.fractal.api.Component} interface.
+     */
+    public Object getFcInterface(String interfaceName)
+    throws NoSuchInterfaceException;
+    
+    /**
+     * Return the array of {@link Interface} instances implemented by this
+     * component. The returned values are of type Object to be compatible 
with
+     * the {@link org.objectweb.fractal.api.Component} interface.
+     */
+    public Object[] getFcInterfaces();
+
+    /**
+     * Register a new collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException;
+
+    /**
+     * Unregister a collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public void unregisterFcInterface( String interfaceName )
+    throws NoSuchInterfaceException;
+
+    /**
+     * Register a new control interface.
+     */
+    public Interface registerFcControlInterface( InterfaceType it, Object 
ctrl );
+}
Index: 
aokell/src/org/objectweb/fractal/aokell/lib/interf/PrimitiveExtItfManager.java
diff -u /dev/null 
aokell/src/org/objectweb/fractal/aokell/lib/interf/PrimitiveExtItfManager.java:1.1
--- /dev/null   Wed Mar 29 20:56:11 2006
+++ 
aokell/src/org/objectweb/fractal/aokell/lib/interf/PrimitiveExtItfManager.java
      Wed Mar 29 20:56:10 2006
@@ -0,0 +1,258 @@
+/***
+ * AOKell
+ * Copyright (C) 2005-2006 INRIA, France Telecom
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+package org.objectweb.fractal.aokell.lib.interf;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.fractal.aokell.lib.InterfaceImpl;
+import org.objectweb.fractal.aokell.lib.type.InterfaceTypeImpl;
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.Type;
+import org.objectweb.fractal.api.type.ComponentType;
+import org.objectweb.fractal.api.type.InterfaceType;
+
+/**
+ * A manager for external interfaces of primitive components.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public class PrimitiveExtItfManager implements InterfaceManager {
+    
+    /** The interfaces managed by this component. */
+    // Map<String,Object> <interface name,interface>
+    private Map itfs;
+    
+    protected Component compctrlimpl;
+    protected ComponentType type;
+    protected Object content;
+
+    
+    public void initFc( Type type, Component compctrlimpl, Object content ) {
+        
+        this.type = (ComponentType) type;
+        this.compctrlimpl = compctrlimpl;
+        this.content = content;
+        
+        /*
+         * Discard old interfaces if there are some.
+         */
+        itfs = new HashMap();
+        ComponentType ct = (ComponentType) type;
+        InterfaceType[] its = ct.getFcInterfaceTypes();
+        for (int i = 0; i < its.length; i++) {
+            /*
+             * Collection interfaces defined in the type do not exist as
+             * Interface instances. An instance for a collection is created:
+             * - when an instance is requested with getFcInterface() or,
+             * - when the interface is bound with bindFc().
+             */
+            if( ! its[i].isFcCollectionItf() ) {
+                Interface itf =
+                    getFcInterface(its[i],compctrlimpl,content,false);
+                itfs.put(its[i].getFcItfName(),itf);
+            }
+        }
+    }
+    
+    /**
+     * Return the instance implementing the {@link Interface} corresponding 
to
+     * the given name. The returned value is of type Object to be compatible
+     * with the {@link org.objectweb.fractal.api.Component} interface.
+     */
+    public Object getFcInterface(String interfaceName)
+    throws NoSuchInterfaceException {
+        
+        if( itfs.containsKey(interfaceName) ) {
+            return itfs.get(interfaceName);
+        }
+        
+        /*
+         * The interface name has not been found.
+         * Try to register it as a collection interface.
+         */
+        return registerFcInterface(interfaceName);
+    }
+    
+    /**
+     * Return the array of {@link Interface} instances implemented by this
+     * component. The returned values are of type Object to be compatible 
with
+     * the {@link org.objectweb.fractal.api.Component} interface.
+     */
+    public Object[] getFcInterfaces() {
+        
+        // Remove hidden interfaces
+        List l = new ArrayList();
+        for (Iterator iter = itfs.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String itfName = (String) entry.getKey();
+            if( itfName.charAt(0) != '/' ) {
+                l.add(entry.getValue());
+            }
+        }
+        
+        return l.toArray();
+    }
+
+    /**
+     * Register a new collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public Interface registerFcInterface( String interfaceName )
+    throws NoSuchInterfaceException {
+        
+        /*
+         * Check whether the Interface is already registered or not.
+         */
+        if( itfs.containsKey(interfaceName) ) {
+            Interface itf = (Interface) itfs.get(interfaceName);
+            return itf;
+        }
+        
+        /*
+         * Check that the given name corresponds to the name of an existing
+         * interface.
+         */
+        InterfaceType[] its = type.getFcInterfaceTypes();
+        InterfaceType it = null;
+        for (int i = 0; i < its.length; i++) {
+            if( interfaceName.equals(its[i].getFcItfName()) ||
+                ( interfaceName.startsWith(its[i].getFcItfName()) &&
+                  its[i].isFcCollectionItf()) ) {
+                it = its[i];
+            }
+        }
+        
+        // No such interface type has been found
+        if( it == null ) {
+            throw new NoSuchInterfaceException(interfaceName);
+        }
+        
+        Interface itf = getFcInterface(it,compctrlimpl,content,false);
+        ((InterfaceImpl)itf).setFcItfName(interfaceName);
+        itfs.put(interfaceName,itf);
+        
+        return itf;
+    }
+
+    /**
+     * Unregister a collection {@link Interface} instance.
+     * The given name must start with an existing collection interface name
+     * decalred in the component type.
+     * 
+     * @param interfaceName  the interface name (e.g. foo004)
+     * @throws NoSuchInterfaceException
+     *      if there is no such collection interface
+     */
+    public void unregisterFcInterface( String interfaceName )
+    throws NoSuchInterfaceException {
+        
+        if( ! itfs.containsKey(interfaceName) ) {
+            throw new NoSuchInterfaceException(interfaceName);
+        }
+        
+        /*
+         * If the interface is of type singleton, keep it in the list.
+         */
+        Interface itf = (Interface) itfs.get(interfaceName);
+        InterfaceType it = (InterfaceType) itf.getFcItfType();
+        if( it.isFcCollectionItf() ) {
+            itfs.remove(interfaceName);
+        }
+    }
+
+    /**
+     * Register a new control interface.
+     */
+    public Interface registerFcControlInterface( InterfaceType it, Object 
ctrl ){
+        // Do not use getFcInterface which is overidden by sub-classes
+        Interface itf =
+            getProxyInterface(
+                    it,compctrlimpl,ctrl,
+                    false,  // external
+                    false   // implemented
+                );
+        itfs.put(it.getFcItfName(),itf);
+        return itf;
+    }
+
+    
+    // --------------------------------------------------------------
+    // Implementation specific
+    // --------------------------------------------------------------
+    
+    /**
+     * Get the {@link Interface} instance associated to the given interface 
type
+     * for the given component.
+     */
+    protected Interface getFcInterface(
+            InterfaceType it, Component itfOwner, Object content,
+            boolean isFcInternalInterface ) {
+        return
+            getProxyInterface(
+                it,itfOwner,content,
+                isFcInternalInterface,
+                it.isFcClientItf()      // boundable when client
+            );                          // implemented when server
+    }
+    
+    /**
+     * Return an {@link Interface} instance for the given interface type.
+     * The returned instance implements both the Interface interface and the
+     * Java interface specified in the given interface type. The instance is 
a
+     * proxy generated with ASM when the fcinterface feature is set to asm.
+     * 
+     * @param it         the interface type
+     * @param itfOwner   the component owning this interface
+     * @param content    the instance implementing the content
+     * @param boundable
+     *     true if the interface can be bound (e.g. client for a primitive)
+     *     false otherwise (e.g. server for a primitive)
+     * @return           the interface instance
+     */
+    public static Interface getProxyInterface(
+            InterfaceType it, Component itfOwner, Object content,
+            boolean isFcInternalInterface, boolean boundable ) {
+        
+        Object proxy =
+            Delegator.generate(
+                it,                     // interface type              
+                itfOwner,               // component owning the interface
+                content,                // the instance holding the content
+                isFcInternalInterface,  // external interface
+                boundable               // boundable or implemented
+            );          
+        
+        return (Interface) proxy;
+    }
+}



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.