org.apache.cocoon.core.container
Class DefaultServiceSelector

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.core.container.DefaultServiceSelector
All Implemented Interfaces:
Configurable, LogEnabled, Preloadable, Serviceable, ServiceSelector, ThreadSafe
Direct Known Subclasses:
ComponentsSelector

public class DefaultServiceSelector
extends AbstractLogEnabled
implements ThreadSafe, Preloadable, Serviceable, Configurable, ServiceSelector

Default component selector for Cocoon's components. This selector "flattens" its declaration by adding them as components of its containing ServiceManager. This allows a smooth transition towards a fully flat configuration by allowing the use of selectors in legacy components and also declaration of hinted components (i.e. with a role of type "rolename/hint") in the service manager.

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

Nested Class Summary
static class DefaultServiceSelector.Factory
          A special factory for DefaultServiceSelector, that passes it the RoleManager and its role name.
 
Field Summary
static String DEFAULT_HINT
          Synthetic hint to alias the default component
 
Constructor Summary
DefaultServiceSelector()
           
 
Method Summary
 void configure(Configuration config)
           
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.
 boolean isSelectable(Object hint)
           
 void release(Object obj)
           
 Object select(Object hint)
           
 void service(ServiceManager manager)
           
 void setRole(String role)
           
 void setRoleManager(RoleManager roles)
           
 
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

DEFAULT_HINT

public static final String DEFAULT_HINT
Synthetic hint to alias the default component

See Also:
Constant Field Values
Constructor Detail

DefaultServiceSelector

public DefaultServiceSelector()
Method Detail

service

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

setRole

public void setRole(String role)

setRoleManager

public void setRoleManager(RoleManager roles)

configure

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

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 obj)
Specified by:
release in interface ServiceSelector

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


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