public abstract class BaseFactory extends Object implements Factory
reflectionStrategy(String, Class)
and ctorStrategy(String, Class)
) to produce objects.
This class caches the produced objects for the lifetime of this object.
Effectively this means the lifetime of the ICS object.Modifier and Type | Field and Description |
---|---|
protected COM.FutureTense.Interfaces.ICS |
ics |
protected static org.apache.commons.logging.Log |
LOG |
Constructor and Description |
---|
BaseFactory(COM.FutureTense.Interfaces.ICS ics) |
BaseFactory(COM.FutureTense.Interfaces.ICS ics,
Factory... roots) |
Modifier and Type | Method and Description |
---|---|
protected <T> T |
createFromMethod(String name,
Class<T> c,
Method m) |
COM.FutureTense.Interfaces.ICS |
createICS(COM.FutureTense.Interfaces.ICS ics) |
protected <T> T |
ctorStrategy(String name,
Class<T> c) |
protected Class<?>[] |
factoryClasses(COM.FutureTense.Interfaces.ICS ics)
Method to find classes to use for the producer methods.
|
<T> T |
getObject(String name,
Class<T> fieldType) |
protected Object |
invokeCreateMethod(Method m,
Object from,
String name,
Object... arguments) |
protected <T> T |
locate(String askedName,
Class<T> c)
Internal method to check for Services or create Services.
|
protected <T> T |
namedAnnotationStrategy(String name,
Class<T> c)
Tries to create the object based on the
ServiceProducer
annotation where the names match. |
protected <T> T |
reflectionStrategy(String name,
Class<T> c)
Reflection based producer method.
|
protected boolean |
shouldCache(Method m) |
protected void |
throwRuntimeException(InvocationTargetException e) |
String |
toString() |
protected <T> T |
unnamedAnnotationStrategy(String name,
Class<T> c)
Tries to create the object based on the
ServiceProducer
annotation without a name. |
protected static final org.apache.commons.logging.Log LOG
protected final COM.FutureTense.Interfaces.ICS ics
public BaseFactory(COM.FutureTense.Interfaces.ICS ics)
public BaseFactory(COM.FutureTense.Interfaces.ICS ics, Factory... roots)
protected <T> T locate(String askedName, Class<T> c) throws InvocationTargetException
name
- c
- InvocationTargetException
protected Class<?>[] factoryClasses(COM.FutureTense.Interfaces.ICS ics)
Object.getClass()
. Subclasses can return and
are encouraged to return other classes.ics
- protected <T> T namedAnnotationStrategy(String name, Class<T> c) throws InvocationTargetException
ServiceProducer
annotation where the names match.name
- c
- InvocationTargetException
protected <T> T unnamedAnnotationStrategy(String name, Class<T> c) throws InvocationTargetException
ServiceProducer
annotation without a name.name
- c
- InvocationTargetException
protected <T> T reflectionStrategy(String name, Class<T> c) throws InvocationTargetException
ICS
and Factory
as
arguments. To this class the current ICS and this object will be passed.name
- the simple name of the object to producec
- the class with the type information of the object to produceInvocationTargetException
- when the create<Type> method
throws an exception.protected <T> T createFromMethod(String name, Class<T> c, Method m) throws InvocationTargetException
name
- name of the objectc
- the type of the object to createm
- the method to use to create the objectInvocationTargetException
protected Object invokeCreateMethod(Method m, Object from, String name, Object... arguments) throws InvocationTargetException
m
- method in invokefrom
- object to invoke fromname
- the name of the objectarguments
- the arguments to pass to the methodInvocationTargetException
protected boolean shouldCache(Method m)
protected void throwRuntimeException(InvocationTargetException e)
e
- protected <T> T ctorStrategy(String name, Class<T> c) throws InvocationTargetException
name
- c
- InvocationTargetException
public COM.FutureTense.Interfaces.ICS createICS(COM.FutureTense.Interfaces.ICS ics)
Copyright © 2010-2016 Oracle Corporation. All Rights Reserved.