Mail Archive Home | fractal-commits List | December 2006 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Monday, December 18, 2006 @ 21:48:43
Author: seintur
Path: /cvsroot/fractal/julia/src/org/objectweb/fractal/juliak
Modified: membrane/BasicMembranes.java
Removed: CompositeMembraneImpl.java PrimitiveMembraneImpl.java
membrane/MergedComposite.fractal
membrane/MergedPrimitive.fractal
Removing merged membranes.
----------------------------------+
CompositeMembraneImpl.java | 2033 -------------------------------------
PrimitiveMembraneImpl.java | 1606 -----------------------------
membrane/BasicMembranes.java | 10
membrane/MergedComposite.fractal | 35
membrane/MergedPrimitive.fractal | 42
5 files changed, 3726 deletions(-)
Index: julia/src/org/objectweb/fractal/juliak/CompositeMembraneImpl.java
diff -u julia/src/org/objectweb/fractal/juliak/CompositeMembraneImpl.java:1.2
julia/src/org/objectweb/fractal/juliak/CompositeMembraneImpl.java:removed
--- julia/src/org/objectweb/fractal/juliak/CompositeMembraneImpl.java:1.2
Sat Dec 16 20:29:46 2006
+++ julia/src/org/objectweb/fractal/juliak/CompositeMembraneImpl.java Mon
Dec 18 21:48:43 2006
@@ -1,2033 +0,0 @@
-/*
- * Generated by SpoonMixinClassProcessor.
- *
- * Author: Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- */
-package org.objectweb.fractal.juliak;
-
-import java.util.ArrayList;
-import org.objectweb.fractal.api.control.BindingController;
-import
org.objectweb.fractal.julia.control.binding.ChainedIllegalBindingException;
-import
org.objectweb.fractal.julia.control.content.ChainedIllegalContentException;
-import
org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
-import org.objectweb.fractal.julia.ChainedNoSuchInterfaceException;
-import org.objectweb.fractal.api.Component;
-import org.objectweb.fractal.julia.ComponentInterface;
-import org.objectweb.fractal.api.type.ComponentType;
-import org.objectweb.fractal.api.control.ContentController;
-import org.objectweb.fractal.julia.Controller;
-import java.util.HashMap;
-import java.util.HashSet;
-import org.objectweb.fractal.api.control.IllegalBindingException;
-import org.objectweb.fractal.api.control.IllegalContentException;
-import org.objectweb.fractal.api.control.IllegalLifeCycleException;
-import org.objectweb.fractal.julia.InitializationContext;
-import org.objectweb.fractal.api.factory.InstantiationException;
-import org.objectweb.fractal.julia.Interceptor;
-import org.objectweb.fractal.api.Interface;
-import org.objectweb.fractal.api.type.InterfaceType;
-import org.objectweb.fractal.api.control.LifeCycleController;
-import org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator;
-import java.util.List;
-import java.util.Map;
-import org.objectweb.fractal.api.control.NameController;
-import org.objectweb.fractal.api.NoSuchInterfaceException;
-import java.util.Set;
-import org.objectweb.fractal.api.control.SuperController;
-import org.objectweb.fractal.julia.control.content.SuperControllerNotifier;
-import org.objectweb.fractal.api.Type;
-
-/**
- * Default implementation of the control membrane for composite components.
- * This implementation merges the controllers associated with a composite
- * membrane.
- *
- * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- *
- * @see org.objectweb.fractal.julia.BasicControllerMixin
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin
- * @see org.objectweb.fractal.julia.control.content.CheckContentMixin
- * @see org.objectweb.fractal.julia.control.content.TypeContentMixin
- * @see org.objectweb.fractal.julia.control.content.BindingContentMixin
- * @see org.objectweb.fractal.julia.control.content.LifeCycleContentMixin
- * @see org.objectweb.fractal.julia.control.content.SuperContentMixin
- * @see org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.BasicBindingControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.TypeBasicBindingMixin
- * @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.UseComponentMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin
- * @see org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin
- * @see org.objectweb.fractal.julia.control.name.BasicNameControllerMixin
- * @see org.objectweb.fractal.julia.BasicComponentMixin
- * @see org.objectweb.fractal.julia.TypeComponentMixin
- */
-public class CompositeMembraneImpl implements Component , BindingController
, ContentController , LifeCycleController , NameController , Controller ,
SuperControllerNotifier , LifeCycleCoordinator {
- /**
- * 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$4(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$5(ic);
- }
-
- /**
- * The name of the component to which this controller object belongs.
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#name
- */
- public String name;
-
- /**
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#getFcName()
- */
- public String getFcName() {
- return name;
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableC
- */
- public Component weaveableC;
-
- /**
- * The parents of the component to which this controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#fcParents
- */
- public Component[] fcParents;
-
- /**
- * 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$6(final InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * The type of this component.
- * @see org.objectweb.fractal.julia.BasicComponentMixin#fcType
- */
- public Type fcType;
-
- /**
- * 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;
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#getFcSuperComponents()
- */
- public Component[] getFcSuperComponents() {
- if ((fcParents) == null) {
- return new Component[0];
- } else {
- return fcParents;
- }
- }
-
- /**
- * 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;
-
- /**
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#setFcName(java.lang.String)
- */
- public void setFcName(final String name) {
- this.name = name;
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
- */
- public Component weaveableOptC;
-
- /**
- * The components that are currently active.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcActive
- */
- public List fcActive;
-
- /**
- * The interfaces of this component. This map associates each interface
to its
- * name.
- * @see org.objectweb.fractal.julia.BasicComponentMixin#fcInterfaces
- */
- public Map fcInterfaces;
-
- /**
- * 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;
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#addedToFc(org.objectweb.fractal.api.Component)
- */
- public void addedToFc(final Component parent) {
- int length = (fcParents) == null ? 1 : (fcParents.length) + 1;
- Component[] parents = new Component[length];
- if ((fcParents) != null) {
- java.lang.System.arraycopy(fcParents ,0 ,parents ,1
,fcParents.length);
- }
- parents[0] = parent;
- fcParents = parents;
- }
-
- /**
- * 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);
- }
-
- /**
- * Checks that the component is stopped and then calls the overriden
method.
- *
- * @param subComponent the component to be removed from this component.
- * @throws IllegalContentException if the given component cannot be
removed
- * from this component.
- * @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.content.LifeCycleContentMixin#removeFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void removeFcSubComponent$0(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- if ((weaveableOptLC) != null) {
- String state = weaveableOptLC.getFcState();
- if (!(LifeCycleController.STOPPED.equals(state))) {
- throw new ChainedIllegalLifeCycleException(null ,
weaveableOptC , "The component is not stopped");
- }
- }
- removeFcSubComponent$1(subComponent);
- }
-
- /**
- * Checks the interface name against the component's type and then calls
the
- * overriden method. This method also creates the collection interfaces
- * when needed, and puts them in the {@link #_this_fcInterfaces} map.
- *
- * @param interfaceName the name of the external interface that must be
- * returned.
- * @return the external interface of the component to which this
interface
- * belongs, whose name is equal to the given name.
- * @throws NoSuchInterfaceException if there is no such interface.
- * @see
org.objectweb.fractal.julia.TypeComponentMixin#getFcInterface(java.lang.String)
- */
- public Object getFcInterface(final String interfaceName) throws
NoSuchInterfaceException {
- if ((interfaceName.indexOf('/')) == 0) {
- return getFcInterface$0(interfaceName);
- }
- ComponentType compType = ((ComponentType)(getFcType()));
- InterfaceType itfType;
- try {
- itfType = compType.getFcInterfaceType(interfaceName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , this ,
interfaceName);
- }
- Object result;
- try {
- result = getFcInterface$0(interfaceName);
- } catch (NoSuchInterfaceException e) {
- if (itfType.isFcCollectionItf()) {
- result = getFcInterface$0(("/collection/" +
(itfType.getFcItfName())));
- result = ((ComponentInterface)(result)).clone();
- ((ComponentInterface)(result)).setFcItfName(interfaceName);
- fcInterfaces.put(interfaceName ,result);
- } else {
- throw e;
- }
- }
- return result;
- }
-
- /**
- * @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()])));
- }
-
- /**
- * Calls the overriden method and then notifies the given component it
has
- * been added in this component. This method does nothing if the given
sub
- * component does not provide the {@link SuperControllerNotifier}
interface.
- *
- * @param subComponent the component to be added inside this component.
- * @throws IllegalContentException if the given component cannot be added
- * inside this component.
- * @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.content.SuperContentMixin#addFcSubComponent(org.objectweb.fractal.api.Component)
- */
- public void addFcSubComponent(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- addFcSubComponent$0(subComponent);
- SuperControllerNotifier scn =
getFcSuperControllerNotifier(subComponent);
- if (scn != null) {
- try {
- Component c =
((Component)(weaveableC.getFcInterface("component")));
- scn.addedToFc(c);
- } catch (NoSuchInterfaceException ignored) {
- }
- }
- }
-
- /**
- * 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$3(final InitializationContext ic) throws
InstantiationException {
- weaveableSC =
((SuperController)(ic.getInterface("super-controller")));
- initFcController$4(ic);
- }
-
- /**
- * The internal interfaces of the component to which this controller
object
- * belongs.
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#fcInternalInterfaces
- */
- public Map fcInternalInterfaces;
-
- /**
- * Checks that the given component is not already a sub component, and
then
- * calls the overriden method. This method also checks that the addition
of
- * this sub component will not create a cycle in the component hierarchy.
- *
- * @param subComponent the component to be added inside this component.
- * @throws IllegalContentException if the given component cannot be added
- * inside this component.
- * @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.content.CheckContentMixin#addFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void addFcSubComponent$0(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- if (containsFcSubComponent(subComponent)) {
- throw new ChainedIllegalContentException(null , weaveableC ,
subComponent , "Already a sub component");
- }
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalContentException(e , weaveableC ,
subComponent , "Cannot check this operation");
- }
- if (subComponent.equals(thisComponent)) {
- throw new ChainedIllegalContentException(null , weaveableC ,
subComponent , "A component cannot be a sub component of itself");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(subComponent);
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- if (allSubComponents.get(i).equals(thisComponent)) {
- throw new ChainedIllegalContentException(null , weaveableC ,
subComponent , "Would create a cycle in the component hierarchy");
- }
- }
- addFcSubComponent$1(subComponent);
- }
-
- /**
- * 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)
- */
- private void initFcController$1(final InitializationContext ic) throws
InstantiationException {
- weaveableCC =
((ContentController)(ic.getInterface("content-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$2(final InitializationContext ic) throws
InstantiationException {
- weaveableOptLC =
((LifeCycleController)(ic.getOptionalInterface("lifecycle-controller")));
- initFcController$3(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);
- }
-
- /**
- * Checks the mandatory client interfaces of the component (and of all
its sub
- * components) and then calls the overriden method.
- *
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin#startFc()
- */
- public void startFc() throws IllegalLifeCycleException {
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot start the component");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- Component subComponent = ((Component)(allSubComponents.get(i)));
- try {
- checkFcMandatoryInterfaces(subComponent);
- } catch (IllegalBindingException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot start the component");
- }
- }
- startFc$0();
- }
-
- /**
- * Checks the interface name against the component's type and then calls
the
- * overriden method. This method also creates the collection interfaces
- * when needed, and puts them in the {@link #_this_fcInternalInterfaces}
map.
- *
- * @param interfaceName the name of the internal interface that must be
- * returned.
- * @return the internal interface of the component to which this
interface
- * belongs, whose name is equal to the given name.
- * @throws NoSuchInterfaceException if there is no such interface.
- * @see
org.objectweb.fractal.julia.control.content.TypeContentMixin#getFcInternalInterface(java.lang.String)
- */
- public Object getFcInternalInterface(final String interfaceName) throws
NoSuchInterfaceException {
- ComponentType compType = ((ComponentType)(weaveableC.getFcType()));
- InterfaceType itfType;
- try {
- itfType = compType.getFcInterfaceType(interfaceName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , weaveableC ,
interfaceName);
- }
- Object result;
- try {
- result = getFcInternalInterface$0(interfaceName);
- } catch (NoSuchInterfaceException e) {
- if (itfType.isFcCollectionItf()) {
- String collectionName = "/collection/" +
(itfType.getFcItfName());
- result = getFcInternalInterface$0(collectionName);
- result = ((ComponentInterface)(result)).clone();
- ((ComponentInterface)(result)).setFcItfName(interfaceName);
- fcInternalInterfaces.put(interfaceName ,result);
- } else {
- throw e;
- }
- }
- return result;
- }
-
- /**
- * 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$0(final InitializationContext ic) throws
InstantiationException {
- weaveableC = ((Component)(ic.getInterface("component")));
- weaveableOptC = weaveableC;
- initFcController$1(ic);
- }
-
- /**
- * Indicates if this component is started or not.
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#fcStarted
- */
- public boolean fcStarted;
-
- /**
- * @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);
- }
-
- /**
- * The sub components of the component to which this controller object
- * belongs.
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#fcSubComponents
- */
- public List fcSubComponents;
-
- /**
- * Initializes the fields of this mixin from the given context, 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.BasicComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- public void initFcController(final InitializationContext ic) throws
InstantiationException {
- this.fcType = ic.type;
- this.fcInterfaces = ic.interfaces;
- initFcController$0(ic);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#removedFromFc(org.objectweb.fractal.api.Component)
- */
- public void removedFromFc(final Component parent) {
- int length = (fcParents.length) - 1;
- if (length == 0) {
- fcParents = null;
- } else {
- Component[] parents = new Component[length];
- int i = 0;
- for (int j = 0 ; j < (fcParents.length) ; ++j) {
- if (!(fcParents[j].equals(parent))) {
- parents[i++] = fcParents[j];
- }
- }
- fcParents = parents;
- }
- }
-
- /**
- * Sets the lifecycle state of this component and of all its direct and
- * indirect sub components that have a {@link LifeCycleCoordinator}
interface.
- *
- * @param started <tt>true</tt> to set the lifecycle state of the
components
- * to {@link #STARTED STARTED}, or <tt>false</tt> to set this state
to
- * {@link #STOPPED STOPPED}.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#setFcState(boolean)
- */
- public void setFcState(final boolean started) throws
IllegalLifeCycleException {
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot set the lifecycle state");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- Component c = ((Component)(allSubComponents.get(i)));
- LifeCycleCoordinator lc;
- try {
- lc =
((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller")));
- } catch (Exception e) {
- try {
- lc =
((LifeCycleCoordinator)(c.getFcInterface("/lifecycle-coordinator")));
- } catch (NoSuchInterfaceException f) {
- continue;
- }
- }
- if (started) {
- lc.setFcStarted();
- } else {
- lc.setFcStopped();
- }
- }
- }
-
- /**
- * Checks that this operation will not create non local bindings, and
then
- * calls the overriden method.
- *
- * @param subComponent the component to be removed from this component.
- * @throws IllegalContentException if the given component cannot be
removed
- * from this component.
- * @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.content.BindingContentMixin#removeFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void removeFcSubComponent$1(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- try {
- checkFcRemoveSubComponent(subComponent);
- } catch (IllegalBindingException e) {
- throw new ChainedIllegalContentException(e , weaveableOptC ,
subComponent , "Would create non local bindings");
- }
- removeFcSubComponent$2(subComponent);
- }
-
- /**
- * 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.lifecycle.OptimizedLifeCycleControllerMixin#getFcState()
- */
- public String getFcState() {
- return fcStarted ? LifeCycleController.STARTED :
LifeCycleController.STOPPED;
- }
-
- /**
- * @see org.objectweb.fractal.julia.BasicComponentMixin#getFcType()
- */
- public Type getFcType() {
- return fcType;
- }
-
- /**
- * @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);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#startFc()
- */
- private void startFc$0() throws IllegalLifeCycleException {
- Component id;
- try {
- id = ((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot start component");
- }
- LifeCycleCoordinator[] clccs = getFcLifeCycleControllers(id);
- for (int i = 0 ; i < (clccs.length) ; ++i) {
- clccs[i].setFcStarted();
- }
- setFcState(true);
- }
-
- /**
- * 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)
- */
- public void bindFc(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- bindFc$0(clientItfType ,clientItfName ,serverItf);
- setFcShortcuts(clientItfType ,clientItfName ,serverItf);
- }
-
- /**
- * 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.BasicContentControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$5(final InitializationContext ic) throws
InstantiationException {
- fcInternalInterfaces = ic.internalInterfaces;
- initFcController$6(ic);
- }
-
- /**
- * @see org.objectweb.fractal.julia.BasicComponentMixin#getFcInterfaces()
- */
- public Object[] getFcInterfaces() {
- if ((fcInterfaces) == null) {
- return new Object[0];
- }
- int size = 0;
- String[] names = new String[fcInterfaces.size()];
- names = ((String[])(fcInterfaces.keySet().toArray(names)));
- for (int i = 0 ; i < (names.length) ; ++i) {
- if ((names[i].charAt(0)) != '/') {
- ++size;
- }
- }
- int index = 0;
- Object[] itfs = new Object[size];
- for (int i = 0 ; i < (names.length) ; ++i) {
- if ((names[i].charAt(0)) != '/') {
- itfs[index++] = fcInterfaces.get(names[i]);
- }
- }
- return itfs;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#getFcInternalInterfaces()
- */
- public Object[] getFcInternalInterfaces() {
- if ((fcInternalInterfaces) == null) {
- return new Object[0];
- }
- int size = 0;
- String[] names = new String[fcInternalInterfaces.size()];
- names = ((String[])(fcInternalInterfaces.keySet().toArray(names)));
- for (int i = 0 ; i < (names.length) ; ++i) {
- if ((names[i].charAt(0)) != '/') {
- ++size;
- }
- }
- int index = 0;
- Object[] itfs = new Object[size];
- for (int i = 0 ; i < (names.length) ; ++i) {
- if ((names[i].charAt(0)) != '/') {
- itfs[index++] = fcInternalInterfaces.get(names[i]);
- }
- }
- return itfs;
- }
-
- /**
- * Calls the overriden method and then notifies the given component it
has
- * been removed from in this component. This method does nothing if the
given
- * sub component does not provide the {@link SuperControllerNotifier}
- * interface.
- *
- * @param subComponent the component to be removed from this component.
- * @throws IllegalContentException if the given component cannot be
removed
- * from this component.
- * @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.content.SuperContentMixin#removeFcSubComponent(org.objectweb.fractal.api.Component)
- */
- public void removeFcSubComponent(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- removeFcSubComponent$0(subComponent);
- SuperControllerNotifier scn =
getFcSuperControllerNotifier(subComponent);
- if (scn != null) {
- try {
- Component c =
((Component)(weaveableC.getFcInterface("component")));
- scn.removedFromFc(c);
- } catch (NoSuchInterfaceException ignored) {
- }
- }
- }
-
- /**
- * @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);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#stopFc()
- */
- public void stopFc() throws IllegalLifeCycleException {
- Component id;
- try {
- id = ((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot stop component");
- }
- LifeCycleCoordinator[] clccs = getFcLifeCycleControllers(id);
- stopFc(clccs);
- setFcState(false);
- }
-
- /**
- * 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 that the removal of the given sub component will not create non
- * local bindings.
- *
- * @param subComponent a sub component that will be removed from this
- * component.
- * @throws IllegalBindingException if the removal of the given sub
component
- * would create non local bindings.
- * @see
org.objectweb.fractal.julia.control.content.BindingContentMixin#checkFcRemoveSubComponent(org.objectweb.fractal.api.Component)
- */
- public void checkFcRemoveSubComponent(final Component subComponent)
throws IllegalBindingException {
- Component parent;
- try {
- parent =
((Component)(weaveableOptC.getFcInterface("component")));
- if (parent == null) {
- return ;
- }
- } catch (NoSuchInterfaceException e) {
- return ;
- }
- BindingController bc;
- try {
- bc =
((BindingController)(subComponent.getFcInterface("binding-controller")));
- } catch (NoSuchInterfaceException e) {
- bc = null;
- }
- Object[] itfs = subComponent.getFcInterfaces();
- for (int i = 0 ; i < (itfs.length) ; ++i) {
- Interface itf;
- InterfaceType itfType;
- try {
- itf = ((Interface)(itfs[i]));
- itfType = ((InterfaceType)(itf.getFcItfType()));
- } catch (ClassCastException e) {
- continue;
- }
- if (itfType.isFcClientItf()) {
- if (bc != null) {
- Interface sItf;
- try {
- sItf =
((Interface)(bc.lookupFc(itf.getFcItfName())));
- } catch (NoSuchInterfaceException e) {
- continue;
- } catch (ClassCastException e) {
- continue;
- }
- if (sItf != null) {
- checkFcLocalBinding(itf ,parent ,sItf ,null);
- }
- }
- } else {
- Object[] potentialClients;
- try {
- potentialClients =
org.objectweb.fractal.julia.control.binding.Util.getFcPotentialClientsOf(itf).toArray();
- } catch (Exception e) {
- continue;
- }
- for (int j = 0 ; j < (potentialClients.length) ; ++j) {
- Component c = ((Component)(potentialClients[j]));
- List clientItfs;
- try {
- clientItfs =
org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(c
,itf);
- } catch (Exception e) {
- continue;
- }
- if ((clientItfs.size()) > 0) {
- checkFcLocalBinding(((Interface)(clientItfs.get(0)))
,null ,itf ,parent);
- }
- }
- }
- }
- }
-
- /**
- * Checks that all the mandatory client interface of the given component
are
- * bound.
- *
- * @param c a component.
- * @throws IllegalBindingException if a mandatory client interface of the
- * given component is not bound.
- * @see
org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin#checkFcMandatoryInterfaces(org.objectweb.fractal.api.Component)
- */
- public void checkFcMandatoryInterfaces(final Component c) throws
IllegalBindingException {
- BindingController bc;
- try {
- bc =
((BindingController)(c.getFcInterface("binding-controller")));
- } catch (NoSuchInterfaceException e) {
- return ;
- }
- ComponentType compType = ((ComponentType)(c.getFcType()));
- String[] names = bc.listFc();
- for (int i = 0 ; i < (names.length) ; ++i) {
- InterfaceType itfType;
- try {
- itfType = compType.getFcInterfaceType(names[i]);
- } catch (NoSuchInterfaceException e) {
- continue;
- }
- if ((itfType.isFcClientItf()) && (!(itfType.isFcOptionalItf())))
{
- Object sItf;
- try {
- sItf = bc.lookupFc(names[i]);
- } catch (NoSuchInterfaceException e) {
- continue;
- }
- if (sItf == null) {
- throw new ChainedIllegalBindingException(null , c , null
, names[i] , null , "Mandatory client interface unbound");
- }
- }
- }
- }
-
- /**
- * 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);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcActivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
- */
- public boolean fcActivated(final LifeCycleCoordinator component) {
- synchronized(fcActive) {
- if ((fcActive.size()) > 0) {
- if (!(fcActive.contains(component))) {
- fcActive.add(component);
- }
- return true;
- }
- return false;
- }
- }
-
- /**
- * @see
org.objectweb.fractal.julia.BasicComponentMixin#getFcInterface(java.lang.String)
- */
- private Object getFcInterface$0(final String interfaceName) throws
NoSuchInterfaceException {
- Object itf = (fcInterfaces) == null ? null :
fcInterfaces.get(interfaceName);
- if (itf == null) {
- throw new ChainedNoSuchInterfaceException(null , this ,
interfaceName);
- }
- return itf;
- }
-
- /**
- * 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)
- */
- public void unbindFc(final InterfaceType clientItfType, final String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- unbindFc$0(clientItfType ,clientItfName);
- setFcShortcuts(clientItfType ,clientItfName ,null);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStarted()
- */
- public boolean setFcStarted() {
- if (!(fcStarted)) {
- fcStarted = true;
- return true;
- }
- return false;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#getFcInternalInterface(java.lang.String)
- */
- private Object getFcInternalInterface$0(final String interfaceName)
throws NoSuchInterfaceException {
- Object itf;
- if ((fcInternalInterfaces) == null) {
- itf = null;
- } else {
- itf = fcInternalInterfaces.get(interfaceName);
- }
- if (itf == null) {
- throw new ChainedNoSuchInterfaceException(null , weaveableOptC ,
interfaceName);
- }
- return itf;
- }
-
- /**
- * 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 {
- }
-
- /**
- * Returns the {@link SuperControllerNotifier} interface of the given
- * component.
- *
- * @param c a component.
- * @return the {@link SuperControllerNotifier} interface of the given
- * component, or <tt>null</tt>.
- * @see
org.objectweb.fractal.julia.control.content.SuperContentMixin#getFcSuperControllerNotifier(org.objectweb.fractal.api.Component)
- */
- private SuperControllerNotifier getFcSuperControllerNotifier(final
Component c) {
- try {
- return
((SuperControllerNotifier)(c.getFcInterface("super-controller")));
- } catch (Exception e) {
- try {
- return
((SuperControllerNotifier)(c.getFcInterface("/super-controller-notifier")));
- } catch (NoSuchInterfaceException ignored) {
- return null;
- }
- }
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcInactivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
- */
- public void fcInactivated(final LifeCycleCoordinator component) {
- synchronized(fcActive) {
- fcActive.remove(component);
- fcActive.notifyAll();
- }
- }
-
- /**
- * Checks that the given component is really a sub component, and then
- * calls the overriden method.
- *
- * @param subComponent the component to be removed from this component.
- * @throws IllegalContentException if the given component cannot be
removed
- * from this component.
- * @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.content.CheckContentMixin#removeFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void removeFcSubComponent$2(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- if (!(containsFcSubComponent(subComponent))) {
- throw new ChainedIllegalContentException(null , weaveableC ,
subComponent , "Not a sub component");
- }
- removeFcSubComponent$3(subComponent);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStopping(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
- */
- public void setFcStopping(final LifeCycleCoordinator coordinator) throws
IllegalLifeCycleException {
- throw new Error("Internal error");
- }
-
- /**
- * The {@link Component#getFcInterface getFcInterface} method overriden
by
- * this mixin.
- *
- * @param interfaceName the name of the external interface that must be
- * returned.
- * @return the external interface of the component to which this
interface
- * belongs, whose name is equal to the given name.
- * @throws NoSuchInterfaceException if there is no such interface.
- */
- private Object getFcInterface$1(String interfaceName) throws
NoSuchInterfaceException {
- return null;
- }
-
- /**
- * The {@link ContentController#getFcInternalInterface
getFcInternalInterface}
- * method overriden by this mixin.
- *
- * @param interfaceName the name of the internal interface that must be
- * returned.
- * @return the internal interface of the component to which this
interface
- * belongs, whose name is equal to the given name.
- * @throws NoSuchInterfaceException if there is no such interface.
- */
- private Object getFcInternalInterface$1(String interfaceName) throws
NoSuchInterfaceException {
- return null;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#setFcStopped()
- */
- public boolean setFcStopped() {
- if (fcStarted) {
- fcStarted = false;
- return true;
- }
- return false;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#getFcSubComponents()
- */
- public Component[] getFcSubComponents() {
- if ((fcSubComponents) == null) {
- return new Component[0];
- }
- return ((Component[])(fcSubComponents.toArray(new
Component[fcSubComponents.size()])));
- }
-
- /**
- * 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$7(InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * Tests if this component contains the given sub component.
- *
- * @param subComponent a component.
- * @return <tt>true</tt> if this component contains the given sub
component,
- * or <tt>false</tt> otherwise.
- * @see
org.objectweb.fractal.julia.control.content.CheckContentMixin#containsFcSubComponent(org.objectweb.fractal.api.Component)
- */
- public boolean containsFcSubComponent(final Component subComponent) {
- Component[] subComponents = getFcSubComponents();
- for (int i = 0 ; i < (subComponents.length) ; ++i) {
- if (subComponents[i].equals(subComponent)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#addFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void addFcSubComponent$1(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- if ((fcSubComponents) == null) {
- fcSubComponents = new ArrayList();
- }
- fcSubComponents.add(subComponent);
- }
-
- /**
- * 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");
- }
- }
- }
- }
-
- /**
- * Stops the given components simultaneously. This method sets the state
of
- * the components to "<tt>STOPPING</tt>", waits until all the components
- * are simultaneoulsy inactive (their state is known thanks to the {@link
- * #fcActivated fcActivated} and {@link #fcInactivated fcInactivated}
callback
- * methods), and then sets the state of the components to {@link #STOPPED
- * STOPPED}.
- *
- * @param components the {@link LifeCycleCoordinator} interface of the
- * components to be stopped.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#stopFc(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)
- */
- public void stopFc(final LifeCycleCoordinator[] components) throws
IllegalLifeCycleException {
- fcActive = new ArrayList();
- for (int i = 0 ; i < (components.length) ; ++i) {
- if
(components[i].getFcState().equals(LifeCycleController.STARTED)) {
- fcActive.add(components[i]);
- }
- }
- LifeCycleCoordinator c;
- try {
- c =
((LifeCycleCoordinator)(weaveableC.getFcInterface("lifecycle-controller")));
- } catch (Exception e) {
- try {
- c =
((LifeCycleCoordinator)(weaveableC.getFcInterface("/lifecycle-coordinator")));
- } catch (NoSuchInterfaceException f) {
- throw new ChainedIllegalLifeCycleException(f , weaveableC ,
"Cannot stop components");
- }
- }
- for (int i = 0 ; i < (components.length) ; ++i) {
- if
(components[i].getFcState().equals(LifeCycleController.STARTED)) {
- components[i].setFcStopping(c);
- }
- }
- synchronized(fcActive) {
- while ((fcActive.size()) > 0) {
- try {
- fcActive.wait();
- } catch (InterruptedException e) {
- }
- }
- }
- for (int i = 0 ; i < (components.length) ; ++i) {
- if
(components[i].getFcState().equals(LifeCycleController.STARTED)) {
- components[i].setFcStopped();
- }
- }
- fcActive = null;
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicContentControllerMixin#removeFcSubComponent(org.objectweb.fractal.api.Component)
- */
- private void removeFcSubComponent$3(final Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- if ((fcSubComponents) != null) {
- fcSubComponents.remove(subComponent);
- }
- }
-
- /**
- * Returns the components that must be stopped in order to stop the given
- * component. These components are the direct or indirect primitive sub
- * components of this component that provide a {@link
LifeCycleCoordinator}
- * interface, as well as the primitive client components of these
components.
- *
- * @param id a composite component.
- * @return the components that must be stopped in order to stop the given
- * component.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getFcLifeCycleControllers(org.objectweb.fractal.api.Component)
- */
- public LifeCycleCoordinator[] getFcLifeCycleControllers(final Component
id) throws IllegalLifeCycleException {
- List clccList = getFcInternalLifeCycleControllers();
- Object[] sItfs = id.getFcInterfaces();
- Set visited = new HashSet();
- for (int i = 0 ; i < (sItfs.length) ; ++i) {
- Interface sItf = ((Interface)(sItfs[i]));
- if (!(((InterfaceType)(sItf.getFcItfType())).isFcClientItf())) {
- getSExtLifeCycleControllers(sItf ,clccList ,visited);
- }
- }
- LifeCycleCoordinator[] clccs;
- clccs = new LifeCycleCoordinator[clccList.size()];
- return ((LifeCycleCoordinator[])(clccList.toArray(clccs)));
- }
-
- /**
- * The {@link ContentController#addFcSubComponent addFcSubComponent}
method
- * overriden by this mixin.
- *
- * @param subComponent the component to be added inside this component.
- * @throws IllegalContentException if the given component cannot be added
- * inside this component.
- * @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 addFcSubComponent$2(Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- }
-
- /**
- * The {@link LifeCycleController#startFc startFc} method overriden by
this
- * mixin.
- *
- * @throws IllegalLifeCycleException if a problem occurs.
- */
- private void startFc$1() throws IllegalLifeCycleException {
- }
-
- /**
- * The {@link ContentController#removeFcSubComponent
removeFcSubComponent}
- * method overriden by this mixin.
- *
- * @param subComponent the component to be removed from this component.
- * @throws IllegalContentException if the given component cannot be
removed
- * from this component.
- * @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 removeFcSubComponent$4(Component subComponent) throws
IllegalContentException, IllegalLifeCycleException {
- }
-
- /**
- * Checks that a given binding is a local binding.
- *
- * @param cItf a client interface.
- * @param cId the parent from which the client component has been
removed, or
- * <tt>null</tt> if the client component has not been removed from a
- * parent component.
- * @param sItf the server interface to which the client interface is
bound.
- * @param sId the parent from which the server component has been
removed, or
- * <tt>null</tt> if the server component has not been removed from a
- * parent component.
- * @throws IllegalBindingException if the given binding is not a local
- * binding.
- * @see
org.objectweb.fractal.julia.control.content.BindingContentMixin#checkFcLocalBinding(org.objectweb.fractal.api.Interface,org.objectweb.fractal.api.Component,org.objectweb.fractal.api.Interface,org.objectweb.fractal.api.Component)
- */
- private void checkFcLocalBinding(final Interface cItf, final Component
cId, final Interface sItf, final Component sId) throws
IllegalBindingException {
- Component client = cItf.getFcItfOwner();
- Component server = sItf.getFcItfOwner();
- if (client.equals(server)) {
- return ;
- }
- SuperController cSc = null;
- SuperController sSc = null;
- try {
- cSc =
((SuperController)(client.getFcInterface("super-controller")));
- } catch (NoSuchInterfaceException ignored) {
- }
- try {
- sSc =
((SuperController)(server.getFcInterface("super-controller")));
- } catch (NoSuchInterfaceException ignored) {
- }
- if (cItf.isFcInternalItf()) {
- if (cSc != null) {
- Component[] sP = sSc.getFcSuperComponents();
- for (int i = 0 ; i < (sP.length) ; ++i) {
- Component p = sP[i];
- if ((sId == null) || (!(p.equals(sId)))) {
- if (p.equals(client)) {
- return ;
- }
- }
- }
- } else {
- return ;
- }
- } else {
- if (sItf.isFcInternalItf()) {
- if (cSc != null) {
- Component[] cP = cSc.getFcSuperComponents();
- for (int i = 0 ; i < (cP.length) ; ++i) {
- Component p = cP[i];
- if ((cId == null) || (!(p.equals(cId)))) {
- if (p.equals(server)) {
- return ;
- }
- }
- }
- } else {
- return ;
- }
- } else {
- if ((cSc != null) && (sSc != null)) {
- Component[] cP = cSc.getFcSuperComponents();
- Component[] sP = sSc.getFcSuperComponents();
- for (int i = 0 ; i < (cP.length) ; ++i) {
- Component p = cP[i];
- if ((cId == null) || (!(p.equals(cId)))) {
- for (int j = 0 ; j < (sP.length) ; ++j) {
- Component q = sP[j];
- if ((sId == null) || (!(q.equals(sId)))) {
- if (p.equals(q)) {
- return ;
- }
- }
- }
- }
- }
- } else {
- return ;
- }
- }
- }
- throw new ChainedIllegalBindingException(null , weaveableOptC , sId
, cItf.getFcItfName() , sItf.getFcItfName() , "Not a local binding");
- }
-
- /**
- * Finds the primitive client components that are bound to the given
server
- * interface.
- *
- * @param serverItf a server interface.
- * @param clccList where to put the {@link LifeCycleCoordinator}
- * interfaces of the primitive client components that are found.
- * @param visited the already visited interfaces.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getSExtLifeCycleControllers(org.objectweb.fractal.api.Interface,java.util.List,java.util.Set)
- */
- private void getSExtLifeCycleControllers(final Interface serverItf,
final List clccList, final Set visited) throws IllegalLifeCycleException {
- Object[] comps;
- try {
- comps =
org.objectweb.fractal.julia.control.binding.Util.getFcPotentialClientsOf(serverItf).toArray();
- } catch (Exception e) {
- throw new ChainedIllegalLifeCycleException(e ,
serverItf.getFcItfOwner() , "Cannot get the LifeCycleCoordinator interfaces");
- }
- for (int i = 0 ; i < (comps.length) ; ++i) {
- Component comp = ((Component)(comps[i]));
- Interface[] clientItfs;
- try {
- List l =
org.objectweb.fractal.julia.control.binding.Util.getFcClientItfsBoundTo(comp
,serverItf);
- clientItfs = ((Interface[])(l.toArray(new
Interface[l.size()])));
- } catch (Exception e) {
- throw new ChainedIllegalLifeCycleException(e ,
serverItf.getFcItfOwner() , "Cannot get the LifeCycleCoordinator interfaces");
- }
- for (int j = 0 ; j < (clientItfs.length) ; ++j) {
- getCExtLifeCycleControllers(clientItfs[j] ,clccList
,visited);
- }
- }
- }
-
- /**
- * 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);
- }
-
- /**
- * Finds the primitive client components that are bound to the given
client
- * interface.
- *
- * @param clientItf a client interface.
- * @param clccList where to put the {@link LifeCycleCoordinator}
interfaces of
- * the primitive client components that are found.
- * @param visited the already visited interfaces.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getCExtLifeCycleControllers(org.objectweb.fractal.api.Interface,java.util.List,java.util.Set)
- */
- private void getCExtLifeCycleControllers(final Interface clientItf,
final List clccList, final Set visited) throws IllegalLifeCycleException {
- Component component = clientItf.getFcItfOwner();
- ContentController cc = null;
- try {
- cc =
((ContentController)(component.getFcInterface("content-controller")));
- } catch (NoSuchInterfaceException e) {
- }
- if (cc != null) {
- Interface itf;
- String name = clientItf.getFcItfName();
- try {
- if (!(clientItf.isFcInternalItf())) {
- itf = ((Interface)(cc.getFcInternalInterface(name)));
- } else {
- itf = ((Interface)(component.getFcInterface(name)));
- }
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , component ,
"Cannot find the LifeCycleCoordinator interfaces");
- }
- if (!(visited.contains(itf))) {
- visited.add(itf);
- getSExtLifeCycleControllers(itf ,clccList ,visited);
- }
- } else if (!(visited.contains(clientItf))) {
- visited.add(clientItf);
- Component c = clientItf.getFcItfOwner();
- LifeCycleCoordinator lcc;
- try {
- lcc =
((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller")));
- } catch (Exception e) {
- try {
- lcc =
((LifeCycleCoordinator)(c.getFcInterface("/lifecycle-coordinator")));
- } catch (NoSuchInterfaceException f) {
- throw new ChainedIllegalLifeCycleException(f , component
, "Primitive client without a LifeCycleCoordinator");
- }
- }
- if (!(clccList.contains(lcc))) {
- clccList.add(lcc);
- }
- }
- }
-
- /**
- * 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);
- }
-
- /**
- * 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$1(final InterfaceType clientItfType, final String
clientItfName, final Object serverItf) throws NoSuchInterfaceException,
IllegalBindingException, IllegalLifeCycleException {
- bindFc$0(clientItfName ,serverItf);
- }
-
- /**
- * 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);
- }
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin#getFcInternalLifeCycleControllers()
- */
- public List getFcInternalLifeCycleControllers() throws
IllegalLifeCycleException {
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC , "The
OptimizedLifeCycleControllerMixin requires " + "components to provide the
Component interface");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
- List result = new ArrayList();
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- Component c = ((Component)(allSubComponents.get(i)));
- try {
- c.getFcInterface("content-controller");
- } catch (NoSuchInterfaceException e) {
- try {
-
result.add(((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller"))));
- } catch (Exception f) {
- try {
-
result.add(c.getFcInterface("/lifecycle-coordinator"));
- } catch (NoSuchInterfaceException ignored) {
- }
- }
- }
- }
- return result;
- }
-
- /**
- * 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$0(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 {
- }
-
- /**
- * 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$2(InterfaceType clientItfType, String clientItfName,
Object serverItf) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- }
-
- /**
- * 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$1(InterfaceType clientItfType, String
clientItfName) throws NoSuchInterfaceException, IllegalBindingException,
IllegalLifeCycleException {
- }
-
-}
\ No newline at end of file
Index: julia/src/org/objectweb/fractal/juliak/PrimitiveMembraneImpl.java
diff -u julia/src/org/objectweb/fractal/juliak/PrimitiveMembraneImpl.java:1.2
julia/src/org/objectweb/fractal/juliak/PrimitiveMembraneImpl.java:removed
--- julia/src/org/objectweb/fractal/juliak/PrimitiveMembraneImpl.java:1.2
Sat Dec 16 20:29:46 2006
+++ julia/src/org/objectweb/fractal/juliak/PrimitiveMembraneImpl.java Mon
Dec 18 21:48:43 2006
@@ -1,1606 +0,0 @@
-/*
- * Generated by SpoonMixinClassProcessor.
- *
- * Author: Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- */
-package org.objectweb.fractal.juliak;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.objectweb.fractal.api.Component;
-import org.objectweb.fractal.api.Interface;
-import org.objectweb.fractal.api.NoSuchInterfaceException;
-import org.objectweb.fractal.api.Type;
-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.NameController;
-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.ContentBindingController;
-import org.objectweb.fractal.julia.control.binding.TypeBindingMixin;
-import org.objectweb.fractal.julia.control.content.SuperControllerNotifier;
-import
org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException;
-import
org.objectweb.fractal.julia.control.lifecycle.ContentLifeCycleController;
-import org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator;
-import org.objectweb.fractal.julia.factory.ChainedInstantiationException;
-import org.objectweb.fractal.juliak.asm.ClassGenerator;
-import org.objectweb.fractal.juliak.asm.InterceptorClassGenerator;
-import org.objectweb.fractal.juliak.asm.TreeParserException;
-import org.objectweb.fractal.juliak.control.binding.BindingControllerDef;
-import org.objectweb.fractal.juliak.control.content.ContentControllerDef;
-import
org.objectweb.fractal.juliak.control.interceptor.InterceptorController;
-import
org.objectweb.fractal.juliak.control.interceptor.InterceptorDefAttributes;
-import org.objectweb.fractal.juliak.factory.InstanceGenerator;
-
-/**
- * Default implementation of the control membrane for primitive components.
- * This implementation merges the controllers associated with a primitive
- * membrane.
- *
- * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
- *
- * @see org.objectweb.fractal.julia.BasicControllerMixin
- * @see
org.objectweb.fractal.juliak.control.interceptor.InterceptorControllerMixin
- * @see org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin
- * @see
org.objectweb.fractal.julia.control.binding.ContainerBindingControllerMixin
- * @see org.objectweb.fractal.julia.control.binding.InterceptorBindingMixin
- * @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.UseComponentMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleControllerMixin
- * @see org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin
- * @see org.objectweb.fractal.julia.control.lifecycle.ContainerLifeCycleMixin
- * @see org.objectweb.fractal.julia.control.name.BasicNameControllerMixin
- * @see org.objectweb.fractal.julia.BasicComponentMixin
- * @see org.objectweb.fractal.julia.TypeComponentMixin
- */
-public class PrimitiveMembraneImpl implements Component , BindingController
, LifeCycleController , NameController , Controller , SuperControllerNotifier
, LifeCycleCoordinator , InterceptorController , InterceptorDefAttributes {
- /**
- * The name of the component to which this controller object belongs.
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#name
- */
- public String name;
-
- /**
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#getFcName()
- */
- public String getFcName() {
- return name;
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableC
- */
- public Component weaveableC;
-
- /**
- * The parents of the component to which this controller object belongs.
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#fcParents
- */
- public Component[] fcParents;
-
- /**
- * 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$6(final InitializationContext ic) throws
InstantiationException {
- }
-
- /**
- * The type of this component.
- * @see org.objectweb.fractal.julia.BasicComponentMixin#fcType
- */
- public Type fcType;
-
- /**
- * 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;
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#getFcSuperComponents()
- */
- public Component[] getFcSuperComponents() {
- if ((fcParents) == null) {
- return new Component[0];
- } else {
- return fcParents;
- }
- }
-
- /**
- * 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;
-
- /**
- * @see
org.objectweb.fractal.juliak.control.interceptor.InterceptorControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$5(InitializationContext ic) throws
InstantiationException {
- if ((interceptorClassGenerator) != null) {
- BindingController bc =
((BindingController)(ic.interfaces.get(("//" +
(BindingControllerDef.NAME)))));
- String[] itfNames = bc.listFc();
- InitializationContext intic = new InitializationContext();
- intic.interfaces = new HashMap<java.lang.String,
java.lang.Object> ();
- for (int i = 0 ; i < (itfNames.length) ; i++) {
- String itfName = itfNames[i].substring(2);
- Object end =
org.objectweb.fractal.juliak.FractalHelper.lookupFc(bc ,itfNames[i]);
- while (end instanceof ComponentInterface) {
- ComponentInterface ci = ((ComponentInterface)(end));
- end = ci.getFcItfImpl();
- }
- intic.interfaces.put(itfName ,end);
- }
- Component compctrl =
((Component)(ic.interfaces.get("component")));
- ContentController cc = null;
- try {
- Object o =
compctrl.getFcInterface(ContentControllerDef.NAME);
- cc = ((ContentController)(o));
- } catch (NoSuchInterfaceException nsie) {
- }
- ComponentType ct = ((ComponentType)(compctrl.getFcType()));
- InterfaceType[] its = ct.getFcInterfaceTypes();
- for (InterfaceType it : its) {
- String itfName = it.getFcItfName();
- if (it.isFcCollectionItf()) {
- itfName = "/juliak/collection/" + (it.getFcItfName());
- }
- Object itf =
org.objectweb.fractal.juliak.FractalHelper.getFcInterface(compctrl ,itfName);
- addFcInterceptor(itf ,intic ,cc);
- }
- }
- initFcController$6(ic);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.name.BasicNameControllerMixin#setFcName(java.lang.String)
- */
- public void setFcName(final String name) {
- this.name = name;
- }
-
- /**
- * The {@link Component} interface of the component to which this
controller
- * object belongs.
- * @see org.objectweb.fractal.julia.UseComponentMixin#weaveableOptC
- */
- public Component weaveableOptC;
-
- /**
- * Calls the overriden method and then calls the {@link
#setFcContentState
- * setFcContentState} method.
- *
- * @return <tt>true</tt> if the execution state has changed, or
<tt>false</tt>
- * if it had already the {@link #STARTED STARTED} value.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.ContainerLifeCycleMixin#setFcStarted()
- */
- public boolean setFcStarted() throws IllegalLifeCycleException {
- synchronized(this) {
- if (setFcStarted$0()) {
- setFcContentState(true);
- return true;
- }
- return false;
- }
- }
-
- /**
- * The components that are currently active.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#fcActive
- */
- public List fcActive;
-
- /**
- * The interfaces of this component. This map associates each interface
to its
- * name.
- * @see org.objectweb.fractal.julia.BasicComponentMixin#fcInterfaces
- */
- public Map fcInterfaces;
-
- /**
- * The "user component" encapsulated in this container component.
- * @see
org.objectweb.fractal.julia.control.binding.ContainerBindingControllerMixin#fcContent
- */
- public Object fcContent;
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#addedToFc(org.objectweb.fractal.api.Component)
- */
- public void addedToFc(final Component parent) {
- int length = (fcParents) == null ? 1 : (fcParents.length) + 1;
- Component[] parents = new Component[length];
- if ((fcParents) != null) {
- java.lang.System.arraycopy(fcParents ,0 ,parents ,1
,fcParents.length);
- }
- parents[0] = parent;
- fcParents = parents;
- }
-
- /**
- * 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);
- }
-
- /**
- * Checks the interface name against the component's type and then calls
the
- * overriden method. This method also creates the collection interfaces
- * when needed, and puts them in the {@link #_this_fcInterfaces} map.
- *
- * @param interfaceName the name of the external interface that must be
- * returned.
- * @return the external interface of the component to which this
interface
- * belongs, whose name is equal to the given name.
- * @throws NoSuchInterfaceException if there is no such interface.
- * @see
org.objectweb.fractal.julia.TypeComponentMixin#getFcInterface(java.lang.String)
- */
- public Object getFcInterface(final String interfaceName) throws
NoSuchInterfaceException {
- if ((interfaceName.indexOf('/')) == 0) {
- return getFcInterface$0(interfaceName);
- }
- ComponentType compType = ((ComponentType)(getFcType()));
- InterfaceType itfType;
- try {
- itfType = compType.getFcInterfaceType(interfaceName);
- } catch (NoSuchInterfaceException e) {
- throw new ChainedNoSuchInterfaceException(null , this ,
interfaceName);
- }
- Object result;
- try {
- result = getFcInterface$0(interfaceName);
- } catch (NoSuchInterfaceException e) {
- if (itfType.isFcCollectionItf()) {
- result = getFcInterface$0(("/collection/" +
(itfType.getFcItfName())));
- result = ((ComponentInterface)(result)).clone();
- ((ComponentInterface)(result)).setFcItfName(interfaceName);
- fcInterfaces.put(interfaceName ,result);
- } else {
- throw e;
- }
- }
- return result;
- }
-
- /**
- * 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$3(final InitializationContext ic) throws
InstantiationException {
- weaveableSC =
((SuperController)(ic.getInterface("super-controller")));
- initFcController$4(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$2(final InitializationContext ic) throws
InstantiationException {
- weaveableOptLC =
((LifeCycleController)(ic.getOptionalInterface("lifecycle-controller")));
- initFcController$3(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);
- }
-
- /**
- * Checks the mandatory client interfaces of the component (and of all
its sub
- * components) and then calls the overriden method.
- *
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin#startFc()
- */
- public void startFc() throws IllegalLifeCycleException {
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot start the component");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- Component subComponent = ((Component)(allSubComponents.get(i)));
- try {
- checkFcMandatoryInterfaces(subComponent);
- } catch (IllegalBindingException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot start the component");
- }
- }
- startFc$0();
- }
-
- /**
- * The life cycle state of this component. Zero means stopped, one means
- * stopping and two means started.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleControllerMixin#fcState
- */
- public int fcState;
-
- /**
- * 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$1(final InitializationContext ic) throws
InstantiationException {
- weaveableC = ((Component)(ic.getInterface("component")));
- weaveableOptC = weaveableC;
- initFcController$2(ic);
- }
-
- /**
- * Calls the overriden method and returns the corresponding {@link
- * Interceptor#getFcItfDelegate getFcItfDelegate} (if the result is an
{@link
- * Interceptor}).
- *
- * @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.InterceptorBindingMixin#lookupFc(java.lang.String)
- */
- private Object lookupFc$0(final String clientItfName) throws
NoSuchInterfaceException {
- Object o = lookupFc$1(clientItfName);
- if (o instanceof Interceptor) {
- o = ((Interceptor)(o)).getFcItfDelegate();
- }
- return o;
- }
-
- /**
- * 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);
- }
-
- /**
- * 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.binding.ContainerBindingControllerMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- private void initFcController$4(final InitializationContext ic) throws
InstantiationException {
- fcContent = ic.content;
- Component owner =
((Component)(ic.getOptionalInterface("component")));
- if (owner != null) {
- try {
- owner = ((Component)(owner.getFcInterface("component")));
- if ((fcContent) == (this)) {
- if ((this) instanceof ContentBindingController) {
-
((ContentBindingController)(this)).bindFcContent("component" ,owner);
- }
- } else if ((fcContent) instanceof BindingController) {
- ((BindingController)(fcContent)).bindFc("component"
,owner);
- }
- } catch (Exception ignored) {
- }
- }
- initFcController$5(ic);
- }
-
- /**
- * Initializes the fields of this mixin from the given context, 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.BasicComponentMixin#initFcController(org.objectweb.fractal.julia.InitializationContext)
- */
- public void initFcController(final InitializationContext ic) throws
InstantiationException {
- this.fcType = ic.type;
- this.fcInterfaces = ic.interfaces;
- initFcController$0(ic);
- }
-
- /**
- * @see
org.objectweb.fractal.julia.control.content.BasicSuperControllerMixin#removedFromFc(org.objectweb.fractal.api.Component)
- */
- public void removedFromFc(final Component parent) {
- int length = (fcParents.length) - 1;
- if (length == 0) {
- fcParents = null;
- } else {
- Component[] parents = new Component[length];
- int i = 0;
- for (int j = 0 ; j < (fcParents.length) ; ++j) {
- if (!(fcParents[j].equals(parent))) {
- parents[i++] = fcParents[j];
- }
- }
- fcParents = parents;
- }
- }
-
- /**
- * Sets the lifecycle state of this component and of all its direct and
- * indirect sub components that have a {@link LifeCycleCoordinator}
interface.
- *
- * @param started <tt>true</tt> to set the lifecycle state of the
components
- * to {@link #STARTED STARTED}, or <tt>false</tt> to set this state
to
- * {@link #STOPPED STOPPED}.
- * @throws IllegalLifeCycleException if a problem occurs.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin#setFcState(boolean)
- */
- public void setFcState(final boolean started) throws
IllegalLifeCycleException {
- Component thisComponent;
- try {
- thisComponent =
((Component)(weaveableC.getFcInterface("component")));
- } catch (NoSuchInterfaceException e) {
- throw new ChainedIllegalLifeCycleException(e , weaveableC ,
"Cannot set the lifecycle state");
- }
- List allSubComponents =
org.objectweb.fractal.julia.control.content.Util.getAllSubComponents(thisComponent);
- for (int i = 0 ; i < (allSubComponents.size()) ; ++i) {
- Component c = ((Component)(allSubComponents.get(i)));
- LifeCycleCoordinator lc;
- try {
- lc =
((LifeCycleCoordinator)(c.getFcInterface("lifecycle-controller")));
- } catch (Exception e) {
- try {
- lc =
((LifeCycleCoordinator)(c.getFcInterface("/lifecycle-coordinator")));
- } catch (NoSuchInterfaceException f) {
- continue;
- }
- }
- if (started) {
- lc.setFcStarted();
- } else {
- lc.setFcStopped();
- }
- }
- }
-
- /**
- * The number of currently executing method calls in this component.
- * @see
org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleControllerMixin#fcInvocationCounter
- */
- public int fcInvocationCounter;
-
- /**
- * 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 ther