org.apache.cocoon.components
Class ExtendedComponentSelector

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.avalon.excalibur.component.AbstractDualLogEnabled
              |
              +--org.apache.avalon.excalibur.component.ExcaliburComponentSelector
                    |
                    +--org.apache.cocoon.components.ExtendedComponentSelector
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.ComponentSelector, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.excalibur.instrument.Instrumentable, org.apache.excalibur.instrument.InstrumentManageable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.logger.LogKitManageable, org.apache.avalon.excalibur.component.RoleManageable, org.apache.avalon.framework.thread.ThreadSafe
Direct Known Subclasses:
ComponentsSelector

public class ExtendedComponentSelector
extends org.apache.avalon.excalibur.component.ExcaliburComponentSelector

An extension of ExcaliburComponentSelector that can have a parent and accepts a wider variety of configurations.

Version:
CVS $Id: ExtendedComponentSelector.java,v 1.1.2.1 2002/07/15 14:42:48 cziegeler Exp $
Author:
Sylvain Wallez

Field Summary
protected  java.lang.ClassLoader classLoader
          The class loader to use
protected  java.lang.String defaultHint
          The default hint
protected  java.util.Set parentComponents
          The components selected in the parent selector
protected  org.apache.avalon.framework.component.ComponentSelector parentSelector
          The parent selector, if any
protected  java.lang.String roleName
          The role of this selector.
protected  org.apache.avalon.excalibur.component.RoleManager roles
          The role manager
 
Fields inherited from class org.apache.avalon.excalibur.component.ExcaliburComponentSelector
m_context
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
ExtendedComponentSelector()
           
ExtendedComponentSelector(java.lang.ClassLoader loader)
          Create the ComponentSelector with a Classloader
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration config)
          Configure this selector.
protected  java.lang.String getClassAttributeName()
          Get the name of the attribute giving the class name of a component.
protected  java.lang.String getComponentInstanceName()
          Get the name for component-instance elements (i.e. components not defined by their role shortcut.
 java.lang.String getDefaultHint()
          Get the default hint, if any for this selector.
protected  java.lang.String getDefaultHintAttributeName()
          Get the name of the attribute giving the default hint to use if none is given.
protected  java.lang.String getRoleName(org.apache.avalon.framework.configuration.Configuration config)
          Get the role name for this selector.
 boolean hasComponent(java.lang.Object hint)
           
 void release(org.apache.avalon.framework.component.Component component)
           
 org.apache.avalon.framework.component.Component select(java.lang.Object hint)
           
 void setParentSelector(org.apache.avalon.framework.component.ComponentSelector parent)
          Set the parent of this selector.
 void setRoleManager(org.apache.avalon.excalibur.component.RoleManager roles)
          Configure the RoleManager.
 
Methods inherited from class org.apache.avalon.excalibur.component.ExcaliburComponentSelector
addComponent, addComponentInstance, compose, contextualize, dispose, getChildInstrumentables, getComponentHandler, getComponentHandlers, getInstrumentableName, getInstruments, initialize, setInstrumentableName, setInstrumentManager, setLoggerManager, setLogKitManager
 
Methods inherited from class org.apache.avalon.excalibur.component.AbstractDualLogEnabled
getLogkitLogger, setLogger
 
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

roles

protected org.apache.avalon.excalibur.component.RoleManager roles
The role manager

parentSelector

protected org.apache.avalon.framework.component.ComponentSelector parentSelector
The parent selector, if any

classLoader

protected java.lang.ClassLoader classLoader
The class loader to use

parentComponents

protected java.util.Set parentComponents
The components selected in the parent selector

roleName

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

defaultHint

protected java.lang.String defaultHint
The default hint
Constructor Detail

ExtendedComponentSelector

public ExtendedComponentSelector()

ExtendedComponentSelector

public ExtendedComponentSelector(java.lang.ClassLoader loader)
Create the ComponentSelector with a Classloader
Method Detail

getComponentInstanceName

protected java.lang.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 java.lang.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

getDefaultHintAttributeName

protected java.lang.String getDefaultHintAttributeName()
Get the name of the attribute giving the default hint 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 hint can be specified.
Returns:
"default", but can be changed by subclasses

setRoleManager

public void setRoleManager(org.apache.avalon.excalibur.component.RoleManager roles)
Configure the RoleManager. Redeclared only because parent member is private.
Overrides:
setRoleManager in class org.apache.avalon.excalibur.component.ExcaliburComponentSelector

setParentSelector

public void setParentSelector(org.apache.avalon.framework.component.ComponentSelector parent)
Set the parent of this selector. This can be done after the selector is initialized, but only once. This allows this selector to be created by a component manager while still being able to have a parent.
Parameters:
parent - the parent selector
Throws:
java.lang.IllegalStateException - if parent is already set

getRoleName

protected java.lang.String getRoleName(org.apache.avalon.framework.configuration.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.

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Configure this selector. This is the main difference with the parent class :
  • if getComponentInstanceName() returns null, any child configurations having a attribute named as the result of getClassAttributeName(), is considered as a component instance.
  • if getComponentInstanceName() returns a non-null value, only child configurations having this name are considered as a component instance.
  • if other cases, it's name is considered to be a hint in the role manager. The behaviour is then the same as ExcaliburComponentSelector.
  • Overrides:
    configure in class org.apache.avalon.excalibur.component.ExcaliburComponentSelector
    Parameters:
    config - the configuration
    Throws:
    org.apache.avalon.framework.configuration.ConfigurationException - if some hints aren't defined

getDefaultHint

public java.lang.String getDefaultHint()
Get the default hint, if any for this selector.

select

public org.apache.avalon.framework.component.Component select(java.lang.Object hint)
                                                       throws org.apache.avalon.framework.component.ComponentException
Overrides:
select in class org.apache.avalon.excalibur.component.ExcaliburComponentSelector

release

public void release(org.apache.avalon.framework.component.Component component)
Overrides:
release in class org.apache.avalon.excalibur.component.ExcaliburComponentSelector

hasComponent

public boolean hasComponent(java.lang.Object hint)
Overrides:
hasComponent in class org.apache.avalon.excalibur.component.ExcaliburComponentSelector


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.