Authors: | |||
E. Bruneton | (France Telecom R&D) | ||
T. Coupaye | (France Telecom R&D) | ||
J.B. Stefani | (INRIA) |
Released | September 12, 2003 |
Status | Draft |
Version | 2.0-2 |
package org.objectweb.naming;
interface Name { NamingContext getNamingContext (); byte[] encode () throws NamingException; } interface NamingContext { Name export (any o, any hints) throws NamingException; Name decode (byte[] b) throws NamingException; } interface Binder extends NamingContext { any bind (Name n, any hints) throws NamingException; } |
package org.objectweb.fractal.api;
interface Component { any[] getFcInterfaces (); any getFcInterface (string itfName) throws NoSuchInterfaceException; Type getFcType (); } interface Type { boolean isFcSubTypeOf (Type t); } |
package org.objectweb.fractal.api;
interface Interface { string getFcItfName (); Type getFcItfType (); Component getFcItfOwner (); boolean isFcInternalItf (); } |
package org.objectweb.fractal.api.control;
interface AttributeController { } |
package org.objectweb.fractal.api.control;
interface BindingController { string[] listFc (); any lookupFc (string clientItfName) throws NoSuchInterfaceException; void bindFc (string clientItfName, any serverItf) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException; void unbindFc (string clientItfName) throws NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException; } |
package org.objectweb.fractal.api.control;
interface ContentController { any[] getFcInternalInterfaces (); any getFcInternalInterface (string itfName) throws NoSuchInterfaceException; Component[] getFcSubComponents (); void addFcSubComponent (Component c) throws IllegalContentException, IllegalLifeCycleException; void removeFcSubComponent (Component c) throws IllegalContentException, IllegalLifeCycleException; } interface SuperController { Component[] getFcSuperComponents (); } |
interface NameController {
string getFcName (); void setFcName (string name); } |
package org.objectweb.fractal.api.control;
interface LifeCycleController { string getFcState (); void startFc () throws IllegalLifeCycleException; void stopFc () throws IllegalLifeCycleException; } |
STOPPED | STARTED | |
startFc | STARTED | STARTED |
stopFc | STOPPED | STOPPED |
package org.objectweb.fractal.api.factory;
interface GenericFactory { Component newFcInstance (Type t, any controllerDesc, any contentDesc) throws InstantiationException; } interface Factory { Type getFcInstanceType (); any getFcControllerDesc (); any getFcContentDesc (); Component newFcInstance () throws InstantiationException; } |
package org.objectweb.fractal.api.type;
interface ComponentType { InterfaceType[] getFcInterfaceTypes (); InterfaceType getFcInterfaceType (string itfName) throws NoSuchInterfaceException; } interface InterfaceType { string getFcItfName (); string getFcItfSignature (); boolean isFcClientItf (); boolean isFcOptionalItf (); boolean isFcCollectionItf (); } interface TypeFactory { InterfaceType createFcItfType (string name, string signature, boolean isClient, boolean isOptional, boolean isCollection) throws InstantiationException; ComponentType createFcType (InterfaceType[] itfTypes) throws InstantiationException; } |
C | I | CT, IT | AC, BC, CC, LC | F | T | |
0 | ||||||
0.1 | x | |||||
1 | x | |||||
1.1 | x | x | ||||
2 | x | x | ||||
2.1 | x | x | x | |||
3 | x | x | x | |||
3.1 | x | x | x | x | ||
3.2 | x | x | x | x | x | |
3.3 | x | x | x | x | x | x |
Component boot = Fractal.getBootstrapComponent();
TypeFactory tf = (TypeFactory)boot.getFcInterface("type-factory"); |
ComponentType rType = tf.createFcType(new
InterfaceType[] {
tf.createFcItfType("m", "M", false, false, false) }); |
ComponentType cType = tf.createFcType(new
InterfaceType[] {
tf.createFcItfType("m", "M", false, false, false), tf.createFcItfType("s", "S", true, false, false) }); |
ComponentType sType = tf.createFcType(new
InterfaceType[] {
tf.createFcItfType("s", "S", false, false, false) }); |
GenericFactory gf = (GenericFactory)boot.getFcInterface("generic-factory"); |
Component rTmpl = gf.newFcInstance(
rType, "compositeTemplate", new Object[] {"composite", null}); |
Component cTmpl = gf.newFcInstance(
cType, "template", new Object[] {"primitive", "CImpl"}); |
Component sTmpl = gf.newFcInstance(
sType, "template", new Object[] {"primitive", "SImpl"}); |
public class
CImpl implements M, BindingController
{
private S s; public String[] listFc () { return new String[] { "s" }; } public Object lookupFc (String name) { if (name.equals("s")) return s; return null; } public Object bindFc (String name, Object itf) { if (name.equals("s")) s = (S)itf; } public Object unbindFc (String name) { if (name.equals("s")) s = null; } // ... } |
ContentController cc = (ContentController)rTmpl.getFcInterface("content-controller");
cc.addFcSubComponent(cTmpl); cc.addFcSubComponent(sTmpl); |
((BindingController)rTmpl.getFcInterface("binding-controller"))
.bindFc("m", cTmpl.getFcInterface("m")); |
((BindingController)cTmpl.getFcInterface("binding-controller"))
.bindFc("s", sTmpl.getFcInterface("s")); |
Component r = ((Factory)rTmpl.getFcInterface("factory")).newFcInstance(); |
((LifeCycleController)r.getFcInterface("lifecycle-controller")).startFc(); |
((LifeCycleController)r.getFcInterface("lifecycle-controller")).stopFc(); |
Component c = ((Interface)((BindingController)r.
getFcInterface("binding-controller")).lookupFc("m")).getFcItfOwner(); Component s = ((Interface)((BindingController)c. getFcInterface("binding-controller")).lookupFc("s")).getFcItfOwner(); |
((BindingController)c.getFcInterface("binding-controller")).unbindFc("s");
((ContentController)r.getFcInterface("content-controller")).removeFcSubComponent(s); |
Component newS = gf.newFcInstance(sType, "primitive", "NewSImpl"); |
((ContentController)r.getFcInterface("content-controller")).addFcSubComponent(newS);
((BindingController)c.getFcInterface("binding-controller")).bindFc("s", newS); ((LifeCycleController)r.getFcInterface("lifecycle-controller")).startFc(); |
package foo;
public class BarException extends Exception { public BarException (String msg) { super(msg); } } |