bloritsch    02/01/28 14:04:50

  Modified:    src/scratchpad/org/apache/avalon/excalibur/system
                        ConfigurableRoleManager.java
                        ExcaliburRoleManager.java RoleManager.java
  Log:
  adjust the RoleManager interface to relate Handlers with implementations
  
  Revision  Changes    Path
  1.2       +34 -2     
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ConfigurableRoleManager.java
  
  Index: ConfigurableRoleManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ConfigurableRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurableRoleManager.java      25 Jan 2002 20:15:11 -0000      1.1
  +++ ConfigurableRoleManager.java      28 Jan 2002 22:04:50 -0000      1.2
  @@ -23,7 +23,7 @@
    * @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 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/28 22:04:50 $
    * @since 4.1
    */
   public class ConfigurableRoleManager
  @@ -37,6 +37,9 @@
       /** Map for role to default classname mapping */
       private Map               m_classNames;
   
  +    /** Map for role to default classname mapping */
  +    private Map               m_handlerNames;
  +
       /** Map for role->hint to classname mapping */
       private Map               m_hintClassNames;
   
  @@ -127,6 +130,27 @@
       }
   
       /**
  +     * 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.
  +     *
  +     * @param role  The role that has a default implementation.
  +     * @return the Fully Qualified Class Name (FQCN) for the role.
  +     */
  +    public final String getHandlerClassNameForClassname( final String 
className )
  +    {
  +        final String handlerName = (String)m_handlerNames.get( className );
  +
  +        if( null == handlerName && null != m_parent )
  +        {
  +            return m_parent.getHandlerClassNameForClassname( className );
  +        }
  +
  +        return handlerName;
  +    }
  +
  +    /**
        * 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
  @@ -202,6 +226,7 @@
       {
           final Map shorts = new HashMap();
           final Map classes = new HashMap();
  +        final Map handlers = new HashMap();
           final Map hintclasses = new HashMap();
   
           final Configuration[] roles = configuration.getChildren( "role" );
  @@ -212,6 +237,9 @@
               final String shorthand = roles[ i ].getAttribute( "shorthand" );
               final String defaultClassName =
                   roles[ i ].getAttribute( "default-class", null );
  +            final String handlerClassName =
  +                roles[ i ].getAttribute( "handler",
  +                
"org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
   
               shorts.put( shorthand, name );
               shorts.put( name, shorthand );
  @@ -219,7 +247,7 @@
               if( null != defaultClassName )
               {
                   classes.put( name, defaultClassName );
  -                classes.put( defaultClassName, name );
  +                handlers.put( defaultClassName, handlerClassName );
               }
   
               final Configuration[] hints = roles[ i ].getChildren( "hint" );
  @@ -231,9 +259,12 @@
                   {
                       final String shortHand = hints[ j 
].getAttribute("shorthand").trim();
                       final String className = hints[ j 
].getAttribute("class").trim();
  +                    final String handlerName = hints[ j ].getAttribute( 
"handler",
  +                        
"org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
   
                       hintMap.put( shortHand, className );
                       hintMap.put( className, shortHand );
  +                    handlers.put( className, handlerName );
                   }
   
                   hintclasses.put( name, Collections.unmodifiableMap( hintMap 
) );
  @@ -242,6 +273,7 @@
   
           m_shorthands = Collections.unmodifiableMap( shorts );
           m_classNames = Collections.unmodifiableMap( classes );
  +        m_handlerNames = Collections.unmodifiableMap( handlers );
           m_hintClassNames = Collections.unmodifiableMap( hintclasses );
       }
   }
  
  
  
  1.2       +60 -2     
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ExcaliburRoleManager.java
  
  Index: ExcaliburRoleManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ExcaliburRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburRoleManager.java 25 Jan 2002 20:15:11 -0000      1.1
  +++ ExcaliburRoleManager.java 28 Jan 2002 22:04:50 -0000      1.2
  @@ -16,7 +16,7 @@
    * 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 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/28 22:04:50 $
    * @since 4.1
    */
   public class ExcaliburRoleManager
  @@ -30,6 +30,9 @@
       /** Map for role to default classname mapping */
       private Map               m_classNames;
   
  +    /** Map for role to handler classname mapping */
  +    private Map               m_handlerNames;
  +
       /** Map for role->hint to classname mapping */
       private Map               m_hintClassNames;
   
  @@ -56,6 +59,7 @@
           HashMap shorts = new HashMap( 10 );
           HashMap classes = new HashMap( 10 );
           HashMap hints = new HashMap( 5 );
  +        HashMap handlers = new HashMap( 10 );
   
           /* Set up DataSource relations */
           shorts.put( "datasource", 
"org.apache.avalon.excalibur.datasource.DataSourceComponent" );
  @@ -81,6 +85,13 @@
           hints.put( 
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
                      Collections.unmodifiableMap( dsMap ) );
   
  +        handlers.put( 
"org.apache.avalon.excalibur.datasource.JdbcDataSource",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        handlers.put( 
"org.apache.avalon.excalibur.datasource.InformixDataSource",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        handlers.put( 
"org.apache.avalon.excalibur.datasource.J2eeDataSource",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
           /* Set up Monitor relations */
           shorts.put( "monitor", "org.apache.avalon.excalibur.monitor.Monitor" 
);
           shorts.put( "org.apache.avalon.excalibur.monitor.Monitor", "monitor" 
);
  @@ -89,6 +100,11 @@
           classes.put( "org.apache.avalon.excalibur.monitor.ActiveMonitor",
                        "org.apache.avalon.excalibur.monitor.Monitor" );
   
  +        handlers.put( "org.apache.avalon.excalibur.monitor.ActiveMonitor",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        handlers.put( "org.apache.avalon.excalibur.monitor.PassiveMonitor",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
           /* Set up XPath relations */
           shorts.put( "xpath", 
"org.apache.avalon.excalibur.xml.xpath.XPathProcessor" );
           shorts.put( "org.apache.avalon.excalibur.xml.xpath.XPathProcessor", 
"xpath" );
  @@ -97,6 +113,11 @@
           classes.put( 
"org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl",
                        "org.apache.avalon.excalibur.xml.xpath.XPathProcessor" 
);
   
  +        handlers.put( 
"org.apache.avalon.excalibur.xml.xpath.XPathProcessorImpl",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        handlers.put( 
"org.apache.avalon.excalibur.xml.xpath.JaxenProcessorImpl",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
           /* Set up i18n relations */
           shorts.put( "i18n", "org.apache.avalon.excalibur.i18n.Bundle" );
           shorts.put( "org.apache.avalon.excalibur.i18n.Bundle", "i18n" );
  @@ -112,6 +133,13 @@
           hints.put( 
"org.apache.avalon.excalibur.datasource.DataSourceComponentSelector",
                      Collections.unmodifiableMap( bundleMap ) );
   
  +        handlers.put( "org.apache.avalon.excalibur.i18n.BundleSelector",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +        handlers.put( "org.apache.avalon.excalibur.i18n.XmlBundle",
  +                      
"org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  +        handlers.put( "org.apache.avalon.excalibur.i18n.FlatXmlBundle",
  +                      
"org.apache.avalon.excalibur.system.handler.PerThreadComponentHandler" );
  +
           /* Set up SourceResolver relations */
           shorts.put( "resolver", 
"org.apache.avalon.excalibur.source.SourceResolver" );
           shorts.put( "org.apache.avalon.excalibur.source.SourceResolver", 
"resolver" );
  @@ -120,7 +148,10 @@
           classes.put( "org.apache.avalon.excalibur.source.SourceResolverImpl",
                        "org.apache.avalon.excalibur.source.SourceResolver" );
   
  -        /* Set up SourceResolver relations */
  +        handlers.put( 
"org.apache.avalon.excalibur.source.SourceResolverImpl",
  +                      
"org.apache.avalon.excalibur.system.handler.ThreadSafeComponentHandler" );
  +
  +        /* Set up XML parser 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",
  @@ -128,9 +159,15 @@
           classes.put( "org.apache.avalon.excalibur.xml.JaxpParser",
                        "org.apache.avalon.excalibur.xml.Parser" );
   
  +        handlers.put( "org.apache.avalon.excalibur.xml.JaxpParser",
  +                      
"org.apache.avalon.excalibur.system.handler.PoolableComponentHandler" );
  +        handlers.put( "org.apache.avalon.excalibur.xml.XercesParser",
  +                      
"org.apache.avalon.excalibur.system.handler.FactoryComponentHandler" );
  +
           m_shorthands = Collections.unmodifiableMap( shorts );
           m_classNames = Collections.unmodifiableMap( classes );
           m_hintClassNames = Collections.unmodifiableMap( hints );
  +        m_handlerNames = Collections.unmodifiableMap( handlers );
       }
   
       /**
  @@ -173,6 +210,27 @@
           }
   
           return role;
  +    }
  +
  +    /**
  +     * 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.
  +     *
  +     * @param role  The role that has a default implementation.
  +     * @return the Fully Qualified Class Name (FQCN) for the role.
  +     */
  +    public final String getHandlerClassNameForClassname( final String 
className )
  +    {
  +        final String handlerName = (String)m_handlerNames.get( className );
  +
  +        if( null == handlerName && null != m_parent )
  +        {
  +            return m_parent.getHandlerClassNameForClassname( className );
  +        }
  +
  +        return handlerName;
       }
   
       /**
  
  
  
  1.2       +12 -1     
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/RoleManager.java
  
  Index: RoleManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/RoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RoleManager.java  25 Jan 2002 20:15:11 -0000      1.1
  +++ RoleManager.java  28 Jan 2002 22:04:50 -0000      1.2
  @@ -15,7 +15,7 @@
    * possible.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/25 20:15:11 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/28 22:04:50 $
    * @since 4.1
    */
   public interface RoleManager
  @@ -40,6 +40,17 @@
        * Get the default classname for a given role.
        */
       String getDefaultClassNameForRole( String role );
  +
  +    /**
  +     * 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.
  +     *
  +     * @param role  The role that has a default implementation.
  +     * @return the Fully Qualified Class Name (FQCN) for the role.
  +     */
  +    String getHandlerClassNameForClassname( final String className );
   
       /**
        * Get the default classname for a given hint type.  This is only
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to