| org.apache.turbine.services.TurbineBaseService org.apache.turbine.services.factory.TurbineFactoryService
TurbineFactoryService | public class TurbineFactoryService extends TurbineBaseService implements FactoryService(Code) | | The Factory Service instantiates objects using specified
class loaders. If none is specified, the default one
will be used.
author: Ilkka Priha version: $Id: TurbineFactoryService.java 534527 2007-05-02 16:10:59Z tv $ |
Field Summary | |
final public static String | CLASS_LOADERS The property specifying a set of additional class loaders. | final public static String | OBJECT_FACTORY The property prefix specifying additional object factories. |
Method Summary | |
protected Factory | getFactory(String className) Gets a customized factory for a named class.
Parameters: className - the name of the class to load. | public Object | getInstance(String className) Gets an instance of a named class.
Parameters: className - the name of the class. | public Object | getInstance(String className, ClassLoader loader) Gets an instance of a named class using a specified class loader.
Class loaders are supported only if the isLoaderSupported
method returns true. | public Object | getInstance(String className, Object[] params, String[] signature) Gets an instance of a named class.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Parameters: className - the name of the class. Parameters: params - an array containing the parameters of the constructor. Parameters: signature - an array containing the signature of the constructor. | public Object | getInstance(String className, ClassLoader loader, Object[] params, String[] signature) Gets an instance of a named class using a specified class loader.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Class loaders are supported only if the isLoaderSupported
method returns true. | protected Object | getInstance(Class clazz) Gets an instance of a specified class.
Parameters: clazz - the class. | protected Object | getInstance(Class clazz, Object params, String signature) Gets an instance of a specified class.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Parameters: clazz - the class. Parameters: params - an array containing the parameters of the constructor. Parameters: signature - an array containing the signature of the constructor. | protected static Class | getPrimitiveClass(String type) Gets the class of a primitive type.
Parameters: type - a primitive type. | public Class[] | getSignature(Class clazz, Object params, String signature) Gets the signature classes for parameters of a method of a class.
Parameters: clazz - the class. Parameters: params - an array containing the parameters of the method. Parameters: signature - an array containing the signature of the method. | public void | init() Initializes the service by loading default class loaders
and customized object factories. | public boolean | isLoaderSupported(String className) Tests if specified class loaders are supported for a named class.
Parameters: className - the name of the class. | protected Class | loadClass(String className) Loads the named class using the default class loader.
Parameters: className - the name of the class to load. | protected Class | loadClass(String className, ClassLoader loader) Loads the named class using a specified class loader.
Parameters: className - the name of the class to load. Parameters: loader - the loader to use. | protected Object | switchObjectContext(Object object, ClassLoader loader) Switches an object into the context of a different class loader. |
CLASS_LOADERS | final public static String CLASS_LOADERS(Code) | | The property specifying a set of additional class loaders.
|
OBJECT_FACTORY | final public static String OBJECT_FACTORY(Code) | | The property prefix specifying additional object factories.
|
TurbineFactoryService | public TurbineFactoryService()(Code) | | Constructs a Factory Service.
|
getFactory | protected Factory getFactory(String className) throws TurbineException(Code) | | Gets a customized factory for a named class.
Parameters: className - the name of the class to load. the factory or null if not specified. throws: TurbineException - if instantiation of the factory fails. |
getInstance | public Object getInstance(String className, ClassLoader loader) throws TurbineException(Code) | | Gets an instance of a named class using a specified class loader.
Class loaders are supported only if the isLoaderSupported
method returns true. Otherwise the loader parameter is ignored.
Parameters: className - the name of the class. Parameters: loader - the class loader. the instance. throws: TurbineException - if instantiation fails. |
getInstance | public Object getInstance(String className, Object[] params, String[] signature) throws TurbineException(Code) | | Gets an instance of a named class.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Parameters: className - the name of the class. Parameters: params - an array containing the parameters of the constructor. Parameters: signature - an array containing the signature of the constructor. the instance. throws: TurbineException - if instantiation fails. |
getInstance | public Object getInstance(String className, ClassLoader loader, Object[] params, String[] signature) throws TurbineException(Code) | | Gets an instance of a named class using a specified class loader.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Class loaders are supported only if the isLoaderSupported
method returns true. Otherwise the loader parameter is ignored.
Parameters: className - the name of the class. Parameters: loader - the class loader. Parameters: params - an array containing the parameters of the constructor. Parameters: signature - an array containing the signature of the constructor. the instance. throws: TurbineException - if instantiation fails. |
getInstance | protected Object getInstance(Class clazz, Object params, String signature) throws TurbineException(Code) | | Gets an instance of a specified class.
Parameters for its constructor are given as an array of objects,
primitive types must be wrapped with a corresponding class.
Parameters: clazz - the class. Parameters: params - an array containing the parameters of the constructor. Parameters: signature - an array containing the signature of the constructor. the instance. throws: TurbineException - if instantiation fails. |
getPrimitiveClass | protected static Class getPrimitiveClass(String type)(Code) | | Gets the class of a primitive type.
Parameters: type - a primitive type. the corresponding class, or null. |
getSignature | public Class[] getSignature(Class clazz, Object params, String signature) throws ClassNotFoundException(Code) | | Gets the signature classes for parameters of a method of a class.
Parameters: clazz - the class. Parameters: params - an array containing the parameters of the method. Parameters: signature - an array containing the signature of the method. an array of signature classes. Note that in some casesobjects in the parameter array can be switched to the contextof a different class loader. throws: ClassNotFoundException - if any of the classes is not found. |
isLoaderSupported | public boolean isLoaderSupported(String className) throws TurbineException(Code) | | Tests if specified class loaders are supported for a named class.
Parameters: className - the name of the class. true if class loaders are supported, false otherwise. throws: TurbineException - if test fails. |
switchObjectContext | protected Object switchObjectContext(Object object, ClassLoader loader)(Code) | | Switches an object into the context of a different class loader.
Parameters: object - an object to switch. Parameters: loader - the loader of the new context. |
|
|