You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/03/03 16:59:12 UTC

cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component DefaultComponentFactory.java DefaultComponentHandler.java ExcaliburComponentManager.java ExcaliburComponentSelector.java PoolableComponentHandler.java ThreadSafeComponentHandler.java

leif        02/03/03 07:59:12

  Modified:    src/java/org/apache/avalon/excalibur/component
                        DefaultComponentFactory.java
                        DefaultComponentHandler.java
                        ExcaliburComponentManager.java
                        ExcaliburComponentSelector.java
                        PoolableComponentHandler.java
                        ThreadSafeComponentHandler.java
  Log:
  Make key methods of the ExcaliburComponentManager protected so that they can
  be extended for the profiler.
  
  Revision  Changes    Path
  1.13      +35 -3     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
  
  Index: DefaultComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultComponentFactory.java	20 Feb 2002 09:44:25 -0000	1.12
  +++ DefaultComponentFactory.java	3 Mar 2002 15:59:11 -0000	1.13
  @@ -42,7 +42,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.12 $ $Date: 2002/02/20 09:44:25 $
  + * @version CVS $Revision: 1.13 $ $Date: 2002/03/03 15:59:11 $
    * @since 4.0
    */
   public class DefaultComponentFactory
  @@ -161,6 +161,11 @@
                   }
               }
           }
  +        
  +        // This was added to make it possible to implement a ProfilerComponentFactory without
  +        //  code duplication.  Once the issues there are worked out, this will most likely be
  +        //  removed as it is rather hackish.
  +        postLogger( component, m_configuration );
   
           if( component instanceof Contextualizable )
           {
  @@ -200,7 +205,12 @@
           {
               ((Initializable)component).initialize();
           }
  -
  +        
  +        // This was added to make it possible to implement a ProfilerComponentFactory without
  +        //  code duplication.  Once the issues there are worked out, this will most likely be
  +        //  removed as it is rather hackish.
  +        postInitialize( component, m_configuration );
  +        
           if( component instanceof Startable )
           {
               ((Startable)component).start();
  @@ -210,6 +220,28 @@
           
           return component;
       }
  +    
  +    /**
  +     * Called after a new component is initialized, but before it is started.  This was added
  +     *  to make it possible to implement the ProfilerComponentFactory without too much duplicate
  +     *  code.  WARNING:  Do not take advantage of this method as it will most likely be removed.
  +     */
  +    protected void postLogger( Object component, Configuration configuration )
  +        throws Exception
  +    {
  +        // Do nothing in this version.
  +    }
  +
  +    /**
  +     * Called after a new component is initialized, but before it is started.  This was added
  +     *  to make it possible to implement the ProfilerComponentFactory without too much duplicate
  +     *  code.  WARNING:  Do not take advantage of this method as it will most likely be removed.
  +     */
  +    protected void postInitialize( Object component, Configuration configuration )
  +        throws Exception
  +    {
  +        // Do nothing in this version.
  +    }
   
       public final Class getCreatedClass()
       {
  @@ -275,7 +307,7 @@
   
           return m_logEnabledLogger;
       }
  -
  +    
       private static class ComponentManagerProxy implements ComponentManager
       {
           private final ComponentManager m_realManager; 
  
  
  
  1.9       +22 -4     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java
  
  Index: DefaultComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultComponentHandler.java	20 Feb 2002 06:26:42 -0000	1.8
  +++ DefaultComponentHandler.java	3 Mar 2002 15:59:12 -0000	1.9
  @@ -22,10 +22,11 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.8 $ $Date: 2002/02/20 06:26:42 $
  + * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  + * @version CVS $Revision: 1.9 $ $Date: 2002/03/03 15:59:12 $
    * @since 4.0
    */
  -class DefaultComponentHandler
  +public class DefaultComponentHandler
       extends ComponentHandler
   {
       /** The instance of the ComponentFactory that creates and disposes of the Component */
  @@ -50,9 +51,26 @@
                                          final LogKitManager logkit )
           throws Exception
       {
  -        m_factory = new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit );
  +        this( 
  +            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            config );
       }
  -
  +    
  +    /**
  +     * Create a DefaultComponentHandler which manages a pool of Components
  +     *  created by the specified factory object.
  +     *
  +     * @param factory The factory object which is responsible for creating the components
  +     *                managed by the ComponentHandler.
  +     * @param config The configuration to use to configure the pool.
  +     */
  +    public DefaultComponentHandler( final DefaultComponentFactory factory,
  +                                       final Configuration config )
  +        throws Exception
  +    {
  +        m_factory = factory;
  +    }										
  +    
       /**
        * Sets the logger that the ComponentHandler will use.
        */
  
  
  
  1.20      +44 -17    jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
  
  Index: ExcaliburComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ExcaliburComponentManager.java	22 Feb 2002 07:29:22 -0000	1.19
  +++ ExcaliburComponentManager.java	3 Mar 2002 15:59:12 -0000	1.20
  @@ -36,7 +36,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.19 $ $Date: 2002/02/22 07:29:22 $
  + * @version CVS $Revision: 1.20 $ $Date: 2002/03/03 15:59:12 $
    * @since 4.0
    */
   public class ExcaliburComponentManager
  @@ -297,13 +297,11 @@
   
                           final Configuration configuration = new DefaultConfiguration( "", "-" );
   
  -                        handler =
  -                            ComponentHandler.getComponentHandler( componentClass,
  -                                                                  configuration,
  -                                                                  this,
  -                                                                  m_context,
  -                                                                  m_roles,
  -                                                                  m_logkit);
  +                        handler = getComponentHandler( componentClass,
  +                                                       configuration,
  +                                                       m_context,
  +                                                       m_roles,
  +                                                       m_logkit );
   
                           handler.setLogger( getLogger() );
                           handler.initialize();
  @@ -539,10 +537,41 @@
           }
       }
   
  -    /** Add a new component to the manager.
  +    /**
  +     * Obtain a new ComponentHandler for the specified component.  This method
  +     *  allows classes which extend the ExcaliburComponentManager to use their
  +     *  own ComponentHandlers.
  +     *
  +     * @param componentClass Class of the component for which the handle is
  +     *                       being requested.
  +     * @param configuration The configuration for this component.
  +     * @param context The current context object.
  +     * @param roleManager The current RoleManager.
  +     * @param logkitManager The current LogKitManager.
  +     *
  +     * @throws Exception If there were any problems obtaining a ComponentHandler
  +     */
  +    protected ComponentHandler getComponentHandler( final Class componentClass,
  +                                                    final Configuration configuration,
  +                                                    final Context context,
  +                                                    final RoleManager roleManager,
  +                                                    final LogKitManager logkitManager )
  +        throws Exception
  +    {
  +        return ComponentHandler.getComponentHandler( componentClass,
  +                                                     configuration,
  +                                                     this,
  +                                                     context,
  +                                                     roleManager,
  +                                                     logkitManager );
  +    }
  +    
  +    /**
  +     * Add a new component to the manager.
  +     *
        * @param role the role name for the new component.
        * @param component the class of this component.
  -     * @param Configuration the configuration for this component.
  +     * @param configuration the configuration for this component.
        */
       public void addComponent( final String role,
                                 final Class component,
  @@ -561,13 +590,11 @@
                   getLogger().debug("Attempting to get Handler for: " + role);
               }
   
  -            final ComponentHandler handler =
  -                ComponentHandler.getComponentHandler( component,
  -                                                      configuration,
  -                                                      this,
  -                                                      m_context,
  -                                                      m_roles,
  -                                                      m_logkit );
  +            final ComponentHandler handler = getComponentHandler( component,
  +                                                                  configuration,
  +                                                                  m_context,
  +                                                                  m_roles,
  +                                                                  m_logkit );
   
               if (getLogger().isDebugEnabled())
               {
  
  
  
  1.12      +39 -8     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
  
  Index: ExcaliburComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ExcaliburComponentSelector.java	15 Feb 2002 20:12:10 -0000	1.11
  +++ ExcaliburComponentSelector.java	3 Mar 2002 15:59:12 -0000	1.12
  @@ -37,7 +37,7 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
  - * @version CVS $Revision: 1.11 $ $Date: 2002/02/15 20:12:10 $
  + * @version CVS $Revision: 1.12 $ $Date: 2002/03/03 15:59:12 $
    * @since 4.0
    */
   public class ExcaliburComponentSelector
  @@ -436,6 +436,38 @@
           m_componentMapping.remove( component );
       }
   
  +    /**
  +     * Obtain a new ComponentHandler for the specified component.  This method
  +     *  allows classes which extend the ExcaliburComponentSelector to use their
  +     *  own ComponentHandlers.
  +     *
  +     * @param componentClass Class of the component for which the handle is
  +     *                       being requested.
  +     * @param configuration The configuration for this component.
  +     * @param componentManager The ComponentManager which will be managing
  +     *                         the Component.
  +     * @param context The current context object.
  +     * @param roleManager The current RoleManager.
  +     * @param logkitManager The current LogKitManager.
  +     *
  +     * @throws Exception If there were any problems obtaining a ComponentHandler
  +     */
  +    protected ComponentHandler getComponentHandler( final Class componentClass,
  +                                                    final Configuration configuration,
  +                                                    final ComponentManager componentManager,
  +                                                    final Context context,
  +                                                    final RoleManager roleManager,
  +                                                    final LogKitManager logkitManager )
  +        throws Exception
  +    {
  +        return ComponentHandler.getComponentHandler( componentClass,
  +                                                     configuration,
  +                                                     componentManager,
  +                                                     context,
  +                                                     roleManager,
  +                                                     logkitManager );
  +    }
  +    
       /** Add a new component to the manager.
        * @param hint the hint name for the new component.
        * @param component the class of this component.
  @@ -453,13 +485,12 @@
   
           try
           {
  -            final ComponentHandler handler =
  -                ComponentHandler.getComponentHandler( component,
  -                                                      configuration,
  -                                                      m_componentManager,
  -                                                      m_context,
  -                                                      m_roles,
  -                                                      m_logkit );
  +            final ComponentHandler handler = getComponentHandler( component,
  +                                                                  configuration,
  +                                                                  m_componentManager,
  +                                                                  m_context,
  +                                                                  m_roles,
  +                                                                  m_logkit );
   
               handler.setLogger( getLogger() );
               handler.initialize();
  
  
  
  1.11      +19 -3     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PoolableComponentHandler.java	26 Feb 2002 07:49:56 -0000	1.10
  +++ PoolableComponentHandler.java	3 Mar 2002 15:59:12 -0000	1.11
  @@ -84,7 +84,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.10 $ $Date: 2002/02/26 07:49:56 $
  + * @version CVS $Revision: 1.11 $ $Date: 2002/03/03 15:59:12 $
    * @since 4.0
    */
   public class PoolableComponentHandler extends ComponentHandler {
  @@ -116,8 +116,24 @@
                                           final LogKitManager logkit )
           throws Exception
       {
  -        m_factory =
  -            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit );
  +        this( 
  +            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            config );
  +    }
  +    
  +    /**
  +     * Create a PoolableComponentHandler which manages a pool of Components
  +     *  created by the specified factory object.
  +     *
  +     * @param factory The factory object which is responsible for creating the components
  +     *                managed by the ComponentHandler.
  +     * @param config The configuration to use to configure the pool.
  +     */
  +    public PoolableComponentHandler( final DefaultComponentFactory factory,
  +                                        final Configuration config )
  +        throws Exception
  +    {
  +        m_factory = factory;
   
           int     poolMax       = config.getAttributeAsInteger( "pool-max", DEFAULT_MAX_POOL_SIZE );
           boolean poolMaxStrict = config.getAttributeAsBoolean( "pool-max-strict", false );
  
  
  
  1.10      +21 -3     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java
  
  Index: ThreadSafeComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ThreadSafeComponentHandler.java	20 Feb 2002 06:26:42 -0000	1.9
  +++ ThreadSafeComponentHandler.java	3 Mar 2002 15:59:12 -0000	1.10
  @@ -22,7 +22,8 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.9 $ $Date: 2002/02/20 06:26:42 $
  + * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  + * @version CVS $Revision: 1.10 $ $Date: 2002/03/03 15:59:12 $
    * @since 4.0
    */
   public class ThreadSafeComponentHandler extends ComponentHandler {
  @@ -44,9 +45,26 @@
                                             final LogKitManager logkit )
           throws Exception
       {
  -        m_factory = new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit );
  +        this( 
  +            new DefaultComponentFactory( componentClass, config, manager, context, roles, logkit ),
  +            config );
       }
  -
  +    
  +    /**
  +     * Create a ThreadSafeComponentHandler which manages a pool of Components
  +     *  created by the specified factory object.
  +     *
  +     * @param factory The factory object which is responsible for creating the components
  +     *                managed by the ComponentHandler.
  +     * @param config The configuration to use to configure the pool.
  +     */
  +    public ThreadSafeComponentHandler( final DefaultComponentFactory factory,
  +                                          final Configuration config )
  +        throws Exception
  +    {
  +        m_factory = factory;
  +    }										
  +    
       /**
        * Create a ComponentHandler that takes care of hiding the details of
        * whether a Component is ThreadSafe, Poolable, or SingleThreaded.
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>