org.objectweb.jonathan.libs.kernel.decoders
Class JImplicitFactory

java.lang.Object
  extended by org.objectweb.jonathan.libs.kernel.JComponent
      extended by org.objectweb.jonathan.libs.kernel.decoders.JImplicitFactory
All Implemented Interfaces:
Component, Factory, Initializer, MultiFactory, Forkable

public class JImplicitFactory
extends JComponent
implements Factory, MultiFactory, Initializer

Runtime implicit factory component. Provides the basic behaviour of a MultiFactory: holds a set of implementation alternatives (given at the object's creation) and instantiates one of them, according to a given chosen alternative ID.


Field Summary
 
Fields inherited from class org.objectweb.jonathan.libs.kernel.JComponent
int_value, reference, type, value
 
Constructor Summary
JImplicitFactory(java.util.List _alternatives)
          Creates a new implicit factory whose implementation alternatives are listed in _alternatives as JAlternatives.
 
Method Summary
 Component duplicate()
          Creates a new implicit factory holding the same implementation alternatives.
 void initialize(java.lang.Object _obj, Context _c, int _alternative)
          Implementation of the Initializer interface's initialize method.
 java.lang.Object newObject(Context _c)
          From Factory interface.
 java.lang.Object newObject(Context _c, int _alternative, Instanciable _instance)
          Returns a new instance of the implicit factory's implementation alternative whose ID is _alternative.
 java.lang.String toString()
           
 
Methods inherited from class org.objectweb.jonathan.libs.kernel.JComponent
fork, getComponent, getElement, getFactoryValue, getIntValue, getReference, getType, getValue, getValue, internalFork, reset, setReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JImplicitFactory

public JImplicitFactory(java.util.List _alternatives)
Creates a new implicit factory whose implementation alternatives are listed in _alternatives as JAlternatives.

Method Detail

duplicate

public Component duplicate()
Creates a new implicit factory holding the same implementation alternatives.

Overrides:
duplicate in class JComponent

newObject

public java.lang.Object newObject(Context _c)
                           throws JonathanException
From Factory interface. Returns a new instance of the single alternative's implementation by calling its constructor; _c is the local Context containing the required instanciation parameters.

Specified by:
newObject in interface Factory
Parameters:
_c - contains the instanciation parameter
Returns:
an new instance of the implicit factory's single alternative
Throws:
JonathanException - if something goes wrong.

newObject

public java.lang.Object newObject(Context _c,
                                  int _alternative,
                                  Instanciable _instance)
                           throws JonathanException
Returns a new instance of the implicit factory's implementation alternative whose ID is _alternative. In the single implementation alternative case, it works only if the single alternative's ID is the given one (although newObject(Context) would do it anyway).

Specified by:
newObject in interface MultiFactory
Parameters:
_c - where the instanciation parameters are found
_alternative - the alternative to instantiate
_instance - the method's caller.
Returns:
an new _alternative's instance
Throws:
JonathanException - if something goes wrong.

initialize

public void initialize(java.lang.Object _obj,
                       Context _c,
                       int _alternative)
                throws JonathanException
Implementation of the Initializer interface's initialize method. Initializes an instance of the implicit factory's implementation alternative whose ID is _alternative by calling its setters. In the single implementation alternative case, it works only if the single alternative's ID is the given one (although initialize(Object,Context) would do it anyway).

Specified by:
initialize in interface Initializer
Parameters:
_obj - the object to initialize
_c - where the initialisation parameters are found
_alternative - the alternative to instantiate
Throws:
JonathanException - if something goes wrong.

toString

public java.lang.String toString()
Overrides:
toString in class JComponent