Package de.intarsys.tools.factory
Class FactoryTools
java.lang.Object
de.intarsys.tools.factory.FactoryTools
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IFactory
lookupFactory
(Class clazz) Lookup theIFactory
instance for a factory class.static IFactory
lookupFactory
(String id, ClassLoader classLoader) Lookup theIFactory
instance for an id.static IFactory
lookupFactoryFor
(Class clazz) Lookup theIFactory
instance for target object class.
-
Constructor Details
-
FactoryTools
public FactoryTools()
-
-
Method Details
-
lookupFactory
Lookup theIFactory
instance for a factory class. This tool method assumes theIFactory
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.- Parameters:
clazz
-- Returns:
- the
IFactory
instance for a factory class
-
lookupFactory
Lookup theIFactory
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.If no
IFactory
is registered and can't be created, null is returned.- Parameters:
id
-classLoader
-- Returns:
- the
IFactory
instance for an id.
-
lookupFactoryFor
Lookup theIFactory
instance for target object class. This method tries to derive the factory by searching theIFactory
with appropriate types. If not available it tries to lookup anIFactory
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.- Parameters:
clazz
-- Returns:
- the
IFactory
instance for target object class
-