|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.extex.framework.AbstractFactory
public abstract class AbstractFactory
This is the abstract base class for factories. It contains some common methods which should make it easy to create a custom factory.
The abstract factory supports utility events:
Configurable
then the
associated method is used to pass on the configuration to the new instance.
LogEnabled
then the associated
method is used to pass on the logger to the new instance.
Field Summary | |
---|---|
protected static java.lang.String |
CLASS_ATTRIBUTE
The constant CLASS_ATTRIBUTE contains the name of the attribute used to get the class name. |
protected static java.lang.String |
DEFAULT_ATTRIBUTE
The constant DEFAULT_ATTRIBUTE contains the name of the attribute used to get the default configuration. |
protected static java.lang.String |
SELECT_ATTRIBUTE
The constant SELECT_ATTRIBUTE contains the name of the attribute used to get the default configuration. |
Constructor Summary | |
---|---|
AbstractFactory()
Creates a new factory object. |
|
AbstractFactory(Configuration configuration)
Creates a new factory object. |
Method Summary | |
---|---|
void |
configure(Configuration configuration)
Configure an object according to a given Configuration. |
static void |
configure(java.lang.Object instance,
Configuration configuration)
Configure an instance if this instance supports configuration. |
protected java.lang.Object |
createInstance(java.lang.Class<?> target)
Get an instance. |
protected java.lang.Object |
createInstance(java.lang.Class<?> target,
java.lang.Object arg)
Get a new instance. |
protected java.lang.Object |
createInstance(java.lang.String type,
java.lang.Class<?> target)
Create a new instance for a given configuration with an additional argument for the constructor. |
protected java.lang.Object |
createInstance(java.lang.String type,
java.lang.Class<?> target,
java.lang.Class<?> argClass,
java.lang.Object arg)
Create a new instance for a given configuration with an additional argument for the constructor. |
protected java.lang.Object |
createInstanceForConfiguration(Configuration config,
java.lang.Class<?> target)
Create a new instance for a given configuration. |
protected java.lang.Object |
createInstanceForConfiguration(Configuration config,
java.lang.Class<?> target,
java.lang.Class<?> argClass,
java.lang.Object arg)
Create a new instance for a given configuration with an additional argument for the constructor. |
protected java.lang.Object |
createInstanceForConfiguration(Configuration config,
java.lang.Class<?> target,
java.lang.Object arg)
Create a new instance for a given configuration. |
void |
enableLogging(java.util.logging.Logger theLogger)
Setter for the logger. |
static void |
enableLogging(java.lang.Object instance,
java.util.logging.Logger logger)
Utility method to pass a logger to an object if it has a method to take it. |
Configuration |
getConfiguration()
Getter for configuration. |
java.util.logging.Logger |
getLogger()
Getter for logger. |
ResourceFinder |
getResourceFinder()
Getter for resourceFinder. |
java.lang.Object |
reconnect(java.lang.Object instance)
Reconnect an object. |
protected Configuration |
selectConfiguration(java.lang.String type)
Select a sub-configuration with a given name. |
void |
setResourceFinder(ResourceFinder finder)
Setter for the resource finder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String CLASS_ATTRIBUTE
protected static final java.lang.String DEFAULT_ATTRIBUTE
protected static final java.lang.String SELECT_ATTRIBUTE
Constructor Detail |
---|
public AbstractFactory()
public AbstractFactory(Configuration configuration)
configuration
- the configuration object to considerMethod Detail |
---|
public static void configure(java.lang.Object instance, Configuration configuration) throws ConfigurationException
instance
- the instance to configureconfiguration
- the configuration to use. If this parameter is
null
then it is not passed to the instance.
ConfigurationException
- in case of an errorpublic static void enableLogging(java.lang.Object instance, java.util.logging.Logger logger)
null
then this method simply does
nothing.
instance
- the instance to pass the logger tologger
- the logger to pass. If the logger is null
then nothing is done.public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configuration
- the configuration object to consider
ConfigurationException
- in case that something went wrongConfigurable.configure(
org.extex.framework.configuration.Configuration)
protected java.lang.Object createInstance(java.lang.Class<?> target) throws ConfigurationException
target
- the expected class or interface
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstance(java.lang.Class<?> target, java.lang.Object arg) throws ConfigurationException
null
or the empty string then the default from
the configuration is used.
target
- the expected class or interfacearg
- the argument for the constructor
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstance(java.lang.String type, java.lang.Class<?> target) throws ConfigurationException
type
- the type to usetarget
- the expected class or interface
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstance(java.lang.String type, java.lang.Class<?> target, java.lang.Class<?> argClass, java.lang.Object arg) throws ConfigurationException
type
- the type to usetarget
- the expected class or interfaceargClass
- the class of the argumentarg
- the argument
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstanceForConfiguration(Configuration config, java.lang.Class<?> target) throws ConfigurationException
config
- the configuration to usetarget
- the expected class or interface
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstanceForConfiguration(Configuration config, java.lang.Class<?> target, java.lang.Class<?> argClass, java.lang.Object arg) throws ConfigurationException
config
- the configuration to usetarget
- the expected class or interfaceargClass
- the class of the argumentarg
- the argument
ConfigurationException
- in case of an configuration errorprotected java.lang.Object createInstanceForConfiguration(Configuration config, java.lang.Class<?> target, java.lang.Object arg) throws ConfigurationException
config
- the configuration to usetarget
- the expected class or interfacearg
- the constructor argument
ConfigurationException
- in case of an configuration errorpublic void enableLogging(java.util.logging.Logger theLogger)
LogEnabled
enableLogging
in interface LogEnabled
theLogger
- the logger to useLogEnabled.enableLogging(
java.util.logging.Logger)
public Configuration getConfiguration()
public java.util.logging.Logger getLogger()
public ResourceFinder getResourceFinder()
public java.lang.Object reconnect(java.lang.Object instance) throws RegistrarException
RegistrarObserver
reconnect
in interface RegistrarObserver
instance
- the object to reconnect
RegistrarException
- in case of an error during configurationRegistrarObserver.reconnect(java.lang.Object)
protected Configuration selectConfiguration(java.lang.String type) throws ConfigurationException
type
- the tag name for the sub-configuration to find
ConfigurationException
- in case of an errorpublic void setResourceFinder(ResourceFinder finder)
setResourceFinder
in interface ResourceAware
finder
- the resource finderResourceAware.setResourceFinder(
org.extex.resource.ResourceFinder)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |