org.apache.cocoon.core.container
Class StandaloneServiceSelector

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.core.container.AbstractServiceManager
          extended byorg.apache.cocoon.core.container.StandaloneServiceSelector
All Implemented Interfaces:
Configurable, Contextualizable, Disposable, Initializable, LogEnabled, Preloadable, Serviceable, ServiceSelector, ThreadSafe

public class StandaloneServiceSelector
extends AbstractServiceManager
implements Preloadable, ServiceSelector, Serviceable, Configurable

Default component selector for Cocoon's components.

Since:
2.2
Version:
$Id: StandaloneServiceSelector.java 326062 2005-10-18 09:31:53Z sylvain $

Nested Class Summary
static class StandaloneServiceSelector.Factory
          A special factory that sets the RoleManager and LoggerManager after service()
 
Field Summary
protected  String defaultKey
          The default key
protected  ServiceManager parentLocator
          The parent locator, if any
protected  StandaloneServiceSelector parentSelector
          The parent selector, if any
protected  String roleName
          The role of this selector.
protected  ServiceManager serviceManager
          The application context for components
 
Fields inherited from class org.apache.cocoon.core.container.AbstractServiceManager
componentEnv, componentHandlers, componentMapping, context, disposed, initialized, loggerManager, roleManager
 
Constructor Summary
StandaloneServiceSelector()
           
 
Method Summary
 void addComponent(String key, Class component, Configuration configuration, ComponentInfo info)
          Add a new component to the manager.
protected  boolean canRelease(Object component)
           
 void configure(Configuration config)
           
 void dispose()
           
protected  String getClassAttributeName()
          Get the name of the attribute giving the class name of a component.
protected  String getComponentInstanceName()
          Get the name for component-instance elements (i.e. components not defined by their role shortcut.
protected  String getDefaultKeyAttributeName()
          Get the name of the attribute giving the default key to use if none is given.
protected  String getRoleName(Configuration config)
          Get the role name for this selector.
 void initialize()
           
 boolean isSelectable(Object hint)
           
 void release(Object component)
           
 Object select(Object hint)
           
 void service(ServiceManager componentManager)
           
 
Methods inherited from class org.apache.cocoon.core.container.AbstractServiceManager
addComponent, contextualize, getComponentHandler, setLoggerManager, setRoleManager
 
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

serviceManager

protected ServiceManager serviceManager
The application context for components


parentSelector

protected StandaloneServiceSelector parentSelector
The parent selector, if any


parentLocator

protected ServiceManager parentLocator
The parent locator, if any


roleName

protected String roleName
The role of this selector. Set in configure().


defaultKey

protected String defaultKey
The default key

Constructor Detail

StandaloneServiceSelector

public StandaloneServiceSelector()
Method Detail

select

public Object select(Object hint)
              throws ServiceException
Specified by:
select in interface ServiceSelector
Throws:
ServiceException

isSelectable

public boolean isSelectable(Object hint)
Specified by:
isSelectable in interface ServiceSelector

release

public void release(Object component)
Specified by:
release in interface ServiceSelector

service

public void service(ServiceManager componentManager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException

configure

public void configure(Configuration config)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Overrides:
initialize in class AbstractServiceManager
Throws:
Exception

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractServiceManager

addComponent

public void addComponent(String key,
                         Class component,
                         Configuration configuration,
                         ComponentInfo info)
                  throws ServiceException
Add a new component to the manager.

Specified by:
addComponent in class AbstractServiceManager
Parameters:
key - the key for the new component.
component - the class of this component.
configuration - the configuration for this component.
Throws:
ServiceException

getComponentInstanceName

protected String getComponentInstanceName()
Get the name for component-instance elements (i.e. components not defined by their role shortcut. If null, any element having a 'class' attribute will be considered as a component instance.

The default here is to return null, and subclasses can redefine this method to return particular values.

Returns:
null, but can be changed by subclasses

getClassAttributeName

protected String getClassAttributeName()
Get the name of the attribute giving the class name of a component. The default here is "class", but this can be overriden in subclasses.

Returns:
"class", but can be changed by subclasses

getDefaultKeyAttributeName

protected String getDefaultKeyAttributeName()
Get the name of the attribute giving the default key to use if none is given. The default here is "default", but this can be overriden in subclasses. If this method returns null, no default key can be specified.

Returns:
"default", but can be changed by subclasses

getRoleName

protected String getRoleName(Configuration config)
Get the role name for this selector. This is called by configure() to set the value of this.roleName.

Returns:
the role name, or null if it couldn't be determined.

canRelease

protected boolean canRelease(Object component)


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.