org.apache.cocoon.components
Class ExtendedComponentSelector

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.excalibur.component.AbstractDualLogEnabled
          extended by org.apache.avalon.excalibur.component.ExcaliburComponentSelector
              extended by org.apache.cocoon.components.ExtendedComponentSelector
All Implemented Interfaces:
RoleManageable, LoggerManageable, LogKitManageable, Disposable, Initializable, Component, ComponentSelector, Composable, Configurable, Contextualizable, LogEnabled, Loggable, ThreadSafe, ParentAware, Instrumentable, InstrumentManageable
Direct Known Subclasses:
ComponentsSelector

public class ExtendedComponentSelector
extends ExcaliburComponentSelector
implements ParentAware

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

Version:
CVS $Id: ExtendedComponentSelector.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Sylvain Wallez

Field Summary
protected  ClassLoader classLoader
          The class loader to use
protected  String defaultHint
          The default hint
protected  ComponentLocator parentLocator
          The parent locator, if any
protected  ExtendedComponentSelector parentSelector
          The parent selector, if any
protected  String roleName
          The role of this selector.
protected  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()
          Create the ComponentSelector with the Thread context ClassLoader
ExtendedComponentSelector(ClassLoader loader)
          Create the ComponentSelector with a ClassLoader
 
Method Summary
protected  boolean canRelease(Component component)
           
 void configure(Configuration config)
          Configure this selector.
 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.
 String getDefaultHint()
          Get the default hint, if any for this selector.
protected  String getDefaultHintAttributeName()
          Get the name of the attribute giving the default hint to use if none is given.
protected  String getRoleName(Configuration config)
          Get the role name for this selector.
 boolean hasComponent(Object hint)
          Does this selector or its parent have the given hint ?
protected  boolean hasDeclaredComponent(Object hint)
          Does this selector declare a given hint?
 void release(Component component)
           
 Component select(Object hint)
           
 void setParentLocator(ComponentLocator locator)
          Set the parent component manager and the role name
 void setRoleManager(RoleManager roles)
          Configure the RoleManager.
 
Methods inherited from class org.apache.avalon.excalibur.component.ExcaliburComponentSelector
addComponent, addComponentInstance, compose, contextualize, 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 RoleManager roles
The role manager


parentSelector

protected ExtendedComponentSelector parentSelector
The parent selector, if any


parentLocator

protected ComponentLocator parentLocator
The parent locator, if any


classLoader

protected ClassLoader classLoader
The class loader to use


roleName

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


defaultHint

protected String defaultHint
The default hint

Constructor Detail

ExtendedComponentSelector

public ExtendedComponentSelector()
Create the ComponentSelector with the Thread context ClassLoader


ExtendedComponentSelector

public ExtendedComponentSelector(ClassLoader loader)
Create the ComponentSelector with a ClassLoader

Method Detail

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

getDefaultHintAttributeName

protected 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(RoleManager roles)
Configure the RoleManager. Redeclared only because parent member is private.

Specified by:
setRoleManager in interface RoleManageable
Overrides:
setRoleManager in class ExcaliburComponentSelector

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.

configure

public void configure(Configuration config)
               throws ConfigurationException
Configure this selector. This is the main difference with the parent class :

getDefaultHint

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


select

public Component select(Object hint)
                 throws ComponentException
Specified by:
select in interface ComponentSelector
Overrides:
select in class ExcaliburComponentSelector
Throws:
ComponentException

release

public void release(Component component)
Specified by:
release in interface ComponentSelector
Overrides:
release in class ExcaliburComponentSelector

hasComponent

public boolean hasComponent(Object hint)
Does this selector or its parent have the given hint ?

Specified by:
hasComponent in interface ComponentSelector
Overrides:
hasComponent in class ExcaliburComponentSelector

hasDeclaredComponent

protected boolean hasDeclaredComponent(Object hint)
Does this selector declare a given hint? Check is performed on the components declared for this selector only, and not those potentially inherited from the parent selector.

Parameters:
hint - the hint to check for
Returns:
true if this selector has the specified hint

setParentLocator

public void setParentLocator(ComponentLocator locator)
                      throws ComponentException
Description copied from interface: ParentAware
Set the parent component manager and the role name

Specified by:
setParentLocator in interface ParentAware
Throws:
ComponentException

dispose

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

canRelease

protected boolean canRelease(Component component)
Overrides:
canRelease in class ExcaliburComponentSelector


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.