Keel 2.1RC2

org.apache.avalon.fortress.impl.handler
Class ComponentFactory

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
          extended byorg.apache.avalon.fortress.impl.handler.ComponentFactory
All Implemented Interfaces:
Instrumentable, LogEnabled, ObjectFactory

public final class ComponentFactory
extends AbstractLogEnabledInstrumentable
implements ObjectFactory

Factory for Avalon components.

Since:
4.0
Version:
CVS $Revision: 1.29 $ $Date: 2004/04/02 10:29:03 $
Author:

Nested Class Summary
protected  class ComponentFactory.ClassInfo
          This class collects all information about the components class: - the constructor to use
 
Field Summary
private  ComponentFactory.ClassInfo m_classinfo
          The class info for creating the component
private  java.lang.Class m_componentClass
          The class which this ComponentFactory should create.
private  Logger m_componentLogger
          The component's logger
private  Configuration m_configuration
          The configuration for this component.
private  Context m_context
          The Context for the component
private  CounterInstrument m_dispose
           
private  LifecycleExtensionManager m_extManager
          Lifecycle extensions manager
private  LoggerManager m_loggerManager
          The LogKitManager for child ComponentSelectors
private  CounterInstrument m_newInstance
           
private  ServiceManager m_serviceManager
          The component manager for this component.
private  boolean m_useDynamicCreation
          Use the dynamic configuration
 
Fields inherited from class org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
 
Fields inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
 
Fields inherited from interface org.apache.excalibur.mpool.ObjectFactory
ROLE
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
ComponentFactory(java.lang.Class componentClass, Configuration configuration, ServiceManager serviceManager, Context context, LoggerManager loggerManager, LifecycleExtensionManager extManager)
          Construct a new component factory for the specified component.
 
Method Summary
private  Logger aquireLogger()
           
protected  void configureComponent(java.lang.Object component)
          Configure the component
protected  void contextualizeComponent(java.lang.Object component)
          Contextualize the component
protected  java.lang.Object createComponent()
          Create a new component
 void dispose(java.lang.Object component)
          Disposal of the supplied component instance.
protected  void enabledComponentLogging(java.lang.Object component)
          Enable logging for the component
 java.lang.Class getCreatedClass()
          Returns the component class.
 java.lang.Object newInstance()
          Returns a new instance of a component and optionally applies a logging channel, instrumentation, context, a component or service manager, configuration, parameters, lifecycle extensions, initialization, and execution phases based on the interfaces implemented by the component class.
protected  void serviceComponent(java.lang.Object component)
          Service the component
 
Methods inherited from class org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
addChildInstrumentable, addInstrument, getChildInstrumentables, getInstrumentableName, getInstruments, setInstrumentableName
 
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

m_newInstance

private final CounterInstrument m_newInstance

m_dispose

private final CounterInstrument m_dispose

m_componentClass

private final java.lang.Class m_componentClass
The class which this ComponentFactory should create.


m_context

private final Context m_context
The Context for the component


m_serviceManager

private final ServiceManager m_serviceManager
The component manager for this component.


m_configuration

private final Configuration m_configuration
The configuration for this component.


m_loggerManager

private final LoggerManager m_loggerManager
The LogKitManager for child ComponentSelectors


m_extManager

private final LifecycleExtensionManager m_extManager
Lifecycle extensions manager


m_componentLogger

private final Logger m_componentLogger
The component's logger


m_classinfo

private ComponentFactory.ClassInfo m_classinfo
The class info for creating the component


m_useDynamicCreation

private boolean m_useDynamicCreation
Use the dynamic configuration

Constructor Detail

ComponentFactory

public ComponentFactory(java.lang.Class componentClass,
                        Configuration configuration,
                        ServiceManager serviceManager,
                        Context context,
                        LoggerManager loggerManager,
                        LifecycleExtensionManager extManager)
Construct a new component factory for the specified component.

Parameters:
componentClass - the class to instantiate (must have a default constructor).
configuration - the Configuration object to pass to new instances.
serviceManager - the service manager to pass to Serviceables.
context - the Context to pass to Contexutalizables.
loggerManager - the loggerManager manager instance.
Method Detail

newInstance

public java.lang.Object newInstance()
                             throws java.lang.Exception
Returns a new instance of a component and optionally applies a logging channel, instrumentation, context, a component or service manager, configuration, parameters, lifecycle extensions, initialization, and execution phases based on the interfaces implemented by the component class.

Specified by:
newInstance in interface ObjectFactory
Returns:
the new instance
Throws:
java.lang.Exception - if the object cannot be instantiated

aquireLogger

private Logger aquireLogger()

getCreatedClass

public final java.lang.Class getCreatedClass()
Returns the component class.

Specified by:
getCreatedClass in interface ObjectFactory
Returns:
the class

dispose

public final void dispose(java.lang.Object component)
                   throws java.lang.Exception
Disposal of the supplied component instance.

Specified by:
dispose in interface ObjectFactory
Parameters:
component - the component to dispose of
Throws:
java.lang.Exception - if a disposal error occurs

createComponent

protected java.lang.Object createComponent()
                                    throws java.lang.Exception
Create a new component

Throws:
java.lang.Exception

enabledComponentLogging

protected void enabledComponentLogging(java.lang.Object component)
                                throws java.lang.Exception
Enable logging for the component

Throws:
java.lang.Exception

contextualizeComponent

protected void contextualizeComponent(java.lang.Object component)
                               throws java.lang.Exception
Contextualize the component

Throws:
java.lang.Exception

serviceComponent

protected void serviceComponent(java.lang.Object component)
                         throws java.lang.Exception
Service the component

Throws:
java.lang.Exception

configureComponent

protected void configureComponent(java.lang.Object component)
                           throws java.lang.Exception
Configure the component

Throws:
java.lang.Exception

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.