org.objectweb.fractal.julia.control.lifecycle
Interface LifeCycleCoordinator

All Superinterfaces:
LifeCycleController
All Known Implementing Classes:
BasicLifeCycleControllerMixin, BasicLifeCycleCoordinatorMixin, ContainerLifeCycleMixin, LoggerLifeCycleMixin, OptimizedLifeCycleControllerMixin

public interface LifeCycleCoordinator
extends LifeCycleController

An extended LifeCycleController interface. This interface is used to stop several components simultaneously, in order to avoid the deadlocks that can occur when several components are stopped one by one (for example, if a component C is stopped after a component S, and if a thread T is executing a method m1 in C which calls a method m2 in S, then T can be blocked in m2 just after S is stopped but before C is stopped, in which case C can not be stopped, and a deadlock occurs).


Field Summary
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Method Summary
 boolean fcActivated(LifeCycleCoordinator component)
          Notifies this component that the given component is about to become active.
 void fcInactivated(LifeCycleCoordinator component)
          Notifies this component that the given component has become inactive.
 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".
 
Methods inherited from interface org.objectweb.fractal.api.control.LifeCycleController
getFcState, startFc, stopFc
 

Method Detail

setFcStarted

boolean setFcStarted()
                     throws IllegalLifeCycleException
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.

Returns:
true if the execution state has changed, or false if it had already the STARTED value.
Throws:
IllegalLifeCycleException - if a problem occurs.

setFcStopping

void setFcStopping(LifeCycleCoordinator coordinator)
                   throws IllegalLifeCycleException
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.

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

boolean setFcStopped()
                     throws IllegalLifeCycleException
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.

Returns:
true if the execution state has changed, or false if it had already the STOPPED value.
Throws:
IllegalLifeCycleException - if a problem occurs.

fcActivated

boolean fcActivated(LifeCycleCoordinator component)
Notifies this component that the given component is about to become active. This method must be called by a component when the following conditions are met:

Parameters:
component - the LifeCycleCoordinator interface of a component that is about to become active.
Returns:
true if the given component can become active, or false if the new activity must be delayed until the component is restarted.

fcInactivated

void fcInactivated(LifeCycleCoordinator component)
Notifies this component that the given component has become inactive. This method must be called by a component when the following conditions are met:

Parameters:
component - the LifeCycleCoordinator interface of a component that has become inactive.