org.objectweb.dream.control.lifecycle
Class ThreadCounterMixin

java.lang.Object
  extended by org.objectweb.dream.control.lifecycle.ThreadCounterMixin
All Implemented Interfaces:
LifeCycleController, LifeCycleCoordinator

public abstract class ThreadCounterMixin
extends Object
implements LifeCycleCoordinator

Life cycle mixin to be used with interceptor generated by LifeCycleInterceptorGenerator.

Requirements


Field Summary
 Component _this_weaveableC
          The weaveableC field required by this mixin.
 int _this_weaveableFcState
          the weaveableFcState field reqired by this mixin.
 Logger _this_weaveableLCCLogger
          The weaveableLCCLogger field required by this mixin.
protected  LifeCycleCoordinator fcCoordinator
           
protected  Thread[] fcExecutingThreads
          The array of currently executing threads.
protected  int[] fcInvocationCounters
          The array of the invocation counter for each threads.
protected  int fcNbExcutingThread
          The number of currently executing thread
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Constructor Summary
ThreadCounterMixin()
           
 
Method Summary
abstract  boolean _super_checkInactivity()
          The checkInactivity method overriden by this mixin.
abstract  void _super_initFcController(InitializationContext ic)
          The Controller.initFcController(org.objectweb.fractal.julia.InitializationContext)method overriden by this mixin.
abstract  boolean _super_setFcStarted()
          The LifeCycleCoordinator.setFcStarted()method overriden by this mixin.
abstract  boolean _super_setFcStopped()
          The LifeCycleCoordinator.setFcStopped()method overriden by this mixin.
abstract  LifeCycleCoordinator _this_getFcCoordinator()
          The getFcCoordinator method overriden by this mixin.
abstract  boolean _this_isInactivated(LifeCycleCoordinator coordinator)
          The isInactivated method used by this mixin.
 int addCurrentThread(String s)
          Registers the current thread has an executing thread.
 boolean checkInactivity()
          Returns true If the component is stopping, and no more thread is executing it and super implementation returns true.
 void initFcController(InitializationContext ic)
           
 int registerCurrentThread()
          Registers the current thread.
 void removeCurrentThread(String s, int i)
          Unregister the current thread.
 boolean setFcStarted()
           
 boolean setFcStopped()
           
 void setFcStopping(LifeCycleCoordinator coordinator)
           
 void unregisterCurrentThread(int i)
          Unregisters current thread.
 
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
 
Methods inherited from interface org.objectweb.fractal.api.control.LifeCycleController
getFcState, startFc, stopFc
 

Field Detail

fcExecutingThreads

protected Thread[] fcExecutingThreads
The array of currently executing threads.


fcInvocationCounters

protected int[] fcInvocationCounters
The array of the invocation counter for each threads.


fcNbExcutingThread

protected int fcNbExcutingThread
The number of currently executing thread


fcCoordinator

protected LifeCycleCoordinator fcCoordinator

_this_weaveableC

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


_this_weaveableFcState

public int _this_weaveableFcState
the weaveableFcState field reqired by this mixin. This field is supposed to reference the current state of the component lifecycle.

See Also:
SimpleLifeCycleControllerMixin.weaveableFcState

_this_weaveableLCCLogger

public Logger _this_weaveableLCCLogger
The weaveableLCCLogger field required by this mixin. This field is supposed to reference the Loggerof this controller.

Constructor Detail

ThreadCounterMixin

public ThreadCounterMixin()
Method Detail

initFcController

public void initFcController(InitializationContext ic)
                      throws InstantiationException
Throws:
InstantiationException
See Also:
Controller.initFcController(InitializationContext)

setFcStarted

public boolean setFcStarted()
                     throws IllegalLifeCycleException
Specified by:
setFcStarted in interface LifeCycleCoordinator
Throws:
IllegalLifeCycleException
See Also:
LifeCycleCoordinator.setFcStarted()

setFcStopping

public void setFcStopping(LifeCycleCoordinator coordinator)
                   throws IllegalLifeCycleException
Specified by:
setFcStopping in interface LifeCycleCoordinator
Throws:
IllegalLifeCycleException
See Also:
LifeCycleCoordinator.setFcStopping(LifeCycleCoordinator)

setFcStopped

public boolean setFcStopped()
                     throws IllegalLifeCycleException
Specified by:
setFcStopped in interface LifeCycleCoordinator
Throws:
IllegalLifeCycleException
See Also:
LifeCycleCoordinator.setFcStopped()

addCurrentThread

public int addCurrentThread(String s)
Registers the current thread has an executing thread. If it is already registered, increments it counter. If the component is started this method just registers the current thread. If the component is stopped, it waits until the component is restarted, ant then registers the current thread. Finally if the component is stopping, threr are two cases. If no thread is executing the component, this method asks the coordinator if the method call can be executed, or if it should be delayed until the component is restarted. The method then blocks or not, depending on the coordinator's response, before registering the current thread.

Parameters:
s - not used.
Returns:
the index of the current thread in the array of executing threads. This value is passed to the removeCurrentThread(String, int)to executing thread.

removeCurrentThread

public void removeCurrentThread(String s,
                                int i)
Unregister the current thread. Finally if the component is stoping, there are two cases. If the component is stopping, and no more thread is executing it, this method notifies the coordinator that the component has become inactive.

Parameters:
s - not used.
i - the index of the current thread in the array of executing threads.

registerCurrentThread

public int registerCurrentThread()
Registers the current thread.

Returns:
the index of the current thread in the array of executing threads.

unregisterCurrentThread

public void unregisterCurrentThread(int i)
Unregisters current thread.

Parameters:
i - the index of the current thread in the array of executing threads.

checkInactivity

public boolean checkInactivity()
Returns true If the component is stopping, and no more thread is executing it and super implementation returns true.

Returns:
true If the component is inactive

_super_setFcStarted

public abstract boolean _super_setFcStarted()
                                     throws IllegalLifeCycleException
The LifeCycleCoordinator.setFcStarted()method overriden by this mixin.

Throws:
IllegalLifeCycleException
See Also:
LifeCycleCoordinator.setFcStarted()

_super_setFcStopped

public abstract boolean _super_setFcStopped()
                                     throws IllegalLifeCycleException
The LifeCycleCoordinator.setFcStopped()method overriden by this mixin.

Throws:
IllegalLifeCycleException
See Also:
LifeCycleCoordinator.setFcStopped()

_super_checkInactivity

public abstract boolean _super_checkInactivity()
The checkInactivity method overriden by this mixin. This method is supposed to work as this SimpleLifeCycleControllerMixin.checkInactivity()method.

See Also:
SimpleLifeCycleControllerMixin.checkInactivity()

_this_getFcCoordinator

public abstract LifeCycleCoordinator _this_getFcCoordinator()
The getFcCoordinator method overriden by this mixin. This method is supposed to work as this SimpleLifeCycleControllerMixin.getFcCoordinator()method.

See Also:
SimpleLifeCycleControllerMixin.getFcCoordinator()

_this_isInactivated

public abstract boolean _this_isInactivated(LifeCycleCoordinator coordinator)
The isInactivated method used by this mixin. This method is supposed to work as this SimpleLifeCycleControllerMixin.isInactivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)method.

See Also:
SimpleLifeCycleControllerMixin.isInactivated(org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator)

_super_initFcController

public abstract void _super_initFcController(InitializationContext ic)
                                      throws InstantiationException
The Controller.initFcController(org.objectweb.fractal.julia.InitializationContext)method overriden by this mixin.

Throws:
InstantiationException
See Also:
Controller.initFcController(InitializationContext)


Copyright © 2003, 2005 - INRIA Rhone-Alpes - All Rights Reserved.