bloritsch 02/01/25 12:15:11
Modified: src/scratchpad/org/apache/avalon/excalibur/system
Container.java ContainerManager.java
Added: src/scratchpad/org/apache/avalon/excalibur/system
AbstractContainer.java ConfigurableRoleManager.java
ExcaliburRoleManager.java RoleManager.java
Log:
More parts of the Container code
Revision Changes Path
1.5 +7 -3
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/Container.java
Index: Container.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/Container.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Container.java 21 Jan 2002 08:17:54 -0000 1.4
+++ Container.java 25 Jan 2002 20:15:11 -0000 1.5
@@ -16,12 +16,16 @@
* Manager can expose that to the instantiating class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.4 $ $Date: 2002/01/21 08:17:54 $
+ * @version CVS $Revision: 1.5 $ $Date: 2002/01/25 20:15:11 $
*/
public interface Container
{
String CONTEXT_CLASSLOADER = "container.classloader";
- String CONTEXT_DIRECTORY = "container.rootDir";
- String WORK_DIRECTORY = "container.workDir";
+ String CONTEXT_DIRECTORY = "container.rootDir";
+ String WORK_DIRECTORY = "container.workDir";
+ String LOGGER_MANAGER = "container.logManager";
+ String COMMAND_QUEUE = "container.commandQueue";
+ String POOL_MANAGER = "container.poolManager";
+ String ROLE_MANAGER = "container.roleManager";
}
1.6 +24 -27
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java
Index: ContainerManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContainerManager.java 18 Jan 2002 23:27:25 -0000 1.5
+++ ContainerManager.java 25 Jan 2002 20:15:11 -0000 1.6
@@ -136,7 +136,7 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.5 $ $Date: 2002/01/18 23:27:25 $
+ * @version CVS $Revision: 1.6 $ $Date: 2002/01/25 20:15:11 $
*/
public class ContainerManager
{
@@ -165,6 +165,7 @@
private Configuration m_LogKitConfig;
private Container m_containerInstance;
private ComponentStateValidator m_validator;
+ private RoleManager m_roleManager;
/**
* This constructor creates a new ContainerManager with a
LogKitLoggerManager
@@ -301,23 +302,6 @@
try
{
- /* Begin *Manageable interfaces
- if ( instance instanceof LoggerManageable )
- {
- ( (LoggerManageable) instance ).setLoggerManager(
getLoggerManager() );
- }
-
- if ( instance instanceof CommandManageable )
- {
- ( (CommandManageable) instance ).setCommandQueue(
m_commandManager.getQueue() );
- }
-
- if ( instance instanceof RoleManageable )
- {
- ( (RoleManageable) instance ).setRoleManager(
setupRoleManager() );
- }
- */
-
if ( instance instanceof Contextualizable )
{
( (Contextualizable) instance ).contextualize(
setupContext() );
@@ -381,6 +365,7 @@
m_initialParameters.getParameter(LOG_CATEGORY, null)
);
context.put( Container.CONTEXT_CLASSLOADER, m_contextClassLoader );
+ context.put( Container.ROLE_MANAGER, setupRoleManager() );
context.makeReadOnly();
return context;
@@ -392,10 +377,14 @@
*/
protected LoggerManager setupLoggerManager()
{
- LogKitLoggerManager logManager = new LogKitLoggerManager(
- m_initialParameters.getParameter(LOG_CATEGORY, null)
- );
- return logManager;
+ if ( null == m_logManager )
+ {
+ m_logManager = new LogKitLoggerManager(
+ m_initialParameters.getParameter(LOG_CATEGORY, null)
+ );
+ }
+
+ return m_logManager;
}
/**
@@ -406,11 +395,14 @@
*/
protected ComponentManager setupComponentManager()
{
- DefaultComponentManager manager = new DefaultComponentManager();
- String parser = m_initialParameters.getParameter(XML_PARSER,
"org.apache.avalon.excalibur.xml.JaxpParser");
- //manager.put();
+ if ( null == m_componentManager )
+ {
+ m_componentManager = new DefaultComponentManager();
+ String parser = m_initialParameters.getParameter(XML_PARSER,
"org.apache.avalon.excalibur.xml.JaxpParser");
+ //manager.put();
+ }
- return manager;
+ return m_componentManager;
}
/**
@@ -420,6 +412,11 @@
*/
protected RoleManager setupRoleManager()
{
- throw new UnsupportedOperationException();
+ if ( null == m_roleManager )
+ {
+ m_roleManager = (RoleManager) new ExcaliburRoleManager();
+ }
+
+ return m_roleManager;
}
}
1.1
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/AbstractContainer.java
Index: AbstractContainer.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.system;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.excalibur.event.Queue;
import org.apache.avalon.excalibur.pool.PoolManager;
import org.apache.avalon.excalibur.util.ComponentStateValidator;
/**
* The Container is an interface used to mark the Containers in your system.
It
* exposes a protected getComponentManager() method so that the Container's
* Manager can expose that to the instantiating class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/01/25 20:15:11 $
*/
public abstract class AbstractContainer
extends AbstractLogEnabled
implements Contextualizable, Composable, Configurable, Initializable,
Disposable
{
private final ComponentStateValidator m_validator = new
ComponentStateValidator( this );
private Context m_context;
private ComponentManager m_manager;
private ComponentManager m_childManager;
private LoggerManager m_logManager;
private PoolManager m_poolManager;
private Queue m_commandQueue;
private ClassLoader m_classLoader;
private RoleManager m_roleManager;
private Configuration m_configuration;
/**
* Wrap this so that ComponentStateValidator functions properly.
*/
public void enableLogging( Logger logger )
{
m_validator.checkLogEnabled();
super.enableLogging( logger );
}
/**
* Pull the manager items from the context so we can use them to set up
the
* system.
*/
public void contextualize( Context containerContext )
throws ContextException
{
m_validator.checkContextualized();
m_context = containerContext;
m_logManager = (LoggerManager)
m_context.get(Container.LOGGER_MANAGER);
m_poolManager = (PoolManager) m_context.get(Container.POOL_MANAGER);
try
{
m_classLoader = (ClassLoader)
m_context.get(Container.CONTEXT_CLASSLOADER);
}
catch ( ContextException ce )
{
m_classLoader = Thread.currentThread().getContextClassLoader();
}
try
{
m_commandQueue = (Queue) m_context.get(Container.COMMAND_QUEUE);
}
catch ( ContextException ce )
{
m_commandQueue = null;
getLogger().warn("No Container.COMMAND_QUEUE is given, all
management will be performed synchronously");
}
try
{
m_roleManager = (RoleManager)
m_context.get(Container.ROLE_MANAGER);
}
catch ( ContextException ce )
{
m_roleManager = new ExcaliburRoleManager();
}
}
/**
* Process the configuration and set up the components and their mappings.
* At this point, all components are prepared and all mappings are made.
* However, nothing is initialized.
*/
public void configure( Configuration configElement )
throws ConfigurationException
{
m_validator.checkConfigured();
m_configuration = configElement;
}
/**
* Root ComponentManager. The Container may choose to have it's
ComponentManager
* delegate to the root manager, or it may choose to be entirely self
contained.
*/
public void compose( ComponentManager manager )
throws ComponentException
{
m_validator.checkComposed();
m_manager = manager;
}
/**
* Initializes all components so that the system is ready to be used.
*/
public void initialize()
throws Exception
{
m_validator.checkInitialized();
}
/**
* Disposes of all components and frees resources that they consume.
*/
public void dispose()
{
m_validator.checkDisposed();
}
}
1.1
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ConfigurableRoleManager.java
Index: ConfigurableRoleManager.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.system;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLoggable;
/**
* Configurable RoleManager implementation. It populates the RoleManager
* from a configuration hierarchy. This is based on the DefaultRoleManager
* in the org.apache.avalon.component package.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/01/25 20:15:11 $
* @since 4.1
*/
public class ConfigurableRoleManager
implements RoleManager, Configurable
{
private static final String EMPTY_STRING = "";
/** Map for shorthand to role mapping */
private Map m_shorthands;
/** Map for role to default classname mapping */
private Map m_classNames;
/** Map for role->hint to classname mapping */
private Map m_hintClassNames;
/** Parent <code>RoleManager</code> for nested resolution */
private final RoleManager m_parent;
/**
* Default constructor--this RoleManager has no parent.
*/
public ConfigurableRoleManager()
{
m_parent = null;
}
/**
* Alternate constructor--this RoleManager has the specified
* parent.
*
* @param parent The parent <code>RoleManager</code>.
*/
public ConfigurableRoleManager(RoleManager parent)
{
m_parent = parent;
}
/**
* 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.
*
* @param shorthandName The shortname that is an alias for the role.
* @return the official role name.
*/
public final String getRoleForName( final String shorthandName )
{
final String role = (String)m_shorthands.get( shorthandName );
if( null == role && null != m_parent )
{
return m_parent.getRoleForName( shorthandName );
}
return role;
}
/**
* 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.
*
* @param shorthandName The shortname that is an alias for the role.
* @return the official role name.
*/
public final String getNameForRole( final String role )
{
final String shorthandName = (String)m_shorthands.get( role );
if( null == shorthandName && null != m_parent )
{
return m_parent.getNameForRole( role );
}
return 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.
*
* @param role The role that has a default implementation.
* @return the Fully Qualified Class Name (FQCN) for the role.
*/
public final String getDefaultClassNameForRole( final String role )
{
final String className = (String)m_classNames.get( role );
if( null == className && null != m_parent )
{
return m_parent.getDefaultClassNameForRole( role );
}
return className;
}
/**
* 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.
*
* @param role The role that this shorthand refers to.
* @param shorthand The shorthand name for the type of Component
* @return the FQCN for the role/hint combination.
*/
public final String getDefaultClassNameForHint( final String hintType,
final String role )
{
final Map hintMap = (Map)m_hintClassNames.get( role );
if( null == hintMap )
{
if( null != m_parent )
{
return m_parent.getDefaultClassNameForHint( hintType, role );
}
else
{
return EMPTY_STRING;
}
}
return (String)hintMap.get( hintType );
}
/**
* 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.
*
* @param role The role that this shorthand refers to.
* @param shorthand The shorthand name for the type of Component
* @return the FQCN for the role/hint combination.
*/
public final String getAliasForHintType( final String className,
final String role )
{
final Map hintMap = (Map)m_hintClassNames.get( role );
if( null == hintMap )
{
if( null != m_parent )
{
return m_parent.getAliasForHintType( className, role );
}
else
{
return EMPTY_STRING;
}
}
return (String)hintMap.get( className );
}
/**
* Reads a configuration object and creates the role, shorthand,
* and class name mapping.
*
* @param configuration The configuration object.
* @throws ConfigurationException if the configuration is malformed
*/
public final void configure( final Configuration configuration )
throws ConfigurationException
{
final Map shorts = new HashMap();
final Map classes = new HashMap();
final Map hintclasses = new HashMap();
final Configuration[] roles = configuration.getChildren( "role" );
for( int i = 0; i < roles.length; i++ )
{
final String name = roles[ i ].getAttribute( "name" );
final String shorthand = roles[ i ].getAttribute( "shorthand" );
final String defaultClassName =
roles[ i ].getAttribute( "default-class", null );
shorts.put( shorthand, name );
shorts.put( name, shorthand );
if( null != defaultClassName )
{
classes.put( name, defaultClassName );
classes.put( defaultClassName, name );
}
final Configuration[] hints = roles[ i ].getChildren( "hint" );
if( hints.length > 0 )
{
HashMap hintMap = new HashMap();
for( int j = 0; j < hints.length; j++ )
{
final String shortHand = hints[ j
].getAttribute("shorthand").trim();
final String className = hints[ j
].getAttribute("class").trim();
hintMap.put( shortHand, className );
hintMap.put( className, shortHand );
}
hintclasses.put( name, Collections.unmodifiableMap( hintMap )
);
}
}
m_shorthands = Collections.unmodifiableMap( shorts );
m_classNames = Collections.unmodifiableMap( classes );
m_hintClassNames = Collections.unmodifiableMap( hintclasses );
}
}
1.1
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ExcaliburRoleManager.java
Index: ExcaliburRoleManager.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.system;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* The Excalibur Role Manager is used for Excalibur Role Mappings. All of the
* information is hard-coded.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/01/25 20:15:11 $
* @since 4.1
*/
public class ExcaliburRoleManager
implements RoleManager
{
private static final String EMPTY_STRING = "";
/** Map for shorthand to role mapping */
private Map m_shorthands;
/** Map for role to default classname mapping */
private Map m_classNames;
/** Map for role->hint to classname mapping */
private Map m_hintClassNames;
/** Parent <code>RoleManager</code> for nested resolution */
private final RoleManager m_parent;
/**
* Default constructor--this RoleManager has no parent.
*/
public ExcaliburRoleManager()
{
this( null );
}
/**
* Alternate constructor--this RoleManager has the specified
* parent.
*
* @param parent The parent <code>RoleManager</code>.
*/
public ExcaliburRoleManager(RoleManager parent)
{
m_parent = parent;
HashMap shorts = new HashMap( 10 );
HashMap classes = new HashMap( 10 );
HashMap hints = new HashMap( 5 );
/* Set up DataSource relations */
shorts.put( "datasource",
"org.apache.avalon.excalibur.datasource.DataSourceComponent" );
shorts.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponent", "datasource" );
classes.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponent",
"org.apache.avalon.excalibur.datasource.JdbcDataSource"
);
classes.put( "org.apache.avalon.excalibur.datasource.JdbcDataSource",
"org.apache.avalon.excalibur.datasource.DataSourceComponent" );
shorts.put( "datasources",
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector" );
shorts.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
"datasources" );
classes.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
"org.apache.avalon.excalibur.datasource.ExcaliburComponentSelector" );
classes.put(
"org.apache.avalon.excalibur.datasource.ExcaliburComponentSelector",
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector" );
HashMap dsMap = new HashMap( 3 );
dsMap.put( "jdbc",
"org.apache.avalon.excalibur.datasource.JdbcDataSource" );
dsMap.put( "org.apache.avalon.excalibur.datasource.JdbcDataSource",
"jdbc" );
dsMap.put( "informix",
"org.apache.avalon.excalibur.datasource.InformixDataSource" );
dsMap.put(
"org.apache.avalon.excalibur.datasource.InformixDataSource", "informix" );
dsMap.put( "j2ee",
"org.apache.avalon.excalibur.datasource.J2eeDataSource" );
dsMap.put( "org.apache.avalon.excalibur.datasource.J2eeDataSource",
"j2ee" );
hints.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
Collections.unmodifiableMap( dsMap ) );
/* Set up Monitor relations */
shorts.put( "monitor", "org.apache.avalon.excalibur.monitor.Monitor"
);
shorts.put( "org.apache.avalon.excalibur.monitor.Monitor", "monitor"
);
classes.put( "org.apache.avalon.excalibur.monitor.Monitor",
"org.apache.avalon.excalibur.monitor.ActiveMonitor" );
classes.put( "org.apache.avalon.excalibur.monitor.ActiveMonitor",
"org.apache.avalon.excalibur.monitor.Monitor" );
/* Set up XPath relations */
shorts.put( "xpath",
"org.apache.avalon.excalibur.xml.xpath.XPathProcessor" );
shorts.put( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
"xpath" );
classes.put( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor",
"org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl" );
classes.put(
"org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl",
"org.apache.avalon.excalibur.xml.xpath.XPathProcessor" );
/* Set up i18n relations */
shorts.put( "i18n", "org.apache.avalon.excalibur.i18n.Bundle" );
shorts.put( "org.apache.avalon.excalibur.i18n.Bundle", "i18n" );
classes.put( "org.apache.avalon.excalibur.i18n.Bundle",
"org.apache.avalon.excalibur.i18n.BundleSelector" );
classes.put( "org.apache.avalon.excalibur.i18n.BundleSelector",
"org.apache.avalon.excalibur.i18n.Bundle" );
HashMap bundleMap = new HashMap( 3 );
bundleMap.put( "xml", "org.apache.avalon.excalibur.i18n.XmlBundle" );
bundleMap.put( "org.apache.avalon.excalibur.i18n.XmlBundle", "xml" );
bundleMap.put( "flat",
"org.apache.avalon.excalibur.i18n.FlatXmlBundle" );
bundleMap.put( "org.apache.avalon.excalibur.i18n.FlatXmlBundle",
"flat" );
hints.put(
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
Collections.unmodifiableMap( bundleMap ) );
/* Set up SourceResolver relations */
shorts.put( "resolver",
"org.apache.avalon.excalibur.source.SourceResolver" );
shorts.put( "org.apache.avalon.excalibur.source.SourceResolver",
"resolver" );
classes.put( "org.apache.avalon.excalibur.source.SourceResolver",
"org.apache.avalon.excalibur.source.SourceResolverImpl"
);
classes.put( "org.apache.avalon.excalibur.source.SourceResolverImpl",
"org.apache.avalon.excalibur.source.SourceResolver" );
/* Set up SourceResolver relations */
shorts.put( "parsre", "org.apache.avalon.excalibur.xml.Parser" );
shorts.put( "org.apache.avalon.excalibur.xml.Parser", "parser" );
classes.put( "org.apache.avalon.excalibur.xml.Parser",
"org.apache.avalon.excalibur.xml.JaxpParser" );
classes.put( "org.apache.avalon.excalibur.xml.JaxpParser",
"org.apache.avalon.excalibur.xml.Parser" );
m_shorthands = Collections.unmodifiableMap( shorts );
m_classNames = Collections.unmodifiableMap( classes );
m_hintClassNames = Collections.unmodifiableMap( hints );
}
/**
* 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.
*
* @param shorthandName The shortname that is an alias for the role.
* @return the official role name.
*/
public final String getRoleForName( final String shorthandName )
{
final String role = (String)m_shorthands.get( shorthandName );
if( null == role && null != m_parent )
{
return m_parent.getRoleForName( shorthandName );
}
return role;
}
/**
* 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.
*
* @param shorthandName The shortname that is an alias for the role.
* @return the official role name.
*/
public final String getNameForRole( final String role )
{
final String shorthandName = (String)m_shorthands.get( role );
if( null == shorthandName && null != m_parent )
{
return m_parent.getNameForRole( role );
}
return 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.
*
* @param role The role that has a default implementation.
* @return the Fully Qualified Class Name (FQCN) for the role.
*/
public final String getDefaultClassNameForRole( final String role )
{
final String className = (String)m_classNames.get( role );
if( null == className && null != m_parent )
{
return m_parent.getDefaultClassNameForRole( role );
}
return className;
}
/**
* 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.
*
* @param role The role that this shorthand refers to.
* @param shorthand The shorthand name for the type of Component
* @return the FQCN for the role/hint combination.
*/
public final String getDefaultClassNameForHint( final String hintType,
final String role )
{
final Map hintMap = (Map)m_hintClassNames.get( role );
if( null == hintMap )
{
if( null != m_parent )
{
return m_parent.getDefaultClassNameForHint( hintType, role );
}
else
{
return EMPTY_STRING;
}
}
return (String)hintMap.get( hintType );
}
/**
* 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.
*
* @param role The role that this shorthand refers to.
* @param shorthand The shorthand name for the type of Component
* @return the FQCN for the role/hint combination.
*/
public final String getAliasForHintType( final String className,
final String role )
{
final Map hintMap = (Map)m_hintClassNames.get( role );
if( null == hintMap )
{
if( null != m_parent )
{
return m_parent.getAliasForHintType( className, role );
}
else
{
return EMPTY_STRING;
}
}
return (String)hintMap.get( className );
}
}
1.1
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/RoleManager.java
Index: RoleManager.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.system;
/**
* RoleManager Interface, use this to specify the Roles and how they
* correspond easy shorthand names. The new RoleManager interface specifies
* how to interpret shorthand names in a configuration file. It also helps
* by providing serialization hints so that self-healing configuration is
* possible.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/01/25 20:15:11 $
* @since 4.1
*/
public interface RoleManager
{
/**
* Find Role name based on shorthand name. Please note that if
* this returns <code>null</code> or an empty string, then the
* shorthand name is assumed to be a "reserved word". In other
* words, you should not try to instantiate a class from an empty
* role.
*/
String getRoleForName( String shorthandName );
/**
* Find shorthand name based on Role name. Please note that if
* this returns <code>null</code> or an empty string, then the
* config file will use the expanded format.
*/
String getNameForRole( String roleName );
/**
* Get the default classname for a given role.
*/
String getDefaultClassNameForRole( String role );
/**
* Get the default classname for a given hint type. This is only
* used by ComponentSelectors.
*/
String getDefaultClassNameForHint( String hintType, String role );
/**
* Get the type name for classname for a given role. This is only
* used by ComponentSelectors.
*/
String getAliasForHintType( String className, String role );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>