Constructor and Description |
---|
GenericFactory() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(java.lang.Object _object,
Context _c,
java.lang.Object[] _used_components) |
protected abstract java.lang.Object[] |
getUsedComponents(Context _c)
Returns the components of the provided context that should be used to build
a new object instance.
|
protected java.lang.Object |
newInstance() |
protected abstract java.lang.Object |
newInstance(Context _c,
java.lang.Object[] _used_components)
Returns a new object created using the provided components, and possibly
some information contained in the provided context.
|
java.lang.Object |
newObject(Context _c)
Returns an object created using information contained in the provided
context . |
void |
register(java.lang.Object object,
Context _configuration)
Registers an instance, using the provided components, in the factory.
|
public java.lang.Object newObject(Context _c) throws JonathanException
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;context
.JonathanException
- if something goes wrong.public void register(java.lang.Object object, Context _configuration)
object
- the instance of an object that could have been created by
the target factory;used_components
- the components is used to create the object.protected abstract java.lang.Object[] getUsedComponents(Context _c)
_c
- a context;_c
that should be used to build a new
objectprotected abstract java.lang.Object newInstance(Context _c, java.lang.Object[] _used_components) throws JonathanException
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;_used_components
;JonathanException
- if something goes wrong.protected java.lang.Object newInstance() throws JonathanException
JonathanException
protected void configure(java.lang.Object _object, Context _c, java.lang.Object[] _used_components) throws JonathanException
JonathanException