| |
|
| java.lang.Object jcckit.util.Factory
Factory | public class Factory (Code) | | General purpose factory method based on
ConfigParameters and Java's Reflection API.
author: Franz-Josef Elmer |
Method Summary | |
public static Object | create(String className) Creates an instance of the specified class.
Parameters: className - Fully-qualified name of a class with a default constructor. | public static Object | create(ConfigParameters configParameters) Creates an object based on the specified configuration
parameters. | public static Object | create(ConfigParameters configParameters, String defaultClassName) Creates an object based on the specified configuration
parameters and default class name. | public static Object | createOrGet(ConfigParameters configParameters, Object defaultObject) Creates an object based on the specified configuration
parameters or returns the default object. |
CLASS_NAME_KEY | final public static String CLASS_NAME_KEY(Code) | | The constant defining the key className.
|
create | public static Object create(String className)(Code) | | Creates an instance of the specified class.
Parameters: className - Fully-qualified name of a class with a default constructor. a new instance. throws: IllegalArgumentException - if the instance could be created. |
create | public static Object create(ConfigParameters configParameters)(Code) | | Creates an object based on the specified configuration
parameters. The class of the object is determined by the
parameter with the key
Factory.CLASS_NAME_KEY .
The constructor with a single argument of the type
ConfigParameter is invoked with the argument
configParameters. If such a constructor
does not exists the default constructor is invoked. If
neither of these constructors exist a
FactoryException is thrown.
Parameters: configParameters - Configuration parameters. the newly created object. throws: IllegalArgumentException - if key className is missing. throws: FactoryException - wrapping any kind of exception or error occured. |
createOrGet | public static Object createOrGet(ConfigParameters configParameters, Object defaultObject)(Code) | | Creates an object based on the specified configuration
parameters or returns the default object. This method behaves
as
Factory.create(jcckit.util.ConfigParameters) , except that is does
not throw an IllegalArgumentException if key className
is missing. Instead defaultObject is returned.
|
|
|
|