Mail Archive Home | fractal-commits List | March 2006 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Wednesday, March 29, 2006 @ 20:56:19
Author: seintur
Path:
.../features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory
Modified: MembraneFactoryImpl.java
New (simpler, more modular) implementation of the binding, content and
component controllers.
--------------------------+
MembraneFactoryImpl.java | 105 ++++++++++++++++++++++++---------------------
1 files changed, 57 insertions(+), 48 deletions(-)
Index:
aokell/features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory/MembraneFactoryImpl.java
diff -u
aokell/features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory/MembraneFactoryImpl.java:1.7
aokell/features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory/MembraneFactoryImpl.java:1.8
---
aokell/features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory/MembraneFactoryImpl.java:1.7
Tue Mar 28 00:42:08 2006
+++
aokell/features/membrane/oo/src/org/objectweb/fractal/aokell/lib/factory/MembraneFactoryImpl.java
Wed Mar 29 20:56:19 2006
@@ -26,6 +26,7 @@
import org.objectweb.fractal.aokell.Membranes;
import org.objectweb.fractal.aokell.lib.control.Controller;
import org.objectweb.fractal.aokell.lib.control.component.ComponentItf;
+import org.objectweb.fractal.aokell.lib.control.content.ContentControllerItf;
import org.objectweb.fractal.aokell.lib.membrane.ControllerDef;
import org.objectweb.fractal.aokell.lib.membrane.MembraneDef;
import org.objectweb.fractal.aokell.lib.membrane.marker.BaseType;
@@ -55,10 +56,42 @@
throws InstantiationException {
/*
- * Create and initialize the component controller.
+ * Instantiate controllers.
+ */
+ Controller[] ctrls = newFcControllers(controllerDesc);
+
+ /*
+ * Retieve the component controller and initialize it.
+ * The purpose of the initFc method is to initialize the management
of
+ * the component external interfaces.
+ *
+ * In the case of composite component, the content controller is in
+ * charge of the internal interfaces. Initialize it also.
+
+ */
+ ComponentItf compctrl = null;
+ ContentControllerItf cc = null;
+
+ for (int i = 0; i < ctrls.length; i++) {
+ if( ctrls[i] instanceof ComponentItf ) {
+ compctrl = (ComponentItf) ctrls[i];
+ }
+ else if( ctrls[i] instanceof ContentControllerItf ) {
+ cc = (ContentControllerItf) ctrls[i];
+ }
+ }
+
+ if( compctrl == null ) {
+ throw new InstantiationException(
+ "Unexpected error. compctrl shouldn't be null.");
+ }
+ /*
+ * If cc is null, the component is composite and this is not an
error.
*/
- ComponentItf compctrl = newFcComponentController(controllerDesc);
compctrl.initFc(type,controllerDesc,contentDesc,content);
+ if( cc != null ) {
+ cc.initFc(type,controllerDesc,contentDesc,compctrl,content);
+ }
/*
* Link the content part and the component controller.
@@ -68,9 +101,9 @@
}
/*
- * Initialize the controllers.
+ * Initialize controllers.
*/
- initFcControllers(controllerDesc,compctrl);
+ initFcControllers(controllerDesc,ctrls,compctrl,cc);
return compctrl;
}
@@ -91,72 +124,48 @@
// Implementation specific
// -----------------------------------------------------------------
- private ComponentItf newFcComponentController( Object controllerDesc )
+ private Controller[] newFcControllers( Object controllerDesc )
throws InstantiationException {
Membranes mr = Membranes.get();
MembraneDef mdef = mr.getMembraneDef(controllerDesc);
- ControllerDef[] ctrls = mdef.getCtrls();
- ComponentItf compctrl = null;
+ ControllerDef[] ctrldefs = mdef.getCtrls();
+ Controller[] ctrls = new Controller[ ctrldefs.length ];
- for (int i = 0; i < ctrls.length; i++) {
- Class ctrlcl = ctrls[i].getImpl();
-
- if( Component.class.isAssignableFrom(ctrlcl) ) {
- Controller ctrl = null;
- try {
- ctrl = (Controller) ctrlcl.newInstance();
- }
- catch( Exception e ) {
- throw new InstantiationException(e.getMessage());
- }
- compctrl = (ComponentItf) ctrl;
- ctrl.setFcCompCtrl(compctrl);
- ctrl.initFcCtrl();
- compctrl.addFcController(ctrls[i].getType(),ctrl);
+ for (int i = 0; i < ctrldefs.length; i++) {
+ Class ctrlcl = ctrldefs[i].getImpl();
+ try {
+ ctrls[i] = (Controller) ctrlcl.newInstance();
+ }
+ catch( Exception e ) {
+ throw new InstantiationException(e.getMessage());
}
}
- return compctrl;
+ return ctrls;
}
/**
* Initialize the controllers.
*/
private void initFcControllers(
- Object controllerDesc, ComponentItf compctrl )
+ Object controllerDesc, Controller[] ctrls,
+ ComponentItf compctrl, ContentControllerItf cc )
throws InstantiationException {
Membranes mr = Membranes.get();
MembraneDef mdef = mr.getMembraneDef(controllerDesc);
- ControllerDef[] ctrls = mdef.getCtrls();
+ ControllerDef[] ctrldefs = mdef.getCtrls();
+ // Note: ctrls.length = ctrldefs.length
for (int i = 0; i < ctrls.length; i++) {
- Class ctrlcl = ctrls[i].getImpl();
-
- // Skip the component controller
- if( ! Component.class.isAssignableFrom(ctrlcl) ) {
- Object ctrl = null;
- try {
- ctrl = ctrlcl.newInstance();
- }
- catch( Exception e ) {
- throw new InstantiationException(e.getMessage());
- }
- if( ctrl instanceof Controller ) {
- ((Controller)ctrl).setFcCompCtrl(compctrl);
- ((Controller)ctrl).initFcCtrl();
- }
- compctrl.addFcController(ctrls[i].getType(),ctrl);
+ ctrls[i].setFcCompCtrl(compctrl);
+ ctrls[i].initFcCtrl();
+ compctrl.addFcController(ctrldefs[i].getType(),ctrls[i]);
+ if( cc != null ) {
+ cc.addFcController(ctrldefs[i].getType(),ctrls[i]);
}
}
-
- /*
- * Re-initialize the component controller.
- * Controllers have been added and cached values (list of interfaces,
- * etc.) may need to be recomputed.
- */
- ((Controller)compctrl).initFcCtrl();
}
}
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.