org.objectweb.fractal.julia.logger
Class LoggerLifeCycleMixin

java.lang.Object
  extended by org.objectweb.fractal.julia.logger.LoggerLifeCycleMixin
All Implemented Interfaces:
LifeCycleController, LifeCycleCoordinator, Initializable

public abstract class LoggerLifeCycleMixin
extends Object
implements LifeCycleCoordinator, Initializable

Assigns a logger to a component during its startup. The topic name is based on the component path in the architecture. To use this mixin you have to add two lines in the julia.cfg configuration file:

 (lifecycle-controller-impl
   ((org.objectweb.fractal.julia.asm.MixinClassGenerator
     LifeCycleControllerImpl
     org.objectweb.fractal.julia.BasicControllerMixin
     org.objectweb.fractal.julia.UseComponentMixin
     org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleCoordinatorMixin
     org.objectweb.fractal.julia.control.lifecycle.BasicLifeCycleControllerMixin
     # to check that mandatory client interfaces are bound in startFc:
     org.objectweb.fractal.julia.control.lifecycle.TypeLifeCycleMixin
     # to automatically assign the logger and logger factory:
     org.objectweb.fractal.julia.BasicInitializableMixin
     org.objectweb.fractal.julia.logger.LoggerLifeCycleMixin
     # to notify the encapsulated component (if present) when its state changes:
     org.objectweb.fractal.julia.control.lifecycle.ContainerLifeCycleMixin
   )
     # optional initialization parameter (monolog configuration file name):
     (monolog-conf-file monolog.properties)
   )
 )
The user component must also implement either BindingController or Loggable. In the first case, the logger and logger factory can be retreived like this:
 public void bindFc (String s, Object o) {
   if ("logger".equals(s)) {
     myLogger = (Logger) o;
   } else if ("monolog-factory".equals(s)) { // optional
     String baseName = myLogger.getName();
     otherLogger1 = ((LoggerFactory) o).getLogger(baseName + ".toto");
     otherLogger2 = ((LoggerFactory) o).getLogger(baseName + ".titi");
   } else ...
 }
The other BindingController methods, and in particular the listFc method, must not take these logger "bindings" into account.

Author:
E.Bruneton, S.Chassande-Barrioz

Field Summary
 Component _this_weaveableC
          The weaveableC field required by this mixin.
 
Fields inherited from interface org.objectweb.fractal.api.control.LifeCycleController
STARTED, STOPPED
 
Method Summary
abstract  void _super_initialize(Tree args)
          The initialize method overriden by this mixin.
abstract  boolean _super_setFcStarted()
          The setFcStarted method overriden by this mixin.
 void initialize(Tree args)
          Initializes this object with the given arguments.
 boolean setFcStarted()
          Calls the overriden method and then sets the logger and logger factory of the user component encapsulated in this component (if there is one).
 
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, setFcStopped, setFcStopping
 
Methods inherited from interface org.objectweb.fractal.api.control.LifeCycleController
getFcState, startFc, stopFc
 

Field Detail

_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

initialize

public void initialize(Tree args)
                throws Exception
Description copied from interface: Initializable
Initializes this object with the given arguments.

Specified by:
initialize in interface Initializable
Parameters:
args - the arguments to be used to initialize this object. The format of these arguments depends on the class of this object.
Throws:
Exception - if a problem occurs during the object initialization.

setFcStarted

public boolean setFcStarted()
                     throws IllegalLifeCycleException
Calls the overriden method and then sets the logger and logger factory of the user component encapsulated in this component (if there is one).

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

_super_initialize

public abstract void _super_initialize(Tree args)
                                throws Exception
The initialize method overriden by this mixin.

Parameters:
args - the arguments to be used to initialize this object. The format of these arguments depends on the class of this object.
Throws:
Exception - if a problem occurs during the object initialization.

_super_setFcStarted

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

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