org.objectweb.jonathan.libs.kernel.decoders

Class JImplicitFactory

Implemented Interfaces:
Component, Factory, Forkable, Initializer, MultiFactory

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(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(Object _obj, Context _c, int _alternative)
Implementation of the Initializer interface's initialize method.
Object
newObject(Context _c)
From Factory interface.
Object
newObject(Context _c, int _alternative, Instanciable _instance)
Returns a new instance of the implicit factory's implementation alternative whose ID is _alternative.
String
toString()

Methods inherited from class org.objectweb.jonathan.libs.kernel.JComponent

duplicate, fork, getComponent, getElement, getFactoryValue, getIntValue, getReference, getType, getValue, getValue, internalFork, reset, setReference, toString

Constructor Details

JImplicitFactory

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

Method Details

duplicate

public Component duplicate()
Creates a new implicit factory holding the same implementation alternatives.
Overrides:
duplicate in interface JComponent


initialize

public void initialize(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.


newObject

public 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 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.


toString

public String toString()
Overrides:
toString in interface JComponent