1 23 24 package j2me; 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 HelloWorld { 35 36 public static void main (final String [] args) throws Exception { 37 38 Component boot = Fractal.getBootstrapComponent(); 39 TypeFactory tf = Fractal.getTypeFactory(boot); 40 ComponentType rType = tf.createFcType(new InterfaceType[] { 42 tf.createFcItfType("m", "j2me.Main", false, false, false) 43 }); 44 ComponentType cType = tf.createFcType(new InterfaceType[] { 46 tf.createFcItfType("m", "j2me.Main", false, false, false), 47 tf.createFcItfType("s", "j2me.Service", true, false, false) 48 }); 49 ComponentType sType = tf.createFcType(new InterfaceType[] { 51 tf.createFcItfType("s", "j2me.Service", false, false, false), 52 tf.createFcItfType( 53 "attribute-controller", 54 "j2me.ServiceAttributes", 55 false, 56 false, 57 false) 58 }); 59 60 GenericFactory cf = Fractal.getGenericFactory(boot); 61 62 Component rComp = cf.newFcInstance(rType, "composite", null); 64 Component cComp = cf.newFcInstance(cType, "primitive", "j2me.ClientImpl"); 66 Component sComp = cf.newFcInstance(sType, "primitive", "j2me.ServerImpl"); 68 ((ServiceAttributes)Fractal.getAttributeController(sComp)).setHeader("-> "); 69 ((ServiceAttributes)Fractal.getAttributeController(sComp)).setCount(1); 70 71 Fractal.getContentController(rComp).addFcSubComponent(cComp); 73 Fractal.getContentController(rComp).addFcSubComponent(sComp); 74 Fractal.getBindingController(rComp).bindFc("m", cComp.getFcInterface("m")); 75 Fractal.getBindingController(cComp).bindFc("s", sComp.getFcInterface("s")); 76 77 Fractal.getLifeCycleController(rComp).startFc(); 79 80 ((Main)rComp.getFcInterface("m")).main(null); 82 } 83 } 84 | Popular Tags |