public class FactoryTools extends Object
| Constructor and Description |
|---|
FactoryTools() |
| Modifier and Type | Method and Description |
|---|---|
static IFactory |
createFactory(Object value,
Object defaultValue)
Create an
IFactory from an object. |
static <T extends IFactory<?>> |
lookupFactory(Class<T> clazz)
Lookup the
IFactory instance for a factory class. |
static IFactory<?> |
lookupFactory(String id,
ClassLoader classLoader)
Lookup the
IFactory instance for an id. |
static <T> IFactory<T> |
lookupFactoryFor(Class<T> clazz)
Lookup the
IFactory instance for target clazz. |
public static IFactory createFactory(Object value, Object defaultValue) throws ObjectCreationException
IFactory from an object.object - defaultValue - The default value to be usedIFactoryObjectCreationExceptionpublic static <T extends IFactory<?>> T lookupFactory(Class<T> clazz)
IFactory instance for a factory class. This tool
method assumes the IFactory instance is registered with its class
name.
If no such IFactory is registered, this method tries to create
and register a new one.
If no IFactory is registered and can't be created, null is
returned.
clazz - IFactory instance for a factory classpublic static IFactory<?> lookupFactory(String id, ClassLoader classLoader)
IFactory instance for an id.
If no such IFactory is registered, this method tries to create
and register a new one by interpreting the id as a class name. First we
check if id represents an IFactory implementation itself, if this
fails a generic IFactory creating instances of type "id" is
built.
If no IFactory is registered and can't be created, null is
returned.
id - classLoader - IFactory instance for an id.public static <T> IFactory<T> lookupFactoryFor(Class<T> clazz)
IFactory instance for target clazz. This method tries
to derive the factory by searching the IFactory with appropriate
types. If not available it tries to lookup an IFactory by
appending "Factory" to the clazz name and using it as an id.
If no such IFactory is registered, this method tries to create
and register a new one by interpreting the id as a class name.
If no IFactory is registered and can't be created, null is
returned.
clazz - IFactory instance for target object classCopyright © 2013 intarsys consulting GmbH. All Rights Reserved.