org.objectweb.jonathan.libs.kernel
Class GenericFactory
java.lang.Object
|
+--org.objectweb.jonathan.libs.kernel.GenericFactory
- All Implemented Interfaces:
- Factory
- Direct Known Subclasses:
- CDRMarshallerFactoryFactory, DavidServicesHandlerFactory, DavidTSHandlerFactory, EventChannelFactoryFactory, EventChannelFactoryFactory, GIOPConnectionFactoryFactory, IIOPORBFactory, IPv4ConnectionFactoryFactory, JChunkFactoryFactory, JConnectionMgrFactory, JDelegateFactoryFactory, JIOPFactory, JRMITSHandlerFactory, JSchedulerFactory, MOAContextFactory, MOAImplFactory, SOAContextFactory, SOAImplFactory, StdMarshallerFactoryFactory, UnknownExceptionServiceFactory
- public abstract class GenericFactory
- extends Object
- implements Factory
Generic Factory implementation.
This class provides a generic mechanism to use a pool of objects and let
already constructed objects be reused.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericFactory
public GenericFactory()
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.
- Specified by:
newObject in interface Factory
- Parameters:
_c - a Context object;- Returns:
- an object created using information contained in
context. - Throws:
JonathanException - if something goes wrong.
register
public void register(Object object,
Context _configuration)
- Registers an instance, using the provided components, in the factory.
- Parameters:
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.
getUsedComponents
protected abstract Object[] getUsedComponents(Context _c)
- Returns the components of the provided context that should be used to build
a new object instance.
- Parameters:
_c - a context;- Returns:
- the components of
_c that should be used to build a new
object
newInstance
protected abstract 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.
- Parameters:
_c - a context;_used_components - components to be used to create a new object;- Returns:
- a new object created using
_used_components; - Throws:
JonathanException - if something goes wrong.
newInstance
protected Object newInstance()
throws JonathanException
configure
protected void configure(Object _object,
Context _c,
Object[] _used_components)
throws JonathanException