Mail Archive Home | fractal-commits List | January 2007 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Tuesday, January 23, 2007 @ 17:36:27
Author: seintur
Path: /cvsroot/fractal/julia
Added:
src/org/objectweb/fractal/juliak/factory/AbstractJuliaEnabledGenericFactoryImpl.java
src/org/objectweb/fractal/juliak/factory/ClasseDefinitions.java
Modified: examples/juliak/etc/execute.properties
examples/juliak/etc/julia.cfg
examples/juliak/src/membrane/Main.java
examples/juliak/src/membrane/glue/LoggablePrimitive.java
src/org/objectweb/fractal/julia/overview.html
src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java
src/org/objectweb/fractal/juliak/Juliak.java
src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java
src/org/objectweb/fractal/juliak/asm/ClassGenerator.java
src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java
src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/CompositeTemplateBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/ContainerAutoBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/ContainerBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/FlatContainerBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/FlatPrimitiveBindingController.fractal
src/org/objectweb/fractal/juliak/control/binding/PrimitiveBindingController.fractal
src/org/objectweb/fractal/juliak/control/component/ComponentController.fractal
src/org/objectweb/fractal/juliak/control/content/ContentController.fractal
src/org/objectweb/fractal/juliak/control/content/SuperController.fractal
src/org/objectweb/fractal/juliak/control/factory/FactoryController.fractal
src/org/objectweb/fractal/juliak/control/lifecycle/CompositeLifeCycleController.fractal
src/org/objectweb/fractal/juliak/control/lifecycle/LifeCycleController.fractal
src/org/objectweb/fractal/juliak/control/name/NameController.fractal
src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java
src/org/objectweb/fractal/juliak/factory/BasicGenericFactoryImpl.java
src/org/objectweb/fractal/juliak/factory/InstanceGenerator.java
src/org/objectweb/fractal/juliak/membrane/AutoBindingComposite.java
src/org/objectweb/fractal/juliak/membrane/AutoBindingPrimitive.java
src/org/objectweb/fractal/juliak/membrane/Bootstrap.java
src/org/objectweb/fractal/juliak/membrane/Composite.java
src/org/objectweb/fractal/juliak/membrane/CompositeTemplate.java
src/org/objectweb/fractal/juliak/membrane/FlatParametricPrimitive.java
src/org/objectweb/fractal/juliak/membrane/FlatParametricPrimitiveTemplate.java
src/org/objectweb/fractal/juliak/membrane/FlatPrimitive.java
src/org/objectweb/fractal/juliak/membrane/FlatPrimitiveTemplate.java
src/org/objectweb/fractal/juliak/membrane/ParametricComposite.java
src/org/objectweb/fractal/juliak/membrane/ParametricCompositeTemplate.java
src/org/objectweb/fractal/juliak/membrane/ParametricPrimitive.java
src/org/objectweb/fractal/juliak/membrane/ParametricPrimitiveTemplate.java
src/org/objectweb/fractal/juliak/membrane/Primitive.java
src/org/objectweb/fractal/juliak/membrane/PrimitiveTemplate.java
src/org/objectweb/fractal/juliak/platform/PlatformItf.java
src/org/objectweb/fractal/juliak/platform/PlatformJSE.java
test/conform/conf.xml
test/conform/org/objectweb/fractal/julia/conform/controllers/StatComposite.java
test/conform/org/objectweb/fractal/julia/conform/controllers/StatPrimitive.java
test/perf/perf8.xml
Removed:
src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/ContainerAutoBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/ContainerBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/FlatContainerBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/FlatPrimitiveBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/binding/PrimitiveBindingControllerImpl.java
src/org/objectweb/fractal/juliak/control/component/ComponentImpl.java
src/org/objectweb/fractal/juliak/control/content/ContentControllerImpl.java
src/org/objectweb/fractal/juliak/control/content/SuperControllerImpl.java
src/org/objectweb/fractal/juliak/control/factory/FactoryControllerImpl.java
src/org/objectweb/fractal/juliak/control/lifecycle/AbstractLifeCycleInterceptor.java
src/org/objectweb/fractal/juliak/control/lifecycle/CompositeLifeCycleControllerImpl.java
src/org/objectweb/fractal/juliak/control/lifecycle/LifeCycleControllerImpl.java
src/org/objectweb/fractal/juliak/control/name/NameControllerImpl.java
Remove adherence to the spoon generated controller implementations. Use the
julia ASM mixin generator.
---------------------------------------------------------------------------------------------+
examples/juliak/etc/execute.properties
| 4
examples/juliak/etc/julia.cfg
| 138 +
examples/juliak/src/membrane/Main.java
| 7
examples/juliak/src/membrane/glue/LoggablePrimitive.java
| 12
src/org/objectweb/fractal/julia/overview.html
| 79
src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java
| 44
src/org/objectweb/fractal/juliak/Juliak.java
| 76
src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java
| 82
src/org/objectweb/fractal/juliak/asm/ClassGenerator.java
| 8
src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java
| 2
src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java
| 1005 ----------
src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java
| 891 --------
src/org/objectweb/fractal/juliak/control/binding/CompositeTemplateBindingController.fractal
| 3
src/org/objectweb/fractal/juliak/control/binding/ContainerAutoBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/ContainerAutoBindingControllerImpl.java
| 842 --------
src/org/objectweb/fractal/juliak/control/binding/ContainerBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/ContainerBindingControllerImpl.java
| 712 -------
src/org/objectweb/fractal/juliak/control/binding/FlatContainerBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/FlatContainerBindingControllerImpl.java
| 580 -----
src/org/objectweb/fractal/juliak/control/binding/FlatPrimitiveBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/FlatPrimitiveBindingControllerImpl.java
| 451 ----
src/org/objectweb/fractal/juliak/control/binding/PrimitiveBindingController.fractal
| 4
src/org/objectweb/fractal/juliak/control/binding/PrimitiveBindingControllerImpl.java
| 583 -----
src/org/objectweb/fractal/juliak/control/component/ComponentController.fractal
| 4
src/org/objectweb/fractal/juliak/control/component/ComponentImpl.java
| 163 -
src/org/objectweb/fractal/juliak/control/content/ContentController.fractal
| 4
src/org/objectweb/fractal/juliak/control/content/ContentControllerImpl.java
| 641 ------
src/org/objectweb/fractal/juliak/control/content/SuperController.fractal
| 4
src/org/objectweb/fractal/juliak/control/content/SuperControllerImpl.java
| 84
src/org/objectweb/fractal/juliak/control/factory/FactoryController.fractal
| 4
src/org/objectweb/fractal/juliak/control/factory/FactoryControllerImpl.java
| 407 ----
src/org/objectweb/fractal/juliak/control/lifecycle/AbstractLifeCycleInterceptor.java
| 116 -
src/org/objectweb/fractal/juliak/control/lifecycle/CompositeLifeCycleController.fractal
| 5
src/org/objectweb/fractal/juliak/control/lifecycle/CompositeLifeCycleControllerImpl.java
| 504 -----
src/org/objectweb/fractal/juliak/control/lifecycle/LifeCycleController.fractal
| 5
src/org/objectweb/fractal/juliak/control/lifecycle/LifeCycleControllerImpl.java
| 565 -----
src/org/objectweb/fractal/juliak/control/name/NameController.fractal
| 6
src/org/objectweb/fractal/juliak/control/name/NameControllerImpl.java
| 53
src/org/objectweb/fractal/juliak/factory/AbstractGenericFactoryImpl.java
| 67
src/org/objectweb/fractal/juliak/factory/AbstractJuliaEnabledGenericFactoryImpl.java
| 127 +
src/org/objectweb/fractal/juliak/factory/BasicGenericFactoryImpl.java
| 71
src/org/objectweb/fractal/juliak/factory/ClasseDefinitions.java
| 126 +
src/org/objectweb/fractal/juliak/factory/InstanceGenerator.java
| 2
src/org/objectweb/fractal/juliak/membrane/AutoBindingComposite.java
| 14
src/org/objectweb/fractal/juliak/membrane/AutoBindingPrimitive.java
| 12
src/org/objectweb/fractal/juliak/membrane/Bootstrap.java
| 4
src/org/objectweb/fractal/juliak/membrane/Composite.java
| 14
src/org/objectweb/fractal/juliak/membrane/CompositeTemplate.java
| 14
src/org/objectweb/fractal/juliak/membrane/FlatParametricPrimitive.java
| 9
src/org/objectweb/fractal/juliak/membrane/FlatParametricPrimitiveTemplate.java
| 10
src/org/objectweb/fractal/juliak/membrane/FlatPrimitive.java
| 10
src/org/objectweb/fractal/juliak/membrane/FlatPrimitiveTemplate.java
| 10
src/org/objectweb/fractal/juliak/membrane/ParametricComposite.java
| 14
src/org/objectweb/fractal/juliak/membrane/ParametricCompositeTemplate.java
| 14
src/org/objectweb/fractal/juliak/membrane/ParametricPrimitive.java
| 12
src/org/objectweb/fractal/juliak/membrane/ParametricPrimitiveTemplate.java
| 12
src/org/objectweb/fractal/juliak/membrane/Primitive.java
| 12
src/org/objectweb/fractal/juliak/membrane/PrimitiveTemplate.java
| 12
src/org/objectweb/fractal/juliak/platform/PlatformItf.java
| 22
src/org/objectweb/fractal/juliak/platform/PlatformJSE.java
| 12
test/conform/conf.xml
| 6
test/conform/org/objectweb/fractal/julia/conform/controllers/StatComposite.java
| 14
test/conform/org/objectweb/fractal/julia/conform/controllers/StatPrimitive.java
| 12
test/perf/perf8.xml
| 4
66 files changed, 869 insertions(+), 7879 deletions(-)
Index: julia/examples/juliak/etc/execute.properties
diff -u julia/examples/juliak/etc/execute.properties:1.1
julia/examples/juliak/etc/execute.properties:1.2
--- julia/examples/juliak/etc/execute.properties:1.1 Wed Jan 17 15:09:15
2007
+++ julia/examples/juliak/etc/execute.properties Tue Jan 23 17:36:26
2007
@@ -1,5 +1,7 @@
run.jvm.parameters \
- -Dfractal.provider=org.objectweb.fractal.juliak.Juliak
+ -Dfractal.provider=org.objectweb.fractal.juliak.Juliak \
+ -Djulia.loader=org.objectweb.fractal.julia.loader.DynamicLoader \
+ -Djulia.config=etc/julia.cfg
# Java class to be launched
Index: julia/examples/juliak/etc/julia.cfg
diff -u julia/examples/juliak/etc/julia.cfg:1.1
julia/examples/juliak/etc/julia.cfg:1.2
--- julia/examples/juliak/etc/julia.cfg:1.1 Wed Jan 17 15:09:15 2007
+++ julia/examples/juliak/etc/julia.cfg Tue Jan 23 17:36:26 2007
@@ -125,6 +125,8 @@
org.objectweb.fractal.julia.BasicComponentMixin
# to check type related constraints, and for collection interfaces
support:
org.objectweb.fractal.julia.TypeComponentMixin
+ # to dynamically add/remove interceptors on collection interfaces:
+
org.objectweb.fractal.juliak.control.interceptor.CollectionItfComponentMixin
))
)
@@ -278,6 +280,8 @@
org.objectweb.fractal.julia.control.content.CheckContentMixin
# to check type related constraints in getFcInternalInterface:
org.objectweb.fractal.julia.control.content.TypeContentMixin
+ # to dynamically add/remove interceptors on collection interfaces:
+
org.objectweb.fractal.juliak.control.interceptor.CollectionItfContentControllerMixin
# to check binding locality related constraints in removeFcSubComponent:
org.objectweb.fractal.julia.control.content.BindingContentMixin
# to check lifecycle related constraints:
@@ -610,4 +614,136 @@
# CUSTOM CONFIGURATION INFORMATION
###############################################################################
-# no custom definitions
+#
-----------------------------------------------------------------------------
+# Definitions for a "flat" component model, without composite components
+# ContentController, SuperController and all Content related mixins are not
used
+#
-----------------------------------------------------------------------------
+
+(flat-primitive-binding-controller-impl
+ ((org.objectweb.fractal.julia.asm.MixinClassGenerator
+ FlatPrimitiveBindingControllerImpl
+ org.objectweb.fractal.julia.BasicControllerMixin
+ org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin
+ # to initialize the BasicBindingControllerMixin from the component's
type:
+ org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin
+ # to check some basic pre conditions (interface not already bound, ...)
+ org.objectweb.fractal.julia.UseComponentMixin
+ org.objectweb.fractal.julia.control.binding.CheckBindingMixin
+ # to check type related constraints for bindings:
+ org.objectweb.fractal.julia.control.binding.TypeBindingMixin
+ # to check content related constraints for bindings:
+ # org.objectweb.fractal.julia.control.content.UseSuperControllerMixin
+ # org.objectweb.fractal.julia.control.binding.ContentBindingMixin
+ # to check lifecycle related constraints for bindings:
+ org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
+ org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin
+ ))
+)
+
+(flat-container-binding-controller-impl
+ ((org.objectweb.fractal.julia.asm.MixinClassGenerator
+ FlatContainerBindingControllerImpl
+ org.objectweb.fractal.julia.BasicControllerMixin
+
org.objectweb.fractal.julia.control.binding.ContainerBindingControllerMixin
+ # to skip Interface objects before delegating to the encapsulated
component:
+ #
org.objectweb.fractal.julia.control.binding.OptimizedContainerBindingMixin
+ # to manage output interceptors:
+ org.objectweb.fractal.julia.UseComponentMixin
+ org.objectweb.fractal.julia.control.binding.InterceptorBindingMixin
+ # to check some basic pre conditions (interface not already bound, ...)
+ org.objectweb.fractal.julia.control.binding.CheckBindingMixin
+ # to check type related constraints for bindings:
+ org.objectweb.fractal.julia.control.binding.TypeBindingMixin
+ # to check content related constraints for bindings:
+ # org.objectweb.fractal.julia.control.content.UseSuperControllerMixin
+ # org.objectweb.fractal.julia.control.binding.ContentBindingMixin
+ # to check lifecycle related constraints for bindings:
+ org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
+ org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin
+ ))
+)
+
+(flatPrimitive
+ (
+ 'interface-class-generator
+ (
+ 'component-itf
+ 'binding-controller-itf
+ 'lifecycle-controller-itf
+ # only if lifecycle-controller-itf does not designate the Julia
interface:
+ # 'julia-lifecycle-controller-itf
+ 'name-controller-itf
+ )
+ (
+ 'component-impl
+ 'flat-container-binding-controller-impl
+ 'lifecycle-controller-impl
+ 'name-controller-impl
+ )
+ (
+ (org.objectweb.fractal.julia.asm.InterceptorClassGenerator
+ org.objectweb.fractal.julia.asm.LifeCycleCodeGenerator
+ )
+ )
+ org.objectweb.fractal.julia.asm.MergeClassGenerator
+ 'optimizationLevel
+ )
+)
+
+(flatParametricPrimitive
+ 'flatPrimitive
+)
+
+(flatPrimitiveTemplate
+ (
+ 'interface-class-generator
+ (
+ 'component-itf
+ 'binding-controller-itf
+ 'name-controller-itf
+ 'factory-itf
+ # only if factory-itf does not designate the Julia interface:
+ # 'julia-factory-itf
+ )
+ (
+ 'component-impl
+ 'flat-primitive-binding-controller-impl
+ 'name-controller-impl
+ 'factory-impl
+ )
+ (
+ # no interceptors
+ )
+ org.objectweb.fractal.julia.asm.MergeClassGenerator
+ 'optimizationLevel
+ )
+)
+
+(flatParametricPrimitiveTemplate
+ (
+ 'interface-class-generator
+ (
+ 'component-itf
+ 'julia-attribute-controller-itf
+ 'binding-controller-itf
+ 'name-controller-itf
+ 'factory-itf
+ # only if factory-itf does not designate the Julia interface:
+ # 'julia-factory-itf
+ )
+ (
+ 'component-impl
+ ((org.objectweb.fractal.julia.asm.AttributeControllerClassGenerator
+ ('attributeControllerInterface)
+ ))
+ 'flat-primitive-binding-controller-impl
+ 'name-controller-impl
+ 'factory-impl
+ )
+ (
+ # no interceptors
+ )
+ org.objectweb.fractal.julia.asm.MergeClassGenerator
+ 'optimizationLevel
+ )
+)
Index: julia/examples/juliak/src/membrane/Main.java
diff -u julia/examples/juliak/src/membrane/Main.java:1.1
julia/examples/juliak/src/membrane/Main.java:1.2
--- julia/examples/juliak/src/membrane/Main.java:1.1 Wed Jan 17 15:09:16
2007
+++ julia/examples/juliak/src/membrane/Main.java Tue Jan 23 17:36:26
2007
@@ -32,6 +32,7 @@
* <li> control membrane introspection </li>
* <li> gluing of a control membrane to a content instance </li>
* <li> dynamic management of interceptors </li>
+ * <li> joint use of object-oriented and component-based control membranes
</li>
* </ul>
*
* @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
@@ -57,5 +58,11 @@
System.err.println("===================================================");
membrane.interceptor.Main.main(args);
+ System.err.println();
+
System.err.println("===================================================");
+ System.err.println("==== Joint use of OO and CB membranes
====");
+
System.err.println("===================================================");
+ membrane.mix.Main.main(args);
+
}
}
Index: julia/examples/juliak/src/membrane/glue/LoggablePrimitive.java
diff -u julia/examples/juliak/src/membrane/glue/LoggablePrimitive.java:1.1
julia/examples/juliak/src/membrane/glue/LoggablePrimitive.java:1.2
--- julia/examples/juliak/src/membrane/glue/LoggablePrimitive.java:1.1 Wed
Jan 17 15:09:15 2007
+++ julia/examples/juliak/src/membrane/glue/LoggablePrimitive.java Tue
Jan 23 17:36:27 2007
@@ -52,27 +52,27 @@
try { Fractal.getNameController(C0).setFcName("LogC"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT2 = typeFactory.createFcItfType("//component",
"org.objectweb.fractal.api.Component", false, false, false);
ComponentType CT1 = typeFactory.createFcType(new InterfaceType [] { IT2 });
-Component C1 = genericFactory.newFcInstance(CT1, "mPrimitive",
"org.objectweb.fractal.juliak.control.component.ComponentImpl");
+Component C1 = genericFactory.newFcInstance(CT1, "mPrimitive",
"component-impl");
try { Fractal.getNameController(C1).setFcName("Comp"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT3 = typeFactory.createFcItfType("//name-controller",
"org.objectweb.fractal.api.control.NameController", false, false, false);
ComponentType CT2 = typeFactory.createFcType(new InterfaceType [] { IT3 });
-Component C2 = genericFactory.newFcInstance(CT2, "mPrimitive",
"org.objectweb.fractal.juliak.control.name.NameControllerImpl");
+Component C2 = genericFactory.newFcInstance(CT2, "mPrimitive",
"name-controller-impl");
try { Fractal.getNameController(C2).setFcName("NC"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT4 = typeFactory.createFcItfType("//component",
"org.objectweb.fractal.api.Component", true, false, false);
InterfaceType IT5 = typeFactory.createFcItfType("//lifecycle-controller",
"org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator", false,
false, false);
ComponentType CT3 = typeFactory.createFcType(new InterfaceType [] { IT4, IT5
});
-Component C3 = genericFactory.newFcInstance(CT3, "mPrimitive",
"org.objectweb.fractal.juliak.control.lifecycle.LifeCycleControllerImpl");
+Component C3 = genericFactory.newFcInstance(CT3, "mPrimitive",
"lifecycle-controller-impl");
try { Fractal.getNameController(C3).setFcName("LC"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT6 = typeFactory.createFcItfType("//lifecycle-controller",
"org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator", true,
false, false);
InterfaceType IT7 = typeFactory.createFcItfType("//super-controller",
"org.objectweb.fractal.julia.control.content.SuperControllerNotifier", true,
false, false);
InterfaceType IT8 = typeFactory.createFcItfType("//component",
"org.objectweb.fractal.api.Component", true, false, false);
InterfaceType IT9 = typeFactory.createFcItfType("//binding-controller",
"org.objectweb.fractal.api.control.BindingController", false, false, false);
ComponentType CT4 = typeFactory.createFcType(new InterfaceType [] { IT6,
IT7, IT8, IT9 });
-Component C4 = genericFactory.newFcInstance(CT4, "mPrimitive",
"org.objectweb.fractal.juliak.control.binding.ContainerBindingControllerImpl");
+Component C4 = genericFactory.newFcInstance(CT4, "mPrimitive",
"container-binding-controller-impl");
try { Fractal.getNameController(C4).setFcName("BC"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT10 = typeFactory.createFcItfType("//super-controller",
"org.objectweb.fractal.julia.control.content.SuperControllerNotifier", false,
false, false);
ComponentType CT5 = typeFactory.createFcType(new InterfaceType [] { IT10 });
-Component C5 = genericFactory.newFcInstance(CT5, "mPrimitive",
"org.objectweb.fractal.juliak.control.content.SuperControllerImpl");
+Component C5 = genericFactory.newFcInstance(CT5, "mPrimitive",
"super-controller-impl");
try { Fractal.getNameController(C5).setFcName("SC"); } catch
(NoSuchInterfaceException ignored) { }
InterfaceType IT11 = typeFactory.createFcItfType("//lifecycle-controller",
"org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator", true,
false, false);
InterfaceType IT12 = typeFactory.createFcItfType("//component",
"org.objectweb.fractal.api.Component", true, false, false);
@@ -133,6 +133,7 @@
return C8;
}
catch( Exception e ) {
+ e.printStackTrace();
throw new
org.objectweb.fractal.api.factory.InstantiationException(e.getMessage());
}
}
@@ -154,6 +155,7 @@
return CT9;
}
catch( Exception e ) {
+ e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
Index: julia/src/org/objectweb/fractal/julia/overview.html
diff -u julia/src/org/objectweb/fractal/julia/overview.html:1.10
julia/src/org/objectweb/fractal/julia/overview.html:1.11
--- julia/src/org/objectweb/fractal/julia/overview.html:1.10 Wed Jan 17
15:09:16 2007
+++ julia/src/org/objectweb/fractal/julia/overview.html Tue Jan 23 17:36:26
2007
@@ -801,8 +801,7 @@
components optimizations (see appendix <a href="#B">B</a>) are still
supported
without any modification.</p>
-<p align="left">The code related to the implementation of component-based
control membranes
-(CBCM) can be found in the <tt>
+<p align="left">The code related to the implementation of <b>component-based
control membranes (CBCM)</b> can be found in the <tt>
<a
href="org/objectweb/fractal/juliak/package-summary.html">org.objectweb.fractal.juliak</a></tt>
package and its sub packages. A new Fractal
provider class, <tt><a
href="org/objectweb/fractal/juliak/Juliak.html">org.objectweb.fractal.juliak.Juliak</a></tt>,
is available. When used,
@@ -819,7 +818,7 @@
<p>The rationale for using component-based control membrane is to be able to
(re)configure
the control part of a Fractal component. This control part (the membrane) is
a
component (a so-called control component) which exports some control
interfaces.
-Control components conforms to the Fractal API and they can be introspected
+Control components conform to the Fractal API. They can be introspected
and dynamically reconfigured.</p>
<p>No restriction is put on the implementation of a control membrane: this
can
@@ -882,7 +881,7 @@
commonly used membrane type.</p>
-<p><code><!-- o.o.f is shortcut for org.objectweb.fractal --><br>
+<p><code><!-- o.o.f is a shortcut for org.objectweb.fractal --><br>
<definition name="o.o.f.juliak.membrane.Primitive"<br>
extends="o.o.f.juliak.control.component.ComponentControllerType,<br>
@@ -892,7 +891,7 @@
o.o.f.juliak.control.name.NameControllerType,<br>
-o.o.f.juliak.control.superc.SuperControllerType,<br>
+o.o.f.juliak.control.content.SuperControllerType,<br>
o.o.f.juliak.control.interceptor.InterceptorControllerType,<br>
@@ -902,18 +901,18 @@
definition="o.o.f.juliak.control.component.ComponentController"
/><br>
<br>
<component name="BC"<br>
-
definition="org.o.o.f.juliak.control.binding.ContainerBindingController"
+
definition="o.o.f.juliak.control.binding.ContainerBindingController"
/><br>
<br>
<component name="LC"<br>
-
definition="org.o.o.f.juliak.control.lifecycle.LifeCycleController"
+
definition="o.o.f.juliak.control.lifecycle.LifeCycleController"
/><br>
<br>
<component name="NC"<br>
definition="o.o.f.juliak.control.name.NameController"
/><br>
<br>
<component name="SC"<br>
-
definition="o.o.f.juliak.control.superc.SuperController" /><br>
+
definition="o.o.f.juliak.control.content.SuperController" /><br>
<br>
<component name="IC"<br>
definition="o.o.f.juliak.control.lifecycle.LifeCycleInterceptor"
/><br>
@@ -980,12 +979,13 @@
<h3>9.3 Component-based membrane specific features</h3>
-<p>Three features are specific to CBCM:</p>
+<p>Four features are specific to CBCM:</p>
<ul>
<li>the introspection of a control membrane</li>
- <li>the binding of a membrane to a content</li>
+ <li>the gluing of a control membrane to a content</li>
<li>the dynamic management of interceptors</li>
+ <li>the joint use of object-oriented and component-based control
membrane</li>
</ul>
@@ -1027,7 +1027,7 @@
Component membrane = mc.getFcMembrane();</code></p>
-<h4>9.3.2 Binding of a membrane to a content</h4>
+<h4>9.3.2 Gluing of a control membrane to a content</h4>
<p>The component factory provided by the <tt><a
href="org/objectweb/fractal/juliak/Juliak.html">
@@ -1088,7 +1088,7 @@
<p>The interceptor controller is defined as follows:</p>
-<p><code><!-- o.o.f is shortcut for org.objectweb.fractal --><br>
+<p><code><!-- o.o.f is a shortcut for org.objectweb.fractal --><br>
<definition
name="o.o.f.juliak.control.interceptor.InterceptorController"<br>
extends="o.o.f.juliak.control.component.UseComponentControllerType"
><br>
<br>
@@ -1121,7 +1121,7 @@
definition of a <code>Primitive</code> membrane. Its definition follows:</p>
-<p><code><!-- o.o.f is shortcut for org.objectweb.fractal --><br>
+<p><code><!-- o.o.f is a shortcut for org.objectweb.fractal --><br>
<definition
name="o.o.f.juliak.control.lifecycle.LifeCycleInterceptor"<br>
extends="o.o.f.juliak.control.interceptor.InterceptorController,<br>
@@ -1131,9 +1131,9 @@
signature="o.o.f.juliak.control.interceptor.InterceptorDefAttributes"><br>
<attribute<br>
name="interceptors"<br>
-
value="(org.objectweb.fractal.julia.asm.InterceptorClassGenerator<br>
+
value="(o.o.f.julia.asm.InterceptorClassGenerator<br>
-org.objectweb.fractal.julia.asm.LifeCycleCodeGenerator)"<br>
+o.o.f.julia.asm.LifeCycleCodeGenerator)"<br>
/><br>
</attributes><br>
<br>
@@ -1143,12 +1143,59 @@
<p>The <code>interceptors</code> attribute in the previous piece of
Fractal-ADL
code specifies the class generator description which is attached to the
<code>
LifeCycleInterceptor</code> control component. The syntax of this
description
-follows the Lisp-like rules which are used in <code>julia.cfg</code> files.
When
+follows the Lisp-like style which is used in <code>julia.cfg</code> files.
When
a control membrane containing such an interceptor control component is bound
to
a content instance, interceptors are generated and attached to the
interfaces of
the component.</p>
+<h4>9.3.4 Joint use of object-oriented and component-based control
membrane</h4>
+
+
+<p>As said previously, the generic factory associated with the <tt><a
href="org/objectweb/fractal/juliak/Juliak.html">org.objectweb.fractal.juliak.Juliak</a></tt>
+Fractal provider class instanciates components equipped with a
component-based
+control membrane. The membrane is choosen according to the value of the
+controller descriptor parameter sent to the
+<a
href="http://fractal.objectweb.org/current/doc/javadoc/fractal/org/objectweb/fractal/api/factory/GenericFactory.html#newFcInstance(org.objectweb.fractal.api.Type,
java.lang.Object, java.lang.Object)">
+newFcInstance</a> method. This parameter is a string such as
<code>primitive</code>
+or <code>composite</code>.</p>
+
+
+<p>As an additional feature, the generic factory associated with the <tt><a
href="org/objectweb/fractal/juliak/Juliak.html">org.objectweb.fractal.juliak.Juliak</a></tt>
+Fractal provider class provides the ability to instanciate components
equipped
+with an object-oriented membrane. For that, a naming convention is adopted
which
+consists in inserting the <code>/julia/</code> prefix in front of controller
+descriptors. For example, the programmer may request a
<code>/julia/primitive</code>
+or a <code>/julia/composite</code> component. In such cases, this factory
+delegates the instanciation to the factory associated with the <tt>
+<a href="org/objectweb/fractal/julia/Julia.html">
+org.objectweb.fractal.julia.Julia</a> </tt>Fractal provider class. </p>
+
+
+<p>As a matter of example, the following piece of code create one composite
and
+two primitive components. The primitive ones are inserted into the composite
and
+are bound together. The composite and the second primitive are equipped with
a
+component-based membrane. The first primitive is equipped with an
+object-oriented membrane (see the second parameter of the call to
+<a
href="http://fractal.objectweb.org/current/doc/javadoc/fractal/org/objectweb/fractal/api/factory/GenericFactory.html#newFcInstance(org.objectweb.fractal.api.Type,
java.lang.Object, java.lang.Object)">
+newFcInstance</a> on line 2).</p>
+
+
+<p><code>Component root =
cf.newFcInstance(rType,"composite",null);<br>
+Component cComp =
cf.newFcInstance(cType,"/julia/primitive,"ClientImpl");<br>
+Component sComp =
cf.newFcInstance(sType,"primitive,"ServerImpl");<br>
+<br>
+Fractal.getContentController(root).addFcSubComponent(cComp);<br>
+Fractal.getContentController(root).addFcSubComponent(sComp);<br>
+<br>
+Fractal.getBindingController(root).bindFc("m",cComp.getFcInterface("s"));<br>
+Fractal.getBindingController(cComp).bindFc("s",sComp.getFcInterface("s"));</code></p>
+
+
+<p>By default, components with object-oriented and component-based membranes
+implement the same control semantics and are thus fully compatible.</p>
+
+
<hr><h2><a name="A"></a>A Mixins reference</h2>
<h3>A.1 Mixins for the <tt>Component</tt> interface</h3>
Index: julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java
diff -u
julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.8
julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.9
--- julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java:1.8
Wed Jan 17 15:09:16 2007
+++ julia/src/org/objectweb/fractal/juliak/BootstrapComponentImpl.java Tue
Jan 23 17:36:26 2007
@@ -23,6 +23,8 @@
package org.objectweb.fractal.juliak;
+import java.util.Map;
+
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.factory.GenericFactory;
@@ -30,16 +32,24 @@
import org.objectweb.fractal.api.type.ComponentType;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.api.type.TypeFactory;
+import org.objectweb.fractal.julia.loader.Loader;
+import org.objectweb.fractal.julia.loader.Tree;
/**
* Juliak bootstrap component implementation (aka content class).
- * This component provides a {@link TypeFactory} and a {@link
GenericFactory}.
+ * This component provides three interfaces:
+ *
+ * <ul>
+ * <li> <code>type-factory</code> of type {@link TypeFactory} </li>
+ * <li> <code>generic-factory</code> of type {@link GenericFactory} </li>
+ * <li> <code>loader</code> of type {@link Loader} </li>
+ * </ul>
*
* @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
* @since 2.5
*/
-public class BootstrapComponentImpl implements TypeFactory, GenericFactory {
+public class BootstrapComponentImpl implements TypeFactory, GenericFactory,
Loader {
// -----------------------------------------------------------------
// Implementation of the TypeFactory interface
@@ -75,4 +85,34 @@
return gf.newFcInstance(type,controllerDesc,contentDesc);
}
+ // -----------------------------------------------------------------
+ // Implementation of the Loader interface
+ // -----------------------------------------------------------------
+
+ private Loader loader = Juliak.get().getFcLoader();
+
+ public Tree evalTree(Tree tree, Map context) throws Exception {
+ return loader.evalTree(tree, context);
+ }
+
+ public void init(Map context) throws Exception {
+ loader.init(context);
+ }
+
+ public Class loadClass(String className, Object loader) throws
ClassNotFoundException {
+ return this.loader.loadClass(className, loader);
+ }
+
+ public Class loadClass(Tree classDescriptor, Object loader) throws
ClassNotFoundException {
+ return this.loader.loadClass(classDescriptor, loader);
+ }
+
+ public Tree loadTree(String name) throws Exception {
+ return loadTree(name);
+ }
+
+ public Object newObject(Tree objectDescriptor, Object loader) throws
Exception {
+ return this.loader.newObject(objectDescriptor, loader);
+ }
+
}
Index: julia/src/org/objectweb/fractal/juliak/Juliak.java
diff -u julia/src/org/objectweb/fractal/juliak/Juliak.java:1.9
julia/src/org/objectweb/fractal/juliak/Juliak.java:1.10
--- julia/src/org/objectweb/fractal/juliak/Juliak.java:1.9 Wed Jan 17
15:09:16 2007
+++ julia/src/org/objectweb/fractal/juliak/Juliak.java Tue Jan 23 17:36:26
2007
@@ -23,6 +23,8 @@
package org.objectweb.fractal.juliak;
+import java.util.HashMap;
+
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.Type;
import org.objectweb.fractal.api.factory.Factory;
@@ -31,6 +33,7 @@
import org.objectweb.fractal.api.type.ComponentType;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.api.type.TypeFactory;
+import org.objectweb.fractal.julia.loader.Loader;
import org.objectweb.fractal.julia.type.BasicComponentType;
import org.objectweb.fractal.julia.type.BasicInterfaceType;
import org.objectweb.fractal.juliak.factory.BasicGenericFactoryImpl;
@@ -62,22 +65,23 @@
return juliak;
}
- String bootTmplClassName = System.getProperty("fractal.provider");
- if (bootTmplClassName == null) {
- throw new RuntimeException(
- "The fractal.provider system property is not defined");
+ String clname = System.getProperty("fractal.provider");
+ if (clname == null) {
+ String msg = "The fractal.provider system property should be
defined and non empty";
+ throw new RuntimeException(msg);
}
try {
- Class bootTmplClass = Class.forName(bootTmplClassName);
- Object o = bootTmplClass.newInstance();
+ Class cl = Class.forName(clname);
+ Object o = cl.newInstance();
juliak = (Juliak) o;
return juliak;
}
catch (Exception e) {
- throw new RuntimeException(
- "Cannot find or instantiate the '" + bootTmplClassName +
- "' class specified in the fractal.provider system property");
+ String msg =
+ "Cannot find or instantiate the '" + clname +
+ "' class specified in the fractal.provider system property";
+ throw new RuntimeException(msg);
}
}
@@ -116,16 +120,20 @@
try {
TYPE =
new BasicComponentType(
- new InterfaceType[] {
- new BasicInterfaceType(
- "type-factory",
- TypeFactory.class.getName(),
- false, false, false),
- new BasicInterfaceType(
- "generic-factory",
- GenericFactory.class.getName(),
- false, false, false)
- });
+ new InterfaceType[] {
+ new BasicInterfaceType(
+ "type-factory",
+ TypeFactory.class.getName(),
+ false, false, false),
+ new BasicInterfaceType(
+ "generic-factory",
+ GenericFactory.class.getName(),
+ false, false, false),
+ new BasicInterfaceType(
+ "loader",
+ Loader.class.getName(),
+ false, false, false)
+ });
}
catch (InstantiationException e) {
throw new RuntimeException(e.getMessage());
@@ -183,6 +191,7 @@
private static TypeFactory tf;
private static GenericFactory gf;
+ private static Loader loader;
public TypeFactory getFcTypeFactory() {
if( tf == null ) {
@@ -197,5 +206,32 @@
}
return gf;
}
-
+
+ public Loader getFcLoader() {
+
+ if( loader != null ) {
+ return loader;
+ }
+
+ String clname = System.getProperty("julia.loader");
+ if( clname==null || clname.length()==0 ) {
+ String msg = "The julia.loader system property should be defined
and non empty";
+ throw new RuntimeException(msg);
+ }
+
+ try {
+ Class cl = Class.forName(clname);
+ Object o = cl.newInstance();
+ loader = (Loader) o;
+ loader.init(new HashMap());
+ return loader;
+ }
+ catch (Exception e) {
+ String msg =
+ "Cannot find or instantiate the '" + clname +
+ "' class specified in the fractal.provider system property";
+ throw new RuntimeException(msg);
+ }
+ }
+
}
Index: julia/src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java
diff -u
julia/src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java:1.3
julia/src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java:1.4
---
julia/src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java:1.3
Tue Jan 2 14:54:31 2007
+++ julia/src/org/objectweb/fractal/juliak/asm/AbstractClassGenerator.java
Tue Jan 23 17:36:26 2007
@@ -23,23 +23,17 @@
package org.objectweb.fractal.juliak.asm;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
import org.objectweb.fractal.api.factory.InstantiationException;
import org.objectweb.fractal.api.type.InterfaceType;
import org.objectweb.fractal.julia.InitializationContext;
-import org.objectweb.fractal.julia.loader.DynamicLoader;
import org.objectweb.fractal.julia.loader.Loader;
import org.objectweb.fractal.juliak.Juliak;
import org.objectweb.fractal.juliak.factory.ClassDefinition;
+import org.objectweb.fractal.juliak.factory.ClasseDefinitions;
import org.objectweb.fractal.juliak.platform.Platform;
/**
- * This class generates classes with the {@link
org.objectweb.fractal.julia.asm
- * Julia bytecode generation framework}.
+ * Root class for {@link InterfaceType}-based class generators.
*
* @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
* @since 2.5
@@ -84,9 +78,10 @@
/*
* Check whether the class has already been requested.
*/
- final String targetClassname = getTargetClassName(it);
- if( classes.containsKey(targetClassname) ) {
- ClassDefinition cd = (ClassDefinition)
classes.get(targetClassname);
+ ClasseDefinitions clrep = ClasseDefinitions.get();
+ String targetClassname = getTargetClassName(it);
+ if( clrep.containsClass(targetClassname) ) {
+ ClassDefinition cd = clrep.getClass(targetClassname);
return cd.cl;
}
@@ -99,23 +94,14 @@
catch( ClassNotFoundException cnfe ) {}
/*
- * Generate the class.
+ * Generate the class and register it.
*/
byte[] bytecode = generate(targetClassname,it,ic);
-
- /*
- * Register the generated class.
- */
- Class cl = Platform.get().defineClass(targetClassname,bytecode);
- ClassDefinition cd = new ClassDefinition(cl,bytecode);
- registerClass(targetClassname,cd);
+ ClassDefinition cd = clrep.registerClass(targetClassname,bytecode);
return cd.cl;
}
- /** The map of already generated classes. */
- private Map classes = new HashMap();
-
/**
* Return the name of the class generated by the current class generator
* for the specified interface type.
@@ -131,49 +117,6 @@
}
/**
- * Store a generated class into the memory cache.
- */
- private void registerClass(String targetClassname, ClassDefinition cd) {
-
- classes.put(targetClassname,cd);
-
- String cachedir =
System.getProperty(Juliak.DUMP_GENERATED_PROP_NAME);
- if( cachedir!=null && cachedir.length()!=0 ) {
- // If applies, dump the generated class to the cache
- try {
- Platform.get().dumpClassToFile(
- cachedir, targetClassname,cd.bytecode );
- }
- catch(IOException ioe) {
- final String msg = "IOException: " + ioe.getMessage();
- throw new RuntimeException(msg);
- }
- }
- }
-
- /**
- * Dump generated classes.
- */
- public void dumpClasses() {
-
- String dirname = System.getProperty("java.io.tmpdir");
-
- for (Iterator iter = classes.entrySet().iterator(); iter.hasNext();)
{
- Map.Entry entry = (Map.Entry) iter.next();
- String targetClassname = (String) entry.getKey();
- ClassDefinition cd = (ClassDefinition) entry.getValue();
-
- try {
- Platform.get().dumpClassToFile(
- dirname, targetClassname, cd.bytecode );
- }
- catch( IOException ioe ) {
- throw new RuntimeException("IOException: "+
ioe.getMessage());
- }
- }
- }
-
- /**
* Given a fully qualified name, return the corresponding simple name,
i.e.
* strip the package name.
*/
@@ -207,18 +150,15 @@
final private static String genByJuliakPkgName = "juliak.generated";
static private Loader loader;
- static private ClassLoader classloader;
protected Loader getLoader() {
if( loader == null ) {
- loader = new DynamicLoader();
+ loader = Juliak.get().getFcLoader();
}
return loader;
}
protected ClassLoader getClassLoader() {
- if( classloader == null ) {
- classloader = AbstractClassGenerator.class.getClassLoader();
- }
- return classloader;
+ Object o = Platform.get().getLoader();
+ return (ClassLoader) o;
}
}
Index: julia/src/org/objectweb/fractal/juliak/asm/ClassGenerator.java
diff -u julia/src/org/objectweb/fractal/juliak/asm/ClassGenerator.java:1.7
julia/src/org/objectweb/fractal/juliak/asm/ClassGenerator.java:1.8
--- julia/src/org/objectweb/fractal/juliak/asm/ClassGenerator.java:1.7 Mon
Dec 11 20:49:48 2006
+++ julia/src/org/objectweb/fractal/juliak/asm/ClassGenerator.java Tue
Jan 23 17:36:26 2007
@@ -28,8 +28,7 @@
import org.objectweb.fractal.julia.InitializationContext;
/**
- * Interface implemented by class generators defined in the
- * org.objectweb.fractal.julia.asm package.
+ * Root class for {@link InterfaceType}-based class generators.
*
* @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
* @since 2.5
@@ -71,9 +70,4 @@
* for the specified interface type.
*/
public String getTargetClassName( InterfaceType it );
-
- /**
- * Dump generated classes.
- */
- public void dumpClasses();
}
Index: julia/src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java
diff -u
julia/src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java:1.12
julia/src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java:1.13
---
julia/src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java:1.12
Tue Jan 2 14:54:31 2007
+++ julia/src/org/objectweb/fractal/juliak/asm/InterfaceClassGenerator.java
Tue Jan 23 17:36:26 2007
@@ -117,7 +117,7 @@
* org.objectweb.julia.asm.ClassGenerationException. Catch
Exception
* to avoid introducing a dependency towards julia-asm.jar. It
seems
* that caught exceptions introduce a dependency as soon as the
- * class even if the code is not reached.
+ * class is loaded even if the code is not reached.
*/
final String msg = "ClassGenerationException: "+cge.getMessage();
throw new InstantiationException(msg);
Index:
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal
diff -u
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal:1.3
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal:1.4
---
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal:1.3
Sat Dec 16 20:43:32 2006
+++
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingController.fractal
Tue Jan 23 17:36:26 2007
@@ -28,7 +28,9 @@
name="org.objectweb.fractal.juliak.control.binding.CompositeAutoBindingController"
extends="org.objectweb.fractal.juliak.control.binding.BindingControllerType,org.objectweb.fractal.juliak.control.component.UseComponentControllerType,org.objectweb.fractal.juliak.control.content.UseSuperControllerType,org.objectweb.fractal.juliak.control.lifecycle.UseLifeCycleControllerType,org.objectweb.fractal.juliak.control.content.UseContentControllerType"
>
- <content
class="org.objectweb.fractal.juliak.control.binding.CompositeAutoBindingControllerImpl"
/>
+ <!-- composite-auto-binding-controller-impl identifies the
implementation of -->
+ <!-- the composite auto binding controller (see the julia.cfg file)
-->
+ <content class="composite-auto-binding-controller-impl" />
<controller desc="mPrimitive" />
</definition>
Index:
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java
diff -u
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java:1.2
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java:removed
---
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java:1.2
Sat Dec 16 20:29:46 2006
+++
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeAutoBindingControllerImpl.java
Tue Jan 23 17:36:27 2007
@@ -1,1005 +0,0 @@
-/*
- * Generated by SpoonMixinClassProcessor.
- *
- * Author: Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- */
-package org.objectweb.fractal.juliak.control.binding;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.objectweb.fractal.api.Component;
-import org.objectweb.fractal.api.Interface;
-import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.BindingController;
-import org.objectweb.fractal.api.control.ContentController;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
-import org.objectweb.fractal.api.control.LifeCycleController;
-import org.objectweb.fractal.api.control.SuperController;
-import org.objectweb.fractal.api.factory.InstantiationException;
-import org.objectweb.fractal.api.type.ComponentType;
-import org.objectweb.fractal.api.type.InterfaceType;
-import org.objectweb.fractal.julia.ChainedNoSuchInterfaceException;
-import org.objectweb.fractal.julia.ComponentInterface;
-import org.objectweb.fractal.julia.Controller;
-import org.objectweb.fractal.julia.InitializationContext;
-import org.objectweb.fractal.julia.Interceptor;
-import
org.objectweb.fractal.julia.control.binding.ChainedIllegalBindingException;
-import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
-import
org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
-
-/**
- * Default implementation of the {@link BindingController} control interface
- * for composite components with auto-bindings.
- *
- * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- *
- * @see org.objectweb.fractal.julia.BasicControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin
- * @see org.objectweb.fractal.julia.UseComponentMixin
- * @see org.objectweb.fractal.julia.control.binding.CheckBindingMixin
- * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin
- * @see org.objectweb.fractal.julia.control.content.UseSuperControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.ContentBindingMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin
- * @see org.objectweb.fractal.julia.control.content.UseContentControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin
- * @see org.objectweb.fractal.julia.control.binding.AutoBindingMixin
- */
-public class CompositeAutoBindingControllerImpl implements BindingController
, Controller {
- /**
- * Initializes the {@link #_this_fcBindings} map, and then calls the
overriden
- * method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$3(final InitializationContext ic) throws
InstantiationException {
- ComponentType compType = ((ComponentType)(ic.type));
- InterfaceType[] itfTypes = compType.getFcInterfaceTypes();
- boolean isComposite =
(ic.getOptionalInterface("content-controller")) != null;
- for (int j = 0 ; j < (itfTypes.length) ; j++) {
- InterfaceType itfType = itfTypes[j];
- if ((((!(itfType.isFcCollectionItf())) &&
(!(itfType.getFcItfName().equals("component")))) &&
(!(itfType.getFcItfName().endsWith("-controller")))) &&
((itfType.isFcClientItf()) || isComposite)) {
- if ((fcBindings) == null) {
- fcBindings = new HashMap();
- }
- fcBindings.put(itfType.getFcItfName() ,fcBindings);
- }
- }
- initFcController$4(ic);
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableC
- */
- public Component weaveableC;
-
- /**
- * Does nothing.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.BasicControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$4(final InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * The {@link SuperController} interface of the component to which this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#weaveableSC
- */
- public SuperController weaveableSC;
-
- /**
- * The {@link ContentController} interface of the component to which this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.UseContentControllerMixin#weaveableCC
- */
- public ContentController weaveableCC;
-
- /**
- * The {@link LifeCycleController} interface of the component to which
this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#weaveableOptLC
- */
- public LifeCycleController weaveableOptLC;
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
- */
- public Component weaveableOptC;
-
- /**
- * The bindings of the component to which this controller object belongs.
- * This map associates to each client interface name the server
interface to
- * which it is bound. If a client interface is not bound, its name is not
- * associated to <tt>null</tt>, but to the {@link #fcBindings} map
itself.
- * This way the {@link #listFc listFc} method returns the names of all
the
- * client interfaces of the component, and not only the names of the
- * interfaces that are bound.
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#fcBindings
- */
- public Map fcBindings;
-
- /**
- * Checks that the given interface is unbound, and then calls the
overriden
- * method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.CheckBindingMixin#bindFc(java.lang.String,java.lang.Object)
- */
- private void bindFc$0(final String clientItfName, final Object
serverItf) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- if ((lookupFc(clientItfName)) != null) {
- throw new ChainedIllegalBindingException(null , weaveableOptC ,
null , clientItfName , null , "Already bound");
- }
- bindFc$1(clientItfName ,serverItf);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#listFc()
- */
- public String[] listFc() {
- if ((fcBindings) == null) {
- return new String[0];
- }
- return ((String[])(fcBindings.keySet().toArray(new
String[fcBindings.size()])));
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$1(final InitializationContext ic) throws
InstantiationException {
- weaveableSC =
((SuperController)(ic.getInterface("super-controller")));
- initFcController$2(ic);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$0(final InitializationContext ic) throws
InstantiationException {
- weaveableOptLC =
((LifeCycleController)(ic.getOptionalInterface("lifecycle-controller")));
- initFcController$1(ic);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.content.UseContentControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- public void initFcController(final InitializationContext ic) throws
InstantiationException {
- weaveableCC =
((ContentController)(ic.getInterface("content-controller")));
- initFcController$0(ic);
- }
-
- /**
- * Checks that the component is stopped and then calls the overriden
method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * LifeCycleController} interface, but it is not in an appropriate
state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin#unbindFc(java.lang.String)
- */
- public void unbindFc(final String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- if ((weaveableOptLC) != null) {
- String state = weaveableOptLC.getFcState();
- if (!(LifeCycleController.STOPPED.equals(state))) {
- throw new ChainedIllegalLifeCycleException(null ,
weaveableOptC , "The component is not stopped");
- }
- }
- unbindFc$0(clientItfName);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.UseComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$2(final InitializationContext ic) throws
InstantiationException {
- weaveableC = ((Component)(ic.getInterface("component")));
- weaveableOptC = weaveableC;
- initFcController$3(ic);
- }
-
- /**
- * Calls the overriden method, and then creates a corresponding internal
- * binding, if necessary. This internal binding is created only if the
- * interface is an external client collection interface "aXXX", and if
there
- * is a "model binding" to the internal server collection interface "a".
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.AutoBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- public void bindFc(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- bindFc$0(clientItfType ,clientItfName ,serverItf);
- if (clientItfType.isFcCollectionItf()) {
- String sItfName = clientItfType.getFcItfName();
- ContentController cc;
- try {
- cc =
((ContentController)(weaveableC.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- cc = null;
- }
- if ((cc != null) && (!(clientItfName.equals(sItfName)))) {
- Object sItf = cc.getFcInternalInterface(sItfName);
- Object itf = cc.getFcInternalInterface(clientItfName);
- try {
- Object[] itfs =
org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(((Interface)(sItf))).toArray();
- for (int i = 0 ; i < (itfs.length) ; ++i) {
- Interface cItf = ((Interface)(itfs[i]));
- InterfaceType cItfType =
((InterfaceType)(cItf.getFcItfType()));
- if (cItfType.isFcCollectionItf()) {
- Component c = cItf.getFcItfOwner();
- BindingController bc =
((BindingController)(c.getFcInterface("binding-controller")));
- String s = (cItfType.getFcItfName()) +
(clientItfName.substring(sItfName.length()));
- bc.bindFc(s ,itf);
- }
- }
- } catch (Exception e) {
- throw new ChainedIllegalBindingException(e , weaveableC
, null , clientItfName , null , "Error during automatic creation of bindings
from the model binding");
- }
- }
- if (clientItfName.equals(sItfName)) {
- Interface sItf = ((Interface)(serverItf));
- InterfaceType sItfType =
((InterfaceType)(sItf.getFcItfType()));
- if (((sItf.isFcInternalItf()) &&
(sItfType.isFcCollectionItf())) &&
(sItf.getFcItfName().equals(sItfType.getFcItfName()))) {
- Component sComp = sItf.getFcItfOwner();
- try {
- BindingController bc =
((BindingController)(sComp.getFcInterface("binding-controller")));
- cc =
((ContentController)(sComp.getFcInterface("content-controller")));
- String s = sItf.getFcItfName();
- String[] itfs = bc.listFc();
- for (int i = 0 ; i < (itfs.length) ; ++i) {
- if (((itfs[i].length()) > (s.length())) &&
(itfs[i].startsWith(s))) {
- bindFc((clientItfName +
(itfs[i].substring(s.length()))) ,cc.getFcInternalInterface(itfs[i]));
- }
- }
- } catch (Exception e) {
- throw new ChainedIllegalBindingException(e ,
weaveableC , null , clientItfName , null , "Error during automatic creation
of bindings from the model binding");
- }
- }
- }
- }
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#lookupFc(java.lang.String)
- */
- private Object lookupFc$0(final String clientItfName) throws
NoSuchInterfaceException {
- if ((fcBindings) == null) {
- return null;
- }
- Object serverItf = fcBindings.get(clientItfName);
- return serverItf == (fcBindings) ? null : serverItf;
- }
-
- /**
- * Checks the interface name with the component's type and then calls the
- * {@link #lookupFc(InterfaceType,String) lookupFc} method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @return the server interface to which the given interface is bound,
or <tt>
- * null</tt> if it is not bound.
- * @throws NoSuchInterfaceException if the component to which this
interface
- * belongs does not have a client interface whose name is equal to
the
- * given name.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#lookupFc(java.lang.String)
- */
- public Object lookupFc(final String clientItfName) throws
NoSuchInterfaceException {
- ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
- InterfaceType clientItfType;
- try {
- clientItfType = compType.getFcInterfaceType(clientItfName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
clientItfName);
- }
- checkFcClientInterface(clientItfType);
- return lookupFc(clientItfType ,clientItfName);
- }
-
- /**
- * Calls the {@link #checkFcLocalBinding checkFcLocalBinding} method and
then
- * calls the overriden method.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.ContentBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- private void bindFc$1(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- checkFcLocalBinding(clientItfType ,clientItfName ,serverItf);
- bindFc$2(clientItfType ,clientItfName ,serverItf);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#bindFc(java.lang.String,java.lang.Object)
- */
- private void bindFc$1(final String clientItfName, final Object
serverItf) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- if ((fcBindings) == null) {
- fcBindings = new HashMap();
- }
- fcBindings.put(clientItfName ,serverItf);
- }
-
- /**
- * Sets the shortcuts for the given binding and then calls the overriden
- * method.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- private void bindFc$0(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- bindFc$1(clientItfType ,clientItfName ,serverItf);
- setFcShortcuts(clientItfType ,clientItfName ,serverItf);
- }
-
- /**
- * The {@link Controller#initFcController initFcController} method
overriden
- * by this mixin.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- */
- private void initFcController$5(InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#unbindFc(java.lang.String)
- */
- private void unbindFc$2(final String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- if ((fcBindings) != null) {
- fcBindings.put(clientItfName ,fcBindings);
- }
- }
-
- /**
- * Checks that the given interface is bound, and then calls the overriden
- * method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.CheckBindingMixin#unbindFc(java.lang.String)
- */
- private void unbindFc$1(final String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- if ((lookupFc(clientItfName)) == null) {
- throw new ChainedIllegalBindingException(null , weaveableOptC ,
null , clientItfName , null , "Not bound");
- }
- unbindFc$2(clientItfName);
- }
-
- /**
- * Checks that the given binding is a local binding.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface.
- * @param serverItf a server interface.
- * @throws IllegalBindingException if the given binding is not a local
- * binding.
- * @see
org.objectweb.fractal.julia.control.binding.ContentBindingMixin#checkFcLocalBinding(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- public void checkFcLocalBinding(final InterfaceType clientItfType, final
String clientItfName, final Object serverItf) throws IllegalBindingException {
- Interface sItf;
- Component sComp;
- try {
- sItf = ((Interface)(serverItf));
- sComp = sItf.getFcItfOwner();
- } catch (ClassCastException e) {
- return ;
- }
- Component[] cParents = weaveableSC.getFcSuperComponents();
- String msg;
- if (!(clientItfType.isFcClientItf())) {
- ContentController cc;
- try {
- cc =
((ContentController)(weaveableC.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- return ;
- }
- Component[] cSubComps = cc.getFcSubComponents();
- for (int i = 0 ; i < (cSubComps.length) ; ++i) {
- if (cSubComps[i].equals(sComp)) {
- return ;
- }
- }
- Component thisComp;
- try {
- thisComp =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalBindingException(e , weaveableC ,
sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "Cannot get the
Component interface of the client component");
- }
- if ((sComp.equals(thisComp)) && (sItf.isFcInternalItf())) {
- return ;
- }
- msg = "Invalid export binding";
- } else if (sItf.isFcInternalItf()) {
- for (int i = 0 ; i < (cParents.length) ; ++i) {
- if (sComp.equals(cParents[i])) {
- return ;
- }
- }
- msg = "Invalid import binding";
- } else {
- SuperController sCompSC;
- try {
- sCompSC =
((SuperController)(sComp.getFcInterface("super-controller")));
- } catch (NoSuchInterfaceException e) {
- return ;
- }
- Component[] sParents = sCompSC.getFcSuperComponents();
- for (int i = 0 ; i < (cParents.length) ; ++i) {
- for (int j = 0 ; j < (sParents.length) ; ++j) {
- if (cParents[i].equals(sParents[j])) {
- return ;
- }
- }
- }
- msg = "Not a local binding";
- }
- throw new ChainedIllegalBindingException(null , weaveableC ,
sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , msg);
- }
-
- /**
- * Checks the interface name with the component's type and then calls the
- * {@link #bindFc(InterfaceType,String,Object) bindFc} method. If the
server
- * interface implements {@link Interface}, and if its type is an
instance of
- * {@link InterfaceType}, this method also checks the compatibility
between
- * the client and server interface types.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#bindFc(java.lang.String,java.lang.Object)
- */
- public void bindFc(final String clientItfName, final Object serverItf)
throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
- InterfaceType cItfType;
- try {
- cItfType = compType.getFcInterfaceType(clientItfName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
clientItfName);
- }
- checkFcClientInterface(cItfType);
- ContentController cc;
- try {
- cc =
((ContentController)(weaveableC.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- cc = null;
- }
- if (cItfType.isFcClientItf()) {
- weaveableC.getFcInterface(clientItfName);
- } else {
- cc.getFcInternalInterface(clientItfName);
- }
- Interface sItf;
- InterfaceType sItfType;
- try {
- sItf = ((Interface)(serverItf));
- sItfType = ((InterfaceType)(sItf.getFcItfType()));
- } catch (ClassCastException e) {
- bindFc(cItfType ,clientItfName ,serverItf);
- return ;
- }
- if (sItfType.isFcClientItf()) {
- throw new ChainedIllegalBindingException(null , weaveableC ,
sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "Cannot bind two
client interfaces together");
- }
- try {
- Class s = Class.forName(sItfType.getFcItfSignature());
- Class c = Class.forName(cItfType.getFcItfSignature());
- if (!(c.isAssignableFrom(s))) {
- throw new ChainedIllegalBindingException(null , weaveableC ,
sItf.getFcItfOwner() , clientItfName , sItf.getFcItfName() , "The server
interface type is not a subtype " + "of the client interface type");
- }
- } catch (ClassNotFoundException ignored) {
- }
- if ((!(cItfType.isFcOptionalItf())) && (sItfType.isFcOptionalItf()))
{
- throw new ChainedIllegalBindingException(null , weaveableC ,
((Interface)(serverItf)).getFcItfOwner() , clientItfName ,
((Interface)(serverItf)).getFcItfName() , "A mandatory interface cannot be
bound to an optional interface");
- }
- bindFc(cItfType ,clientItfName ,sItf);
- }
-
- /**
- * Updates the shortcuts for the given binding and then calls the
overriden
- * method.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin#unbindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
- */
- private void unbindFc$0(final InterfaceType clientItfType, final String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- unbindFc$1(clientItfType ,clientItfName);
- setFcShortcuts(clientItfType ,clientItfName ,null);
- }
-
- /**
- * The {@link BindingController#unbindFc unbindFc} method overriden by
this
- * mixin.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * LifeCycleController} interface, but it is not in an appropriate
state
- * to perform this operation.
- */
- private void unbindFc$3(String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- }
-
- /**
- * Creates the given binding and updates the shortcuts links accordingly.
- *
- * @param clientItfType the type of the 'clientItfName' interface.
- * @param clientItfName a client interface name.
- * @param serverItf the server interface to which the client interface
must
- * be bound, or <tt>null</tt> if it must be unbound.
- * @throws NoSuchInterfaceException if there is no client interface
whose name
- * is equal to 'clientItfName'.
- * @throws IllegalBindingException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin#setFcShortcuts(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- public void setFcShortcuts(final InterfaceType clientItfType, final
String clientItfName, final Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException {
- Interface clientItf;
- if (clientItfType.isFcClientItf()) {
- clientItf =
((Interface)(weaveableC.getFcInterface(clientItfName)));
- } else {
- clientItf =
((Interface)(weaveableCC.getFcInternalInterface(clientItfName)));
- }
- Set visited = new HashSet();
- List shortcutItfs = new ArrayList();
- List shortcutImpls = new ArrayList();
- Object itf = serverItf;
- while (true) {
- ComponentInterface citf;
- if (itf instanceof ComponentInterface) {
- citf = ((ComponentInterface)(itf));
- } else {
- break;
- }
- if ((citf.getFcItfImpl()) instanceof Interceptor) {
- break;
- }
- try {
- Component owner = citf.getFcItfOwner();
- owner.getFcInterface("content-controller");
- BindingController bc =
((BindingController)(owner.getFcInterface("binding-controller")));
- itf = bc.lookupFc(citf.getFcItfName());
- } catch (NoSuchInterfaceException e) {
- break;
- }
- }
- Object impl;
- if (itf == null) {
- impl = null;
- } else {
- if (itf instanceof ComponentInterface) {
- impl = ((ComponentInterface)(itf)).getFcItfImpl();
- } else {
- impl = itf;
- }
- }
- try {
- setFcClientShortcuts(clientItf ,impl ,visited ,shortcutItfs
,shortcutImpls);
- } catch (Exception e) {
- Interface sItf;
- sItf = serverItf instanceof Interface ? ((Interface)(serverItf))
: null;
- throw new ChainedIllegalBindingException(e ,
clientItf.getFcItfOwner() , sItf == null ? null : sItf.getFcItfOwner() ,
clientItf.getFcItfName() , sItf == null ? null : sItf.getFcItfName() ,
"Cannot create shortcut links");
- }
- for (int i = 0 ; i < (shortcutItfs.size()) ; ++i) {
- Interface shortcutItf = ((Interface)(shortcutItfs.get(i)));
- Object shortcutImpl = shortcutImpls.get(i);
- Component c = shortcutItf.getFcItfOwner();
- ContentController cc;
- try {
- cc =
((ContentController)(c.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- cc = null;
- }
- if (cc != null) {
- ComponentInterface cShortcutItf =
((ComponentInterface)(shortcutItf));
- if (cShortcutItf.hasFcInterceptor()) {
- Object newImpl = cShortcutItf.getFcItfImpl();
- ((Interceptor)(newImpl)).setFcItfDelegate(shortcutImpl);
- } else {
- cShortcutItf.setFcItfImpl(shortcutImpl);
- }
- } else {
- BindingController bc;
- try {
- bc =
((BindingController)(c.getFcInterface("binding-controller")));
- } catch (NoSuchInterfaceException e) {
- continue;
- }
- try {
- String itfName = shortcutItf.getFcItfName();
- Object o = bc.lookupFc(itfName);
- if (o != null) {
- bc.unbindFc(itfName);
- bc.bindFc(itfName ,o);
- }
- } catch (Exception e) {
- Interface sItf;
- sItf = serverItf instanceof Interface ?
((Interface)(serverItf)) : null;
- throw new ChainedIllegalBindingException(e ,
clientItf.getFcItfOwner() , sItf == null ? null : sItf.getFcItfOwner() ,
clientItf.getFcItfName() , sItf == null ? null : sItf.getFcItfName() ,
"Cannot create shortcut links");
- }
- }
- }
- }
-
- /**
- * Calls the overriden method, and then removes the corresponding
internal
- * bindings, if necessary. This internal binding is removed only if the
- * interface is an external client collection interface "aXXX", and if
there
- * is a "model binding" to the internal server collection interface "a".
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.AutoBindingMixin#unbindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
- */
- public void unbindFc(final InterfaceType clientItfType, final String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- unbindFc$0(clientItfType ,clientItfName);
- if (clientItfType.isFcCollectionItf()) {
- ContentController cc;
- try {
- cc =
((ContentController)(weaveableC.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- return ;
- }
- String sItfName = clientItfType.getFcItfName();
- Object sItf = cc.getFcInternalInterface(sItfName);
- try {
- Object[] itfs =
org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(((Interface)(sItf))).toArray();
- for (int i = 0 ; i < (itfs.length) ; ++i) {
- Interface cItf = ((Interface)(itfs[i]));
- InterfaceType cItfType =
((InterfaceType)(cItf.getFcItfType()));
- if (cItfType.isFcCollectionItf()) {
- Component c = cItf.getFcItfOwner();
- BindingController bc =
((BindingController)(c.getFcInterface("binding-controller")));
- String s = (cItfType.getFcItfName()) +
(clientItfName.substring(sItfName.length()));
- bc.unbindFc(s);
- }
- }
- } catch (Exception e) {
- throw new ChainedIllegalBindingException(e , weaveableC ,
null , clientItfName , null , "Error during automatic destruction of bindings
from the model binding");
- }
- }
- }
-
- /**
- * Checks the interface name with the component's type and then calls the
- * {@link #unbindFc(InterfaceType,String) unbindFc} method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#unbindFc(java.lang.String)
- */
- private void unbindFc$0(final String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
- InterfaceType clientItfType;
- try {
- clientItfType = compType.getFcInterfaceType(clientItfName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
clientItfName);
- }
- checkFcClientInterface(clientItfType);
- unbindFc(clientItfType ,clientItfName);
- }
-
- /**
- * Returns the interface to which the given client interface is bound.
More
- * precisely, returns the server interface to which the client interface
whose
- * name is given is bound.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @return the server interface to which the given interface is bound,
or <tt>
- * null</tt> if it is not bound.
- * @throws NoSuchInterfaceException if the component to which this
interface
- * belongs does not have a client interface whose name is equal to
the
- * given name.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#lookupFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
- */
- public Object lookupFc(final InterfaceType clientItfType, final String
clientItfName) throws NoSuchInterfaceException {
- return lookupFc$0(clientItfName);
- }
-
- /**
- * The {@link TypeBindingMixin#bindFc(InterfaceType,String,Object)
bindFc}
- * method overriden by this mixin.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- */
- private void bindFc$3(InterfaceType clientItfType, String clientItfName,
Object serverItf) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- }
-
- /**
- * Binds the client interface whose name is given to a server interface.
More
- * precisely, binds the client interface of the component to which this
- * interface belongs, and whose name is equal to the given name, to the
given
- * server interface.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- private void bindFc$2(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- bindFc$0(clientItfName ,serverItf);
- }
-
- /**
- * The {@link TypeBindingMixin#unbindFc(InterfaceType,String) unbindFc}
- * method overriden by this mixin.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- */
- private void unbindFc$2(InterfaceType clientItfType, String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- }
-
- /**
- * Finds the shortcut links to be updated by following the bindings
backwards
- * from the given client interface.
- *
- * @param clientItf the client interface from which the bindings must be
- * followed backward.
- * @param impl the object to be used to update the shortcut links with
{@link
- * ComponentInterface#getFcItfImpl getFcItfImpl}.
- * @param visited the already visited interfaces.
- * @param shortcutItfs the interfaces whose shortcut links must be
updated.
- * @param shortcutImpls the values to be used to update the shortcut
links.
- * @throws Exception if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin#setFcClientShortcuts(org.objectweb.fractal.api.Interface,java.lang.Object,java.util.Set,java.util.List,java.util.List)
- */
- public void setFcClientShortcuts(final Interface clientItf, final Object
impl, final Set visited, final List shortcutItfs, final List shortcutImpls)
throws Exception {
- Component clientComp = clientItf.getFcItfOwner();
- ContentController cc;
- try {
- cc =
((ContentController)(clientComp.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- cc = null;
- }
- if (cc != null) {
- ComponentInterface itf;
- try {
- String name = clientItf.getFcItfName();
- if (clientItf.isFcInternalItf()) {
- itf =
((ComponentInterface)(clientComp.getFcInterface(name)));
- } else {
- itf =
((ComponentInterface)(cc.getFcInternalInterface(name)));
- }
- } catch (NoSuchInterfaceException e) {
- throw new Exception("Cannot create shortcut links");
- } catch (ClassCastException e) {
- throw new Exception("Cannot create shortcut links");
- }
- if (!(visited.contains(itf))) {
- visited.add(itf);
- shortcutItfs.add(itf);
- shortcutImpls.add(impl);
- if (itf.hasFcInterceptor()) {
- Object newImpl = itf.getFcItfImpl();
- setFcServerShortcuts(itf ,newImpl ,visited ,shortcutItfs
,shortcutImpls);
- } else {
- setFcServerShortcuts(itf ,impl ,visited ,shortcutItfs
,shortcutImpls);
- }
- }
- } else if (!(visited.contains(clientItf))) {
- visited.add(clientItf);
- shortcutItfs.add(clientItf);
- shortcutImpls.add(impl);
- }
- }
-
- /**
- * Unbinds the given client interface. More precisely, unbinds the client
- * interface of the component to which this interface belongs, and whose
name
- * is equal to the given name.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#unbindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String)
- */
- private void unbindFc$1(final InterfaceType clientItfType, final String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- unbindFc$1(clientItfName);
- }
-
- /**
- * Checks that the given type corresponds to an external or internal
client
- * interface.
- *
- * @param itfType an interface type.
- * @throws NoSuchInterfaceException if the given type does not
correspdond to
- * an external or internal client interface.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#checkFcClientInterface(org.objectweb.fractal.api.type.InterfaceType)
- */
- private void checkFcClientInterface(InterfaceType itfType) throws
NoSuchInterfaceException {
- try {
- weaveableC.getFcInterface("content-controller");
- String name = itfType.getFcItfName();
- if ((!(name.equals("component"))) &&
(!(name.endsWith("-controller")))) {
- return ;
- }
- } catch (NoSuchInterfaceException e) {
- if (itfType.isFcClientItf()) {
- return ;
- }
- }
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
itfType.getFcItfName());
- }
-
- /**
- * Finds the shortcut links to be updated by followng the bindings
backwards
- * from the given server interface.
- *
- * @param serverItf the server interface from which the bindings must be
- * followed backward.
- * @param impl the object to be used to update the shortcut links with
{@link
- * ComponentInterface#getFcItfImpl getFcItfImpl}.
- * @param visited the already visited interfaces.
- * @param shortcutItfs the interfaces whose shortcut links must be
updated.
- * @param shortcutImpls the values to be used to update the shortcut
links.
- * @throws Exception if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin#setFcServerShortcuts(org.objectweb.fractal.api.Interface,java.lang.Object,java.util.Set,java.util.List,java.util.List)
- */
- public void setFcServerShortcuts(final Interface serverItf, final Object
impl, final Set visited, final List shortcutItfs, final List shortcutImpls)
throws Exception {
- Object[] comps =
org.objectweb.fractal.julia.control.binding.Util.getFcPotentialClientsOf(serverItf).toArray();
- for (int i = 0 ; i < (comps.length) ; ++i) {
- Component comp = ((Component)(comps[i]));
- List clientItfs =
org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(comp
,serverItf);
- for (int j = 0 ; j < (clientItfs.size()) ; ++j) {
- setFcClientShortcuts(((Interface)(clientItfs.get(j))) ,impl
,visited ,shortcutItfs ,shortcutImpls);
- }
- }
- }
-
- /**
- * The {@link BindingController#lookupFc lookupFc} method overriden by
this
- * mixin.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @return the server interface to which the given interface is bound,
or <tt>
- * null</tt> if it is not bound.
- * @throws NoSuchInterfaceException if the component to which this
interface
- * belongs does not have a client interface whose name is equal to
the
- * given name.
- */
- private Object lookupFc$1(String clientItfName) throws
NoSuchInterfaceException {
- return null;
- }
-
- /**
- * The {@link BindingController#bindFc bindFc} method overriden by this
- * mixin.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- */
- private void bindFc$2(String clientItfName, Object serverItf) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- }
-
-}
\ No newline at end of file
Index:
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal
diff -u
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal:1.3
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal:1.4
---
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal:1.3
Sat Dec 16 20:43:32 2006
+++
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingController.fractal
Tue Jan 23 17:36:26 2007
@@ -28,7 +28,9 @@
name="org.objectweb.fractal.juliak.control.binding.CompositeBindingController"
extends="org.objectweb.fractal.juliak.control.binding.BindingControllerType,org.objectweb.fractal.juliak.control.component.UseComponentControllerType,org.objectweb.fractal.juliak.control.content.UseSuperControllerType,org.objectweb.fractal.juliak.control.lifecycle.UseLifeCycleControllerType,org.objectweb.fractal.juliak.control.content.UseContentControllerType"
>
- <content
class="org.objectweb.fractal.juliak.control.binding.CompositeBindingControllerImpl"
/>
+ <!-- composite-binding-controller-impl identifies the implementation
of -->
+ <!-- the composite binding controller (see the julia.cfg file)
-->
+ <content class="composite-binding-controller-impl" />
<controller desc="mPrimitive" />
</definition>
Index:
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java
diff -u
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java:1.2
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java:removed
---
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java:1.2
Sat Dec 16 20:29:46 2006
+++
julia/src/org/objectweb/fractal/juliak/control/binding/CompositeBindingControllerImpl.java
Tue Jan 23 17:36:27 2007
@@ -1,891 +0,0 @@
-/*
- * Generated by SpoonMixinClassProcessor.
- *
- * Author: Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- */
-package org.objectweb.fractal.juliak.control.binding;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.objectweb.fractal.api.Component;
-import org.objectweb.fractal.api.Interface;
-import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.control.BindingController;
-import org.objectweb.fractal.api.control.ContentController;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
-import org.objectweb.fractal.api.control.LifeCycleController;
-import org.objectweb.fractal.api.control.SuperController;
-import org.objectweb.fractal.api.factory.InstantiationException;
-import org.objectweb.fractal.api.type.ComponentType;
-import org.objectweb.fractal.api.type.InterfaceType;
-import org.objectweb.fractal.julia.ChainedNoSuchInterfaceException;
-import org.objectweb.fractal.julia.ComponentInterface;
-import org.objectweb.fractal.julia.Controller;
-import org.objectweb.fractal.julia.InitializationContext;
-import org.objectweb.fractal.julia.Interceptor;
-import
org.objectweb.fractal.julia.control.binding.ChainedIllegalBindingException;
-import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
-import
org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
-
-/**
- * Default implementation of the {@link BindingController} control interface
- * for composite components.
- *
- * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- *
- * @see org.objectweb.fractal.julia.BasicControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin
- * @see org.objectweb.fractal.julia.UseComponentMixin
- * @see org.objectweb.fractal.julia.control.binding.CheckBindingMixin
- * @see org.objectweb.fractal.julia.control.binding.TypeBindingMixin
- * @see org.objectweb.fractal.julia.control.content.UseSuperControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.ContentBindingMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin
- * @see org.objectweb.fractal.julia.control.content.UseContentControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.OptimizedCompositeBindingMixin
- */
-public class CompositeBindingControllerImpl implements BindingController ,
Controller {
- /**
- * Initializes the {@link #_this_fcBindings} map, and then calls the
overriden
- * method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$3(final InitializationContext ic) throws
InstantiationException {
- ComponentType compType = ((ComponentType)(ic.type));
- InterfaceType[] itfTypes = compType.getFcInterfaceTypes();
- boolean isComposite =
(ic.getOptionalInterface("content-controller")) != null;
- for (int j = 0 ; j < (itfTypes.length) ; j++) {
- InterfaceType itfType = itfTypes[j];
- if ((((!(itfType.isFcCollectionItf())) &&
(!(itfType.getFcItfName().equals("component")))) &&
(!(itfType.getFcItfName().endsWith("-controller")))) &&
((itfType.isFcClientItf()) || isComposite)) {
- if ((fcBindings) == null) {
- fcBindings = new HashMap();
- }
- fcBindings.put(itfType.getFcItfName() ,fcBindings);
- }
- }
- initFcController$4(ic);
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableC
- */
- public Component weaveableC;
-
- /**
- * Does nothing.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.BasicControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$4(final InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * The {@link SuperController} interface of the component to which this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#weaveableSC
- */
- public SuperController weaveableSC;
-
- /**
- * The {@link ContentController} interface of the component to which this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.UseContentControllerMixin#weaveableCC
- */
- public ContentController weaveableCC;
-
- /**
- * The {@link LifeCycleController} interface of the component to which
this
- * controller object belongs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#weaveableOptLC
- */
- public LifeCycleController weaveableOptLC;
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
- */
- public Component weaveableOptC;
-
- /**
- * The bindings of the component to which this controller object belongs.
- * This map associates to each client interface name the server
interface to
- * which it is bound. If a client interface is not bound, its name is not
- * associated to <tt>null</tt>, but to the {@link #fcBindings} map
itself.
- * This way the {@link #listFc listFc} method returns the names of all
the
- * client interfaces of the component, and not only the names of the
- * interfaces that are bound.
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#fcBindings
- */
- public Map fcBindings;
-
- /**
- * Checks that the given interface is unbound, and then calls the
overriden
- * method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but it is not in an appropriate state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.CheckBindingMixin#bindFc(java.lang.String,java.lang.Object)
- */
- private void bindFc$0(final String clientItfName, final Object
serverItf) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- if ((lookupFc(clientItfName)) != null) {
- throw new ChainedIllegalBindingException(null , weaveableOptC ,
null , clientItfName , null , "Already bound");
- }
- bindFc$1(clientItfName ,serverItf);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#listFc()
- */
- public String[] listFc() {
- if ((fcBindings) == null) {
- return new String[0];
- }
- return ((String[])(fcBindings.keySet().toArray(new
String[fcBindings.size()])));
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.content.UseSuperControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$1(final InitializationContext ic) throws
InstantiationException {
- weaveableSC =
((SuperController)(ic.getInterface("super-controller")));
- initFcController$2(ic);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.lifecycle.UseLifeCycleControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$0(final InitializationContext ic) throws
InstantiationException {
- weaveableOptLC =
((LifeCycleController)(ic.getOptionalInterface("lifecycle-controller")));
- initFcController$1(ic);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.control.content.UseContentControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- public void initFcController(final InitializationContext ic) throws
InstantiationException {
- weaveableCC =
((ContentController)(ic.getInterface("content-controller")));
- initFcController$0(ic);
- }
-
- /**
- * Checks that the component is stopped and then calls the overriden
method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be removed.
- * @throws IllegalLifeCycleException if this component has a {@link
- * LifeCycleController} interface, but it is not in an appropriate
state
- * to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.LifeCycleBindingMixin#unbindFc(java.lang.String)
- */
- public void unbindFc(final String clientItfName) throws
NoSuchInterfaceException, IllegalBindingException, IllegalLifeCycleException {
- if ((weaveableOptLC) != null) {
- String state = weaveableOptLC.getFcState();
- if (!(LifeCycleController.STOPPED.equals(state))) {
- throw new ChainedIllegalLifeCycleException(null ,
weaveableOptC , "The component is not stopped");
- }
- }
- unbindFc$0(clientItfName);
- }
-
- /**
- * Initializes the fields of this mixin and then calls the overriden
method.
- *
- * @param ic information about the component to which this controller
object
- * belongs.
- * @throws InstantiationException if the initialization fails.
- * @see
org.objectweb.fractal.julia.UseComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$2(final InitializationContext ic) throws
InstantiationException {
- weaveableC = ((Component)(ic.getInterface("component")));
- weaveableOptC = weaveableC;
- initFcController$3(ic);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#lookupFc(java.lang.String)
- */
- private Object lookupFc$0(final String clientItfName) throws
NoSuchInterfaceException {
- if ((fcBindings) == null) {
- return null;
- }
- Object serverItf = fcBindings.get(clientItfName);
- return serverItf == (fcBindings) ? null : serverItf;
- }
-
- /**
- * Checks the interface name with the component's type and then calls the
- * {@link #lookupFc(InterfaceType,String) lookupFc} method.
- *
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @return the server interface to which the given interface is bound,
or <tt>
- * null</tt> if it is not bound.
- * @throws NoSuchInterfaceException if the component to which this
interface
- * belongs does not have a client interface whose name is equal to
the
- * given name.
- * @see
org.objectweb.fractal.julia.control.binding.TypeBindingMixin#lookupFc(java.lang.String)
- */
- public Object lookupFc(final String clientItfName) throws
NoSuchInterfaceException {
- ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
- InterfaceType clientItfType;
- try {
- clientItfType = compType.getFcInterfaceType(clientItfName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
clientItfName);
- }
- checkFcClientInterface(clientItfType);
- return lookupFc(clientItfType ,clientItfName);
- }
-
- /**
- * Calls the {@link #checkFcLocalBinding checkFcLocalBinding} method and
then
- * calls the overriden method.
- *
- * @param clientItfType the type of the <tt>clientItfName</tt> interface.
- * @param clientItfName the name of a client interface of the component
to
- * which this interface belongs.
- * @param serverItf a server interface.
- * @throws NoSuchInterfaceException if there is no such client interface.
- * @throws IllegalBindingException if the binding cannot be created.
- * @throws IllegalLifeCycleException if this component has a {@link
- * org.objectweb.fractal.api.control.LifeCycleController}
interface, but
- * it is not in an appropriate state to perform this operation.
- * @see
org.objectweb.fractal.julia.control.binding.ContentBindingMixin#bindFc(org.objectweb.fractal.api.type.InterfaceType,java.lang.String,java.lang.Object)
- */
- private void bindFc$0(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- checkFcLocalBinding(clientItfType ,clientItfName ,serverItf);
- bindFc$1(clientItfType ,clientItfName ,serverItf);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin#bindFc(java.lang.String,java.lang.Object)
- */
- private void bindFc$1(final String clientItfName, final Object
serverItf) throws NoSuchInterfaceException, IllegalBindingException,
Illegal