1 23 24 import java.util.Arrays ; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.factory.GenericFactory; 28 import org.objectweb.fractal.api.type.ComponentType; 29 import org.objectweb.fractal.api.type.InterfaceType; 30 import org.objectweb.fractal.api.type.TypeFactory; 31 32 import org.objectweb.fractal.util.Fractal; 33 34 public class Collection { 35 36 public static void main (String [] args) throws Exception { 37 Component boot = Fractal.getBootstrapComponent(); 38 39 TypeFactory tf = Fractal.getTypeFactory(boot); 40 ComponentType aType = tf.createFcType(new InterfaceType[0]); 41 ComponentType bType = tf.createFcType(new InterfaceType[] { 42 tf.createFcItfType("client", "I", true, true, true) 43 }); 44 ComponentType sType = tf.createFcType(new InterfaceType[] { 45 tf.createFcItfType("server", "I", false, false, false) 46 }); 47 48 GenericFactory cf = Fractal.getGenericFactory(boot); 49 50 Component aComp = cf.newFcInstance(aType, "composite", null); 51 Component bComp = cf.newFcInstance(bType, "autoBindingComposite", null); 52 Component cComp = cf.newFcInstance(bType, "autoBindingPrimitive", "CImpl"); 53 Component s1Comp = cf.newFcInstance(sType, "primitive", "SImpl"); 54 Component s2Comp = cf.newFcInstance(sType, "primitive", "SImpl"); 55 Component s3Comp = cf.newFcInstance(sType, "primitive", "SImpl"); 56 57 Fractal.getContentController(aComp).addFcSubComponent(bComp); 58 Fractal.getContentController(aComp).addFcSubComponent(s1Comp); 59 Fractal.getContentController(aComp).addFcSubComponent(s2Comp); 60 Fractal.getContentController(aComp).addFcSubComponent(s3Comp); 61 Fractal.getContentController(bComp).addFcSubComponent(cComp); 62 63 Fractal.getBindingController(bComp).bindFc( 65 "client-I", s1Comp.getFcInterface("server")); 66 67 Fractal.getBindingController(cComp).bindFc( 71 "client", 72 Fractal.getContentController(bComp).getFcInternalInterface("client")); 73 74 String [] itfs = Fractal.getBindingController(cComp).listFc(); 76 System.out.println(Arrays.asList(itfs)); 77 78 Fractal.getBindingController(bComp).bindFc( 81 "client-II", s2Comp.getFcInterface("server")); 82 Fractal.getBindingController(bComp).bindFc( 83 "client-III", s3Comp.getFcInterface("server")); 84 85 itfs = Fractal.getBindingController(cComp).listFc(); 87 System.out.println(Arrays.asList(itfs)); 88 89 Fractal.getBindingController(bComp).unbindFc("client-I"); 91 Fractal.getBindingController(bComp).unbindFc("client-II"); 92 Fractal.getBindingController(bComp).unbindFc("client-III"); 93 94 itfs = Fractal.getBindingController(cComp).listFc(); 95 System.out.println(Arrays.asList(itfs)); 96 } 97 } 98 | Popular Tags |