org.apache.avalon.excalibur.system
Class AbstractRoleManager

java.lang.Object
  |
  +--org.apache.avalon.excalibur.system.AbstractRoleManager
All Implemented Interfaces:
RoleManager
Direct Known Subclasses:
ConfigurableRoleManager, ExcaliburRoleManager

public abstract class AbstractRoleManager
extends java.lang.Object
implements RoleManager

The Excalibur Role Manager is used for Excalibur Role Mappings. All of the information is hard-coded.

Since:
4.1
Version:
CVS $Revision: 1.1 $ $Date: 2002/01/30 15:44:06 $
Author:
Berin Loritsch

Field Summary
protected static java.lang.String EMPTY_STRING
           
protected  java.util.Map m_classNames
          Map for role to classname mapping
protected  java.util.Map m_handlerNames
          Map for role to handler classname mapping
protected  java.lang.ClassLoader m_loader
           
protected  RoleManager m_parent
          Parent RoleManager for nested resolution
protected  java.util.Map m_shorthands
          Map for shorthand to class mapping
 
Constructor Summary
AbstractRoleManager()
          Default constructor--this RoleManager has no parent.
AbstractRoleManager(RoleManager parent)
          Alternate constructor--this RoleManager has the specified parent.
AbstractRoleManager(RoleManager parent, java.lang.ClassLoader loader)
          Alternate constructor--this RoleManager has the specified parent.
 
Method Summary
 java.lang.Class[] getClassesForRole(java.lang.String role)
          Retrieves the default class name for the specified role.
 java.lang.Class getClassForName(java.lang.String shorthandName)
          Find the Class for the given shorthand name.
 java.lang.Class getHandlerClassForClass(java.lang.Class className)
          Retrieves the handler class name for the specified class name.
 java.lang.String getNameForClass(java.lang.Class klass)
          Retrieves the real role name from a shorthand name.
 java.lang.String getRoleForClass(java.lang.Class klass)
          Retrieves a default class name for a role/hint combination.
protected  void setup(java.util.Map shorts, java.util.Map classes, java.util.Map handlers, java.lang.String shortName, java.lang.String role, java.lang.String className, java.lang.String handlerClassName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

protected static final java.lang.String EMPTY_STRING

m_loader

protected final java.lang.ClassLoader m_loader

m_shorthands

protected java.util.Map m_shorthands
Map for shorthand to class mapping

m_classNames

protected java.util.Map m_classNames
Map for role to classname mapping

m_handlerNames

protected java.util.Map m_handlerNames
Map for role to handler classname mapping

m_parent

protected final RoleManager m_parent
Parent RoleManager for nested resolution
Constructor Detail

AbstractRoleManager

public AbstractRoleManager()
Default constructor--this RoleManager has no parent.

AbstractRoleManager

public AbstractRoleManager(RoleManager parent)
Alternate constructor--this RoleManager has the specified parent.
Parameters:
parent - The parent RoleManager.

AbstractRoleManager

public AbstractRoleManager(RoleManager parent,
                           java.lang.ClassLoader loader)
Alternate constructor--this RoleManager has the specified parent.
Parameters:
parent - The parent RoleManager.
Method Detail

setup

protected void setup(java.util.Map shorts,
                     java.util.Map classes,
                     java.util.Map handlers,
                     java.lang.String shortName,
                     java.lang.String role,
                     java.lang.String className,
                     java.lang.String handlerClassName)

getClassForName

public final java.lang.Class getClassForName(java.lang.String shorthandName)
Find the Class for the given shorthand name. If there is no correspondence between the class and the shorthand name, the method returns null. If this RoleManager does not have the match, and there is a parent RoleManager, the parent will be asked to resolve the request.
Specified by:
getClassForName in interface RoleManager

getNameForClass

public final java.lang.String getNameForClass(java.lang.Class klass)
Retrieves the real role name from a shorthand name. Usually the shorthand name refers to a configuration element name. If this RoleManager does not have the match, and there is a parent RoleManager, the parent will be asked to resolve the role.
Specified by:
getNameForClass in interface RoleManager
Parameters:
shorthandName - The shortname that is an alias for the role.
Returns:
the official role name.

getHandlerClassForClass

public final java.lang.Class getHandlerClassForClass(java.lang.Class className)
Retrieves the handler class name for the specified class name. This is called for every ComponentImplementation. If this RoleManager does not have the match, and there is a parent RoleManager, the parent will be asked to resolve the handler's class name.
Specified by:
getHandlerClassForClass in interface RoleManager
Parameters:
role - The role that has a default implementation.
Returns:
the Fully Qualified Class Name (FQCN) for the role.

getClassesForRole

public final java.lang.Class[] getClassesForRole(java.lang.String role)
Retrieves the default class name for the specified role. This is only called when the configuration does not specify the class explicitly. If this RoleManager does not have the match, and there is a parent RoleManager, the parent will be asked to resolve the class name.
Specified by:
getClassesForRole in interface RoleManager
Parameters:
role - The role that has a default implementation.
Returns:
the Fully Qualified Class Name (FQCN) for the role.

getRoleForClass

public final java.lang.String getRoleForClass(java.lang.Class klass)
Retrieves a default class name for a role/hint combination. This is only called when a role is mapped to a DefaultComponentSelector, and the configuration elements use shorthand names for the type of component. If this RoleManager does not have the match, and there is a parent RoleManager, the parent will be asked to resolve the class name.
Specified by:
getRoleForClass in interface RoleManager
Parameters:
role - The role that this shorthand refers to.
shorthand - The shorthand name for the type of Component
Returns:
the FQCN for the role/hint combination.


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.