Package de.intarsys.tools.factory
Class FactoryTools
java.lang.Object
de.intarsys.tools.factory.FactoryTools
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IFactorylookupFactory(Class clazz) Lookup theIFactoryinstance for a factory class.static IFactorylookupFactory(String id, ClassLoader classLoader) Lookup theIFactoryinstance for an id.static IFactorylookupFactoryFor(Class clazz) Lookup theIFactoryinstance for target object class.
-
Constructor Details
-
FactoryTools
public FactoryTools()
-
-
Method Details
-
lookupFactory
Lookup theIFactoryinstance for a factory class. This tool method assumes theIFactoryinstance is registered with its class name.If no such
IFactoryis registered, this method tries to create and register a new one.If no
IFactoryis registered and can't be created, null is returned.- Parameters:
clazz-- Returns:
- the
IFactoryinstance for a factory class
-
lookupFactory
Lookup theIFactoryinstance for an id.If no such
IFactoryis registered, this method tries to create and register a new one by interpreting the id as a class name.If no
IFactoryis registered and can't be created, null is returned.- Parameters:
id-classLoader-- Returns:
- the
IFactoryinstance for an id.
-
lookupFactoryFor
Lookup theIFactoryinstance for target object class. This method tries to derive the factory by searching theIFactorywith appropriate types. If not available it tries to lookup anIFactoryby appending "Factory" to the clazz name and using it as an id.If no such
IFactoryis registered, this method tries to create and register a new one by interpreting the id as a class name.If no
IFactoryis registered and can't be created, null is returned.- Parameters:
clazz-- Returns:
- the
IFactoryinstance for target object class
-