|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.services.BaseInitable
org.apache.turbine.services.BaseService
org.apache.turbine.services.TurbineBaseService
org.apache.turbine.services.factory.TurbineFactoryService
The Factory Service instantiates objects using specified class loaders. If none is specified, the default one will be used.
Field Summary | |
static java.lang.String |
CLASS_LOADERS
The property specifying a set of additional class loaders. |
static java.lang.String |
OBJECT_FACTORY
The property prefix specifying additional object factories. |
Fields inherited from class org.apache.turbine.services.BaseService |
configuration, name, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.factory.FactoryService |
SERVICE_NAME |
Constructor Summary | |
TurbineFactoryService()
Constructs a Factory Service. |
Method Summary | |
protected Factory |
getFactory(java.lang.String className)
Gets a customized factory for a named class. |
protected java.lang.Object |
getInstance(java.lang.Class clazz)
Gets an instance of a specified class. |
protected java.lang.Object |
getInstance(java.lang.Class clazz,
java.lang.Object[] params,
java.lang.String[] signature)
Gets an instance of a specified class. |
java.lang.Object |
getInstance(java.lang.String className)
Gets an instance of a named class. |
java.lang.Object |
getInstance(java.lang.String className,
java.lang.ClassLoader loader)
Gets an instance of a named class using a specified class loader. |
java.lang.Object |
getInstance(java.lang.String className,
java.lang.ClassLoader loader,
java.lang.Object[] params,
java.lang.String[] signature)
Gets an instance of a named class using a specified class loader. |
java.lang.Object |
getInstance(java.lang.String className,
java.lang.Object[] params,
java.lang.String[] signature)
Gets an instance of a named class. |
protected static java.lang.Class |
getPrimitiveClass(java.lang.String type)
Gets the class of a primitive type. |
java.lang.Class[] |
getSignature(java.lang.Class clazz,
java.lang.Object[] params,
java.lang.String[] signature)
Gets the signature classes for parameters of a method of a class. |
void |
init()
Initializes the service by loading default class loaders and customized object factories. |
boolean |
isLoaderSupported(java.lang.String className)
Tests if specified class loaders are supported for a named class. |
protected java.lang.Class |
loadClass(java.lang.String className)
Loads the named class using the default class loader. |
protected java.lang.Class |
loadClass(java.lang.String className,
java.lang.ClassLoader loader)
Loads the named class using a specified class loader. |
protected java.lang.Object |
switchObjectContext(java.lang.Object object,
java.lang.ClassLoader loader)
Switches an object into the context of a different class loader. |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
init, init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.turbine.services.Service |
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker, shutdown |
Field Detail |
public static final java.lang.String CLASS_LOADERS
public static final java.lang.String OBJECT_FACTORY
Constructor Detail |
public TurbineFactoryService()
Method Detail |
protected static java.lang.Class getPrimitiveClass(java.lang.String type)
type
- a primitive type.
public void init() throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
InitializationException
- if initialization fails.public java.lang.Object getInstance(java.lang.String className) throws TurbineException
getInstance
in interface FactoryService
className
- the name of the class.
TurbineException
- if instantiation fails.public java.lang.Object getInstance(java.lang.String className, java.lang.ClassLoader loader) throws TurbineException
Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.
getInstance
in interface FactoryService
className
- the name of the class.loader
- the class loader.
TurbineException
- if instantiation fails.public java.lang.Object getInstance(java.lang.String className, java.lang.Object[] params, java.lang.String[] signature) throws TurbineException
getInstance
in interface FactoryService
className
- the name of the class.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
TurbineException
- if instantiation fails.public java.lang.Object getInstance(java.lang.String className, java.lang.ClassLoader loader, java.lang.Object[] params, java.lang.String[] signature) throws TurbineException
Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.
getInstance
in interface FactoryService
className
- the name of the class.loader
- the class loader.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
TurbineException
- if instantiation fails.public boolean isLoaderSupported(java.lang.String className) throws TurbineException
isLoaderSupported
in interface FactoryService
className
- the name of the class.
TurbineException
- if test fails.protected java.lang.Object getInstance(java.lang.Class clazz) throws TurbineException
clazz
- the class.
TurbineException
- if instantiation fails.protected java.lang.Object getInstance(java.lang.Class clazz, java.lang.Object[] params, java.lang.String[] signature) throws TurbineException
clazz
- the class.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
TurbineException
- if instantiation fails.public java.lang.Class[] getSignature(java.lang.Class clazz, java.lang.Object[] params, java.lang.String[] signature) throws java.lang.ClassNotFoundException
getSignature
in interface FactoryService
clazz
- the class.params
- an array containing the parameters of the method.signature
- an array containing the signature of the method.
java.lang.ClassNotFoundException
- if any of the classes is not found.protected java.lang.Object switchObjectContext(java.lang.Object object, java.lang.ClassLoader loader)
object
- an object to switch.loader
- the loader of the new context.protected java.lang.Class loadClass(java.lang.String className) throws java.lang.ClassNotFoundException
className
- the name of the class to load.
java.lang.ClassNotFoundException
- if the class was not found.protected java.lang.Class loadClass(java.lang.String className, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundException
className
- the name of the class to load.loader
- the loader to use.
java.lang.ClassNotFoundException
- if the class was not found.protected Factory getFactory(java.lang.String className) throws TurbineException
className
- the name of the class to load.
TurbineException
- if instantiation of the factory fails.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |