org.objectweb.fractal.julia.control.lifecycle
Class OptimizedLifeCycleControllerMixin

java.lang.Object
  extended by org.objectweb.fractal.julia.control.lifecycle.OptimizedLifeCycleControllerMixin
All Implemented Interfaces:
LifeCycleController, LifeCycleCoordinator

public abstract class OptimizedLifeCycleControllerMixin
extends Object
implements LifeCycleCoordinator

Provides an optimized implementation of the LifeCycleController interface. This implementation does not need interceptors. This life cycle controller works by stopping all the direct and indirect primitive sub components that have a LifeCycleCoordinator interface, and the primitive client components of these components (these clients must also have a LifeCycleCoordinator interface). These components are stopped simultaneously, by using the coordinator interface provided by this component.

Requirements


Field Summary
 Component _this_weaveableC
          The weaveableC field required by this mixin.
 boolean fcStarted
          Indicates if this component is started or not.
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Method Summary
abstract  void _this_setFcState(boolean started)
          The setFcState method required by this mixin.
abstract  void _this_stopFc(LifeCycleCoordinator[] components)
          The stopFc method required by this mixin.
 List getFcInternalLifeCycleControllers()
           
 LifeCycleCoordinator[] getFcLifeCycleControllers(Component id)
          Returns the components that must be stopped in order to stop the given component.
 String getFcState()
           
 boolean setFcStarted()
          Sets the state of this component, but not of its sub components, to STARTED.
 boolean setFcStopped()
          Sets the state of this component, but not of its sub components, to STOPPED.
 void setFcStopping(LifeCycleCoordinator coordinator)
          Sets the state of this component, but not of its sub components, to "STOPPING".
 void startFc()
           
 void stopFc()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator
fcActivated, fcInactivated
 

Field Detail

fcStarted

public boolean fcStarted
Indicates if this component is started or not.


_this_weaveableC

public Component _this_weaveableC
The weaveableC field required by this mixin. This field is supposed to reference the Component interface of the component to which this controller object belongs.

Method Detail

getFcState

public String getFcState()
Specified by:
getFcState in interface LifeCycleController

startFc

public void startFc()
             throws IllegalLifeCycleException
Specified by:
startFc in interface LifeCycleController
Throws:
IllegalLifeCycleException

stopFc

public void stopFc()
            throws IllegalLifeCycleException
Specified by:
stopFc in interface LifeCycleController
Throws:
IllegalLifeCycleException

setFcStarted

public boolean setFcStarted()
Description copied from interface: LifeCycleCoordinator
Sets the state of this component, but not of its sub components, to STARTED. Because of component sharing, the startFc method cannot be implemented by just calling itself recursively on the sub components of this componets (otherwise some sub components may be started several times). Hence this method.

Specified by:
setFcStarted in interface LifeCycleCoordinator
Returns:
true if the execution state has changed, or false if it had already the STARTED value.

setFcStopping

public void setFcStopping(LifeCycleCoordinator coordinator)
                   throws IllegalLifeCycleException
Description copied from interface: LifeCycleCoordinator
Sets the state of this component, but not of its sub components, to "STOPPING". After this method has been called, and while the setFcStopped has not been called, this component must notify the given coordinator when it becomes inactive, and when it is about to become active, with the fcInactivated and fcActivated methods.
Note: the "STOPPING" state is an internal state that is not visible from the outside. Indeed, in this state, the getFcState method should return STARTED, as the component is not yet stopped.

Specified by:
setFcStopping in interface LifeCycleCoordinator
Parameters:
coordinator - the coordinator that must be notified when this component becomes inactive, and when it is about to become active.
Throws:
IllegalLifeCycleException - if a problem occurs.

setFcStopped

public boolean setFcStopped()
Description copied from interface: LifeCycleCoordinator
Sets the state of this component, but not of its sub components, to STOPPED. Because of component sharing, the stopFc method cannot be implemented by just calling itself recursively on the sub components of this componets (otherwise some sub components may be stopped several times). Hence this method.

Specified by:
setFcStopped in interface LifeCycleCoordinator
Returns:
true if the execution state has changed, or false if it had already the STOPPED value.

getFcLifeCycleControllers

public LifeCycleCoordinator[] getFcLifeCycleControllers(Component id)
                                                 throws IllegalLifeCycleException
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 LifeCycleCoordinator interface, as well as the primitive client components of these components.

Parameters:
id - a composite component.
Returns:
the components that must be stopped in order to stop the given component.
Throws:
IllegalLifeCycleException - if a problem occurs.

getFcInternalLifeCycleControllers

public List getFcInternalLifeCycleControllers()
                                       throws IllegalLifeCycleException
Throws:
IllegalLifeCycleException

_this_setFcState

public abstract void _this_setFcState(boolean started)
                               throws IllegalLifeCycleException
The setFcState method required by this mixin. This method is supposed to work as this setFcState method.

Parameters:
started - true to set the lifecycle state of the components to STARTED, or false to set this state to STOPPED.
Throws:
IllegalLifeCycleException - if a problem occurs.

_this_stopFc

public abstract void _this_stopFc(LifeCycleCoordinator[] components)
                           throws IllegalLifeCycleException
The stopFc method required by this mixin. This method is supposed to work as this stopFc method.

Parameters:
components - the LifeCycleCoordinator interface of the components to be stopped.
Throws:
IllegalLifeCycleException - if a problem occurs.