org.objectweb.jonathan.libs.kernel
Class GenericFactory
java.lang.Object
org.objectweb.jonathan.libs.kernel.GenericFactory
- Factory
public abstract class GenericFactory
extends java.lang.Object
Generic
Factory
implementation.
This class provides a generic mechanism to use a pool of objects and let
already constructed objects be reused.
protected void | configure(Object _object, Context _c, Object[] _used_components)
|
protected Object[] | getUsedComponents(Context _c) - Returns the components of the provided context that should be used to build
a new object instance.
|
protected Object | newInstance()
|
protected Object | newInstance(Context _c, Object[] _used_components) - Returns a new object created using the provided components, and possibly
some information contained in the provided context.
|
Object | newObject(Context _c) - Returns an object created using information contained in the provided
context .
|
void | register(Object object, Context _configuration) - Registers an instance, using the provided components, in the factory.
|
getUsedComponents
protected Object[] getUsedComponents(Context _c)
Returns the components of the provided context that should be used to build
a new object instance.
_c
- a context;
- the components of
_c
that should be used to build a new
object
newInstance
protected Object newInstance(Context _c,
Object[] _used_components)
throws JonathanException
Returns a new object created using the provided components, and possibly
some information contained in the provided context.
The provided components must have been obtained using the
getUsedComponents
method.
_c
- a context;_used_components
- components to be used to create a new object;
- a new object created using
_used_components
;
JonathanException
- if something goes wrong.
newObject
public Object newObject(Context _c)
throws JonathanException
Returns an object created using information contained in the provided
context
.
This method first calls the
getUsedComponents()
method to retrieve the components that would be used
to create a new object. If an object has already been constructed using
the same components, it is returned. Otherwise, the
newInstance
method is called to create
a new object. Before being returned, the object is stored, so that it can be
reused in future calls.
- newObject in interface Factory
_c
- a Context
object;
- an object created using information contained in
context
.
JonathanException
- if something goes wrong.
register
public void register(Object object,
Context _configuration)
Registers an instance, using the provided components, in the factory.
object
- the instance of an object that could have been created by
the target factory;