org.apache.avalon.fortress.impl
Class DefaultContainer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.fortress.impl.AbstractContainer
          extended by org.apache.avalon.fortress.impl.DefaultContainer
All Implemented Interfaces:
org.apache.avalon.fortress.Container, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable
Direct Known Subclasses:
DefaultECMContainer

public class DefaultContainer
extends AbstractContainer
implements org.apache.avalon.framework.configuration.Configurable

This is the default implementation of Container, adding configuration markup semantics to the AbstractContainer.

Version:
CVS $Revision: 1.17 $ $Date: 2004/02/28 15:16:24 $
Author:
The Avalon Team

Field Summary
private  java.lang.String m_defaultActivationPolicy
          Default activation policy for components, ie.
 
Fields inherited from class org.apache.avalon.fortress.impl.AbstractContainer
DEFAULT_ENTRY, m_classLoader, m_commandSink, m_componentContext, m_components, m_context, m_extManager, m_instrumentManager, m_loggerManager, m_mapper, m_metaManager, m_poolManager, m_serviceManager, m_shutDownOrder, SELECTOR_ENTRY
 
Fields inherited from interface org.apache.avalon.fortress.Container
ROLE
 
Constructor Summary
DefaultContainer()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration config)
          Process the configuration and set up the components and their mappings.
private  int getActivation(org.apache.avalon.framework.configuration.Configuration component)
          Helper method to determine the activation policy for a given component handler configuration.
private  java.lang.String getClassname(org.apache.avalon.framework.configuration.Configuration config)
          Retrieve the classname for component configuration.
private  java.lang.String getDefaultActivationPolicy(org.apache.avalon.framework.configuration.Configuration config)
          Obtains the default activation policy from the component configuration header
 org.apache.avalon.framework.service.ServiceManager getServiceManager()
          Return the ServiceManager that exposes all the services in impl.
protected  void interpretProxy(java.lang.String proxyType)
          Interpret the ProxyManager type from the configuration element.
 
Methods inherited from class org.apache.avalon.fortress.impl.AbstractContainer
addComponent, contextualize, createHintMap, createObjectFactory, dispose, get, getProxyManager, getRoleKey, has, initialize, provideComponentContext, provideServiceManager, service, setProxyManager
 
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_defaultActivationPolicy

private java.lang.String m_defaultActivationPolicy
Default activation policy for components, ie. inline, background, etc.

Constructor Detail

DefaultContainer

public DefaultContainer()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException

Process the configuration and set up the components and their mappings. At this point, all components are prepared and all mappings are made. However, nothing is initialized.

The configuration format follows a specific convention:

Please note: each configuration element must have a unique id. If a configuration element does not have a unique id, it will not be treated as a component. This id is used later as a hint when there is more than one implementation of a role.

The first component encourted which implements a specific role becomes the default implemenation of that role. This can be changed by the default attribute in this configuration.

   <my-config>
     <component id="default-connection"
                   class="org.apache.avalon.excalibur.datasource.JdbcDataSourceComponent">

       <!-- Component specific configuration -->

     </component>
 
     <jdbc-data-source id="another-connection">

         <!-- Component specific configuration -->

     </jdbc-data-source>
   </my-config>
 

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
config - The configuration element to translate into the list of components this impl managers.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if the configuration is not valid

getDefaultActivationPolicy

private java.lang.String getDefaultActivationPolicy(org.apache.avalon.framework.configuration.Configuration config)
Obtains the default activation policy from the component configuration header

Parameters:
config - Configuration to examine
Returns:
activation policy if specified, 'background' (the default) if not

interpretProxy

protected void interpretProxy(java.lang.String proxyType)
                       throws org.apache.avalon.framework.configuration.ConfigurationException
Interpret the ProxyManager type from the configuration element.

Parameters:
proxyType -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getClassname

private java.lang.String getClassname(org.apache.avalon.framework.configuration.Configuration config)
                               throws org.apache.avalon.framework.configuration.ConfigurationException
Retrieve the classname for component configuration.

Parameters:
config - the component configuration
Returns:
the class name
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getActivation

private int getActivation(org.apache.avalon.framework.configuration.Configuration component)
                   throws org.apache.avalon.framework.configuration.ConfigurationException
Helper method to determine the activation policy for a given component handler configuration. Supported values for the "activation" attribute of the component are "background", "inline", or "lazy". The default activation is "background". For compatibility, "startup" is an alias for "background" and "request" is an alias for "lazy".

Parameters:
component - Configuration
Returns:
the activation policy, one of ComponentHandlerMetaData.ACTIVATION_BACKGROUND, ComponentHandlerMetaData.ACTIVATION_INLINE, ComponentHandlerMetaData.ACTIVATION_LAZY.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if the handler specifies an unknown activation policy

getServiceManager

public org.apache.avalon.framework.service.ServiceManager getServiceManager()
Return the ServiceManager that exposes all the services in impl.

Overrides:
getServiceManager in class AbstractContainer
Returns:
the ServiceManager that exposes all the services in impl.