|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.fulcrum.factory.DefaultFactoryService
public class DefaultFactoryService
The Factory Service instantiates objects using specified class loaders. If none is specified, the default one will be used.
Field Summary | |
---|---|
protected static String |
DEFAULT_FACTORY
The name of the default factory. |
protected boolean |
initialized
|
Fields inherited from interface org.apache.fulcrum.factory.FactoryService |
---|
ROLE |
Constructor Summary | |
---|---|
DefaultFactoryService()
|
Method Summary | |
---|---|
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
Avalon component lifecycle method |
protected Factory |
getFactory(String className)
Gets a customized factory for a named class. |
Object |
getInstance(Class clazz)
Gets an instance of a specified class. |
protected Object |
getInstance(Class clazz,
Object[] params,
String[] signature)
Gets an instance of a specified class. |
Object |
getInstance(String className)
Gets an instance of a named class. |
Object |
getInstance(String className,
ClassLoader loader)
Gets an instance of a named class using a specified class loader. |
Object |
getInstance(String className,
ClassLoader loader,
Object[] params,
String[] signature)
Gets an instance of a named class using a specified class loader. |
Object |
getInstance(String className,
Object[] params,
String[] signature)
Gets an instance of a named class. |
protected static Class |
getPrimitiveClass(String type)
Gets the class of a primitive type. |
Class[] |
getSignature(Class clazz,
Object[] params,
String[] signature)
Gets the signature classes for parameters of a method of a class. |
void |
initialize()
Avalon component lifecycle method Initializes the service by loading default class loaders and customized object factories. |
boolean |
isLoaderSupported(String className)
Tests if specified class loaders are supported for a named class. |
protected Class |
loadClass(String className)
Loads the named class using the default class loader. |
protected Class |
loadClass(String className,
ClassLoader loader)
Loads the named class using a specified class loader. |
protected Object |
switchObjectContext(Object object,
ClassLoader loader)
Switches an object into the context of a different class loader. |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean initialized
protected static final String DEFAULT_FACTORY
Constructor Detail |
---|
public DefaultFactoryService()
Method Detail |
---|
protected static Class getPrimitiveClass(String type)
type
- a primitive type.
public Object getInstance(String className) throws FactoryException
getInstance
in interface FactoryService
className
- the name of the class.
FactoryException
- if instantiation fails.public Object getInstance(String className, ClassLoader loader) throws FactoryException
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.
FactoryException
- if instantiation fails.public Object getInstance(String className, Object[] params, String[] signature) throws FactoryException
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.
FactoryException
- if instantiation fails.public Object getInstance(String className, ClassLoader loader, Object[] params, String[] signature) throws FactoryException
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.
FactoryException
- if instantiation fails.public boolean isLoaderSupported(String className) throws FactoryException
isLoaderSupported
in interface FactoryService
className
- the name of the class.
FactoryException
- if test fails.public Object getInstance(Class clazz) throws FactoryException
getInstance
in interface FactoryService
clazz
- the class.
FactoryException
- if instantiation fails.protected Object getInstance(Class clazz, Object[] params, String[] signature) throws FactoryException
clazz
- the class.params
- an array containing the parameters of the constructor.signature
- an array containing the signature of the constructor.
FactoryException
- if instantiation fails.public Class[] getSignature(Class clazz, Object[] params, String[] signature) throws 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.
ClassNotFoundException
- if any of the classes is not found.protected Object switchObjectContext(Object object, ClassLoader loader)
object
- an object to switch.loader
- the loader of the new context.protected Class loadClass(String className) throws ClassNotFoundException
className
- the name of the class to load.
ClassNotFoundException
- if the class was not found.protected Class loadClass(String className, ClassLoader loader) throws ClassNotFoundException
className
- the name of the class to load.loader
- the loader to use.
ClassNotFoundException
- if the class was not found.protected Factory getFactory(String className) throws FactoryException
className
- the name of the class to load.
FactoryException
- if instantiation of the factory fails.public void configure(org.apache.avalon.framework.configuration.Configuration conf) throws org.apache.avalon.framework.configuration.ConfigurationException
configure
in interface org.apache.avalon.framework.configuration.Configurable
org.apache.avalon.framework.configuration.ConfigurationException
public void initialize() throws Exception
initialize
in interface org.apache.avalon.framework.activity.Initializable
InitializationException
- if initialization fails.
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |