avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/component/src/test/org/apache/avalon/excalibur/component/test ExcaliburComponentManagerTestCase.java
Date Sun, 02 Jun 2002 06:03:01 GMT
donaldp     2002/06/01 23:03:01

  Modified:    component README.txt
               component/src/java/org/apache/avalon/excalibur/component
                        ComponentHandler.java DefaultComponentFactory.java
                        DefaultComponentHandler.java
                        DefaultRoleManager.java
                        ExcaliburComponentManager.java
                        ExcaliburComponentSelector.java
                        PoolableComponentHandler.java
                        ThreadSafeComponentHandler.java
               component/src/test/org/apache/avalon/excalibur/component/test
                        ExcaliburComponentManagerTestCase.java
  Added:       component/src/java/org/apache/avalon/excalibur/component
                        AbstractDualLogEnabled.java
                        LogKit2LoggerTarget.java Logger2LogKitManager.java
                        LogkitLoggerManager.java
  Log:
  Merge in the LogEnabled changes to ECM.
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-avalon-excalibur/component/README.txt
  
  Index: README.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/README.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- README.txt	4 Apr 2002 05:09:02 -0000	1.1
  +++ README.txt	2 Jun 2002 06:03:01 -0000	1.2
  @@ -1,5 +1,5 @@
  -                Avalons Excalibur TestCase
  -                --------------------------
  +                Avalons Excalibur ComponentManager 
  +                ----------------------------------
   
   This project contains utilities for managing components.  In particular,
   the ExcaliburComponentManager.
  
  
  
  1.3       +4 -6      jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java
  
  Index: ComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ComponentHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ComponentHandler.java	13 May 2002 12:17:41 -0000	1.2
  +++ ComponentHandler.java	2 Jun 2002 06:03:01 -0000	1.3
  @@ -7,7 +7,6 @@
    */
   package org.apache.avalon.excalibur.component;
   
  -import org.apache.avalon.excalibur.logger.LogKitManager;
   import org.apache.avalon.excalibur.pool.Poolable;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -15,7 +14,6 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.SingleThreaded;
   import org.apache.avalon.framework.thread.ThreadSafe;
   
  @@ -26,13 +24,13 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
    * @author <a href="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/05/13 12:17:41 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
  -public abstract class ComponentHandler extends AbstractLoggable
  +public abstract class ComponentHandler
  +    extends AbstractDualLogEnabled
       implements Initializable, Disposable
   {
  -
       private Object m_referenceSemaphore = new Object();
       private int m_references = 0;
   
  @@ -42,7 +40,7 @@
           final ComponentManager manager,
           final Context context,
           final RoleManager roles,
  -        final LogKitManager logkit )
  +        final LogkitLoggerManager logkit )
           throws Exception
       {
           int numInterfaces = 0;
  
  
  
  1.3       +14 -31    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java
  
  Index: DefaultComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultComponentFactory.java	12 May 2002 23:38:30 -0000	1.2
  +++ DefaultComponentFactory.java	2 Jun 2002 06:03:01 -0000	1.3
  @@ -11,7 +11,6 @@
   import java.util.Collection;
   import org.apache.avalon.excalibur.collections.BucketMap;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
  -import org.apache.avalon.excalibur.logger.LogKitManager;
   import org.apache.avalon.excalibur.pool.ObjectFactory;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -24,9 +23,7 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.logger.LogEnabled;
  -import org.apache.avalon.framework.logger.LogKitLogger;
   import org.apache.avalon.framework.logger.Loggable;
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
  @@ -38,11 +35,11 @@
    * @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.2 $ $Date: 2002/05/12 23:38:30 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
   public class DefaultComponentFactory
  -    extends AbstractLoggable
  +    extends AbstractDualLogEnabled
       implements ObjectFactory, Disposable, ThreadSafe
   {
       /** The class which this <code>ComponentFactory</code>
  @@ -66,13 +63,9 @@
        */
       private RoleManager m_roles;
   
  -    /** The LogKitManager for child ComponentSelectors
  +    /** The LogkitLoggerManager for child ComponentSelectors
        */
  -    private LogKitManager m_logkit;
  -
  -    /** The org.apache.avalon.framework.logger.Logger instance.
  -     */
  -    private org.apache.avalon.framework.logger.Logger m_logEnabledLogger;
  +    private LogkitLoggerManager m_logkit;
   
       /** Components created by this factory, and their associated ComponentManager
        *  proxies, if they are Composables.
  @@ -93,7 +86,7 @@
                                       final ComponentManager componentManager,
                                       final Context context,
                                       final RoleManager roles,
  -                                    final LogKitManager logkit )
  +                                    final LogkitLoggerManager logkit )
       {
           m_componentClass = componentClass;
           m_configuration = configuration;
  @@ -118,7 +111,7 @@
           {
               if( null == m_logkit || null == m_configuration )
               {
  -                ( (LogEnabled)component ).enableLogging( getLogEnabledLogger() );
  +                ( (LogEnabled)component ).enableLogging( getLogger() );
               }
               else
               {
  @@ -126,12 +119,12 @@
                   if( null == logger )
                   {
                       getLogger().debug( "no logger attribute available, using standard logger"
);
  -                    ( (LogEnabled)component ).enableLogging( getLogEnabledLogger() );
  +                    ( (LogEnabled)component ).enableLogging( getLogger() );
                   }
                   else
                   {
                       getLogger().debug( "logger attribute is " + logger );
  -                    ( (LogEnabled)component ).enableLogging( new LogKitLogger( m_logkit.getLogger(
logger ) ) );
  +                    ( (LogEnabled)component ).enableLogging( m_logkit.getLoggerForCategory(
logger ) );
                   }
               }
           }
  @@ -140,7 +133,7 @@
           {
               if( null == m_logkit || null == m_configuration )
               {
  -                ( (Loggable)component ).setLogger( getLogger() );
  +                ( (Loggable)component ).setLogger( getLogkitLogger() );
               }
               else
               {
  @@ -148,12 +141,12 @@
                   if( null == logger )
                   {
                       getLogger().debug( "no logger attribute available, using standard logger"
);
  -                    ( (Loggable)component ).setLogger( getLogger() );
  +                    ( (Loggable)component ).setLogger( getLogkitLogger() );
                   }
                   else
                   {
                       getLogger().debug( "logger attribute is " + logger );
  -                    ( (Loggable)component ).setLogger( m_logkit.getLogger( logger ) );
  +                    ( (Loggable)component ).setLogger( m_logkit.getLogKitLoggerForCategory(
logger ) );
                   }
               }
           }
  @@ -184,7 +177,7 @@
   
           if( component instanceof LogKitManageable )
           {
  -            ( (LogKitManageable)component ).setLogKitManager( m_logkit );
  +            ( (LogKitManageable)component ).setLogKitManager( m_logkit.getLogKitManager()
);
           }
   
           if( component instanceof Configurable )
  @@ -297,23 +290,13 @@
           m_components.remove( component );
       }
   
  -    protected org.apache.avalon.framework.logger.Logger getLogEnabledLogger()
  -    {
  -        if( null == m_logEnabledLogger )
  -        {
  -            m_logEnabledLogger = new LogKitLogger( getLogger() );
  -        }
  -
  -        return m_logEnabledLogger;
  -    }
  -
       /**
        * Proxy <code>ComponentManager</code> class to maintain references to
        * components looked up within a <code>Composable</code> instance created
        * by this factory.
        *
        * This class acts a safety net to ensure that all components looked
  -     * up within a <code>Composable</code> instance created by this factory
are 
  +     * up within a <code>Composable</code> instance created by this factory
are
        * released when the instance itself is released.
        */
       private static class ComponentManagerProxy implements ComponentManager
  @@ -358,7 +341,7 @@
           }
   
           /**
  -         * Releases all components that have been looked up through this 
  +         * Releases all components that have been looked up through this
            * <code>ComponentManager</code>, that have not yet been released
            * via user code.
            */
  
  
  
  1.2       +7 -17     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java
  
  Index: DefaultComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultComponentHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentHandler.java	4 Apr 2002 05:09:02 -0000	1.1
  +++ DefaultComponentHandler.java	2 Jun 2002 06:03:01 -0000	1.2
  @@ -7,13 +7,11 @@
    */
   package org.apache.avalon.excalibur.component;
   
  -import org.apache.avalon.excalibur.logger.LogKitManager;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.log.Logger;
   
   /**
    * The DefaultComponentHandler to make sure components are initialized
  @@ -22,7 +20,7 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
    * @author <a href="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/04/04 05:09:02 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
   public class DefaultComponentHandler
  @@ -32,10 +30,10 @@
       private final DefaultComponentFactory m_factory;
   
       /** State management boolean stating whether the Handler is initialized or not */
  -    private boolean m_initialized = false;
  +    private boolean m_initialized;
   
       /** State management boolean stating whether the Handler is disposed or not */
  -    private boolean m_disposed = false;
  +    private boolean m_disposed;
   
       /**
        * Create a ComponentHandler that takes care of hiding the details of
  @@ -47,7 +45,7 @@
                                          final ComponentManager manager,
                                          final Context context,
                                          final RoleManager roles,
  -                                       final LogKitManager logkit )
  +                                       final LogkitLoggerManager logkit )
           throws Exception
       {
           this(
  @@ -71,16 +69,6 @@
       }
   
       /**
  -     * Sets the logger that the ComponentHandler will use.
  -     */
  -    public void setLogger( final Logger logger )
  -    {
  -        m_factory.setLogger( logger );
  -
  -        super.setLogger( logger );
  -    }
  -
  -    /**
        * Initialize the ComponentHandler.
        */
       public void initialize()
  @@ -89,10 +77,12 @@
           {
               return;
           }
  +        m_factory.setLogger( getLogkitLogger() );
  +        m_factory.enableLogging( getLogger() );
   
           if( getLogger().isDebugEnabled() )
           {
  -            getLogger().debug( "ComponentHandler initialized for: " + this.m_factory.getCreatedClass().getName()
);
  +            getLogger().debug( "ComponentHandler initialized for: " + m_factory.getCreatedClass().getName()
);
           }
           m_initialized = true;
       }
  
  
  
  1.2       +12 -4     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultRoleManager.java
  
  Index: DefaultRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/DefaultRoleManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRoleManager.java	4 Apr 2002 05:09:02 -0000	1.1
  +++ DefaultRoleManager.java	2 Jun 2002 06:03:01 -0000	1.2
  @@ -13,7 +13,6 @@
   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;
   
   /**
    * Default RoleManager implementation.  It populates the RoleManager
  @@ -22,11 +21,11 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/04/04 05:09:02 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
   public class DefaultRoleManager
  -    extends AbstractLoggable
  +    extends AbstractDualLogEnabled
       implements RoleManager, Configurable
   {
       /** Map for shorthand to role mapping */
  @@ -148,7 +147,16 @@
               getLogger().debug( "looking up classname for hint " + shorthand );
           }
   
  -        return (String)hintMap.get( shorthand );
  +        final String s = ( String ) hintMap.get( shorthand );
  +
  +        if( s == null && null != m_parent )
  +        {
  +            return m_parent.getDefaultClassNameForHint( role, shorthand );
  +        }
  +        else
  +        {
  +            return s;
  +        }
       }
   
       /**
  
  
  
  1.6       +27 -13    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java
  
  Index: ExcaliburComponentManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExcaliburComponentManager.java	13 May 2002 12:17:41 -0000	1.5
  +++ ExcaliburComponentManager.java	2 Jun 2002 06:03:01 -0000	1.6
  @@ -13,6 +13,7 @@
   import org.apache.avalon.excalibur.collections.BucketMap;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.excalibur.logger.LoggerManager;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
  @@ -24,7 +25,6 @@
   import org.apache.avalon.framework.configuration.DefaultConfiguration;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
   
   /**
    * Default component manager for Avalon's components.
  @@ -32,11 +32,11 @@
    * @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.5 $ $Date: 2002/05/13 12:17:41 $
  + * @version CVS $Revision: 1.6 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
   public class ExcaliburComponentManager
  -    extends AbstractLoggable
  +    extends AbstractDualLogEnabled
       implements ComponentManager,
       Configurable,
       Contextualizable,
  @@ -64,7 +64,7 @@
       private RoleManager m_roles;
   
       /** LogKitManager. */
  -    private LogKitManager m_logkit;
  +    private LogkitLoggerManager m_logkit;
   
       /** Is the Manager disposed or not? */
       private boolean m_disposed;
  @@ -308,7 +308,8 @@
                                                          m_roles,
                                                          m_logkit );
   
  -                        handler.setLogger( getLogger() );
  +                        handler.setLogger( getLogkitLogger() );
  +                        handler.enableLogging( getLogger() );
                           handler.initialize();
                       }
                       catch( final Exception e )
  @@ -392,10 +393,10 @@
       {
           if( null == m_roles )
           {
  -            DefaultRoleManager role_info = new DefaultRoleManager();
  -            role_info.setLogger( getLogger() );
  -            role_info.configure( configuration );
  -            m_roles = role_info;
  +            final DefaultRoleManager roleInfo = new DefaultRoleManager();
  +            roleInfo.enableLogging( getLogger() );
  +            roleInfo.configure( configuration );
  +            m_roles = roleInfo;
               getLogger().debug( "No RoleManager given, deriving one from configuration"
);
           }
   
  @@ -490,7 +491,18 @@
       {
           if( null == m_logkit )
           {
  -            m_logkit = logkit;
  +            m_logkit = new LogkitLoggerManager( null, logkit );
  +        }
  +    }
  +
  +    /**
  +     * Configure the LoggerManager.
  +     */
  +    public void setLoggerManager( final LoggerManager logkit )
  +    {
  +        if( null == m_logkit )
  +        {
  +            m_logkit = new LogkitLoggerManager( logkit, null );
           }
       }
   
  @@ -569,7 +581,7 @@
                                                       final Configuration configuration,
                                                       final Context context,
                                                       final RoleManager roleManager,
  -                                                    final LogKitManager logkitManager )
  +                                                    final LogkitLoggerManager logkitManager
)
           throws Exception
       {
           return ComponentHandler.getComponentHandler( componentClass,
  @@ -625,7 +637,8 @@
                   getLogger().debug( "Handler type = " + handler.getClass().getName() );
               }
   
  -            handler.setLogger( getLogger() );
  +            handler.setLogger( getLogkitLogger() );
  +            handler.enableLogging( getLogger() );
               m_componentHandlers.put( role, handler );
           }
           catch( final Exception e )
  @@ -650,7 +663,8 @@
           {
               ComponentHandler handler =
                   ComponentHandler.getComponentHandler( instance );
  -            handler.setLogger( getLogger() );
  +            handler.setLogger( getLogkitLogger() );
  +            handler.enableLogging( getLogger() );
               m_componentHandlers.put( role, handler );
           }
           catch( final Exception e )
  
  
  
  1.5       +36 -10    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java
  
  Index: ExcaliburComponentSelector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentSelector.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ExcaliburComponentSelector.java	13 May 2002 12:17:41 -0000	1.4
  +++ ExcaliburComponentSelector.java	2 Jun 2002 06:03:01 -0000	1.5
  @@ -13,6 +13,7 @@
   import org.apache.avalon.excalibur.collections.BucketMap;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.excalibur.logger.LoggerManager;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
  @@ -25,7 +26,6 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
  -import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.ThreadSafe;
   
   /**
  @@ -33,11 +33,11 @@
    *
    * @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.4 $ $Date: 2002/05/13 12:17:41 $
  + * @version CVS $Revision: 1.5 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
   public class ExcaliburComponentSelector
  -    extends AbstractLoggable
  +    extends AbstractDualLogEnabled
       implements Contextualizable,
       ComponentSelector,
       Composable,
  @@ -93,7 +93,7 @@
   
       /** The RoleManager to get hint shortcuts
        */
  -    private LogKitManager m_logkit;
  +    private LogkitLoggerManager m_logkit;
   
       /** Create the ComponentSelector */
       public ExcaliburComponentSelector()
  @@ -177,7 +177,19 @@
           if( !m_initialized ) return false;
           if( m_disposed ) return false;
   
  -        return m_componentHandlers.containsKey( hint );
  +        boolean exists = false;
  +
  +        try
  +        {
  +            this.release( this.select( hint ) );
  +            exists = true;
  +        }
  +        catch( Throwable t )
  +        {
  +            // We can safely ignore all exceptions
  +        }
  +
  +        return exists;
       }
   
       /**
  @@ -379,6 +391,7 @@
           }
       }
   
  +
       /**
        * Configure the LogKitManager
        */
  @@ -386,7 +399,18 @@
       {
           if( null == m_logkit )
           {
  -            m_logkit = logkit;
  +            m_logkit = new LogkitLoggerManager( null, logkit );
  +        }
  +    }
  +
  +    /**
  +     * Configure the LoggerManager.
  +     */
  +    public void setLoggerManager( final LoggerManager logkit )
  +    {
  +        if( null == m_logkit )
  +        {
  +            m_logkit = new LogkitLoggerManager( logkit, null );
           }
       }
   
  @@ -458,7 +482,7 @@
                                                       final ComponentManager componentManager,
                                                       final Context context,
                                                       final RoleManager roleManager,
  -                                                    final LogKitManager logkitManager )
  +                                                    final LogkitLoggerManager logkitManager
)
           throws Exception
       {
           return ComponentHandler.getComponentHandler( componentClass,
  @@ -482,7 +506,7 @@
       /** Add a new component to the manager.
        * @param hint the hint 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 Object hint,
                                 final Class component,
  @@ -503,7 +527,8 @@
                                                                     m_roles,
                                                                     m_logkit );
   
  -            handler.setLogger( getLogger() );
  +            handler.setLogger( getLogkitLogger() );
  +            handler.enableLogging( getLogger() );
               handler.initialize();
               m_componentHandlers.put( hint, handler );
   
  @@ -540,7 +565,8 @@
           {
               final ComponentHandler handler =
                   ComponentHandler.getComponentHandler( instance );
  -            handler.setLogger( getLogger() );
  +            handler.setLogger( getLogkitLogger() );
  +            handler.enableLogging( getLogger() );
               handler.initialize();
               m_componentHandlers.put( hint, handler );
   
  
  
  
  1.4       +8 -17     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/PoolableComponentHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PoolableComponentHandler.java	13 May 2002 12:17:41 -0000	1.3
  +++ PoolableComponentHandler.java	2 Jun 2002 06:03:01 -0000	1.4
  @@ -7,7 +7,6 @@
    */
   package org.apache.avalon.excalibur.component;
   
  -import org.apache.avalon.excalibur.logger.LogKitManager;
   import org.apache.avalon.excalibur.pool.Poolable;
   import org.apache.avalon.excalibur.pool.ResourceLimitingPool;
   import org.apache.avalon.framework.activity.Disposable;
  @@ -15,8 +14,6 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.logger.LogKitLogger;
  -import org.apache.log.Logger;
   
   /**
    * The PoolableComponentHandler to make sure that poolable components are initialized
  @@ -82,10 +79,11 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/05/13 12:17:41 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
  -public class PoolableComponentHandler extends ComponentHandler
  +public class PoolableComponentHandler
  +    extends ComponentHandler
   {
       /** The default max size of the pool */
       public static final int DEFAULT_MAX_POOL_SIZE = 8;
  @@ -112,7 +110,7 @@
                                           final ComponentManager manager,
                                           final Context context,
                                           final RoleManager roles,
  -                                        final LogKitManager logkit )
  +                                        final LogkitLoggerManager logkit )
           throws Exception
       {
           this(
  @@ -145,17 +143,6 @@
       }
   
       /**
  -     * Sets the logger that the ComponentHandler will use.
  -     */
  -    public void setLogger( final Logger logger )
  -    {
  -        m_factory.setLogger( logger );
  -        m_pool.enableLogging( new LogKitLogger( logger ) );
  -
  -        super.setLogger( logger );
  -    }
  -
  -    /**
        * Initialize the ComponentHandler.
        */
       public void initialize()
  @@ -164,6 +151,10 @@
           {
               return;
           }
  +
  +        m_factory.setLogger( getLogkitLogger() );
  +        m_factory.enableLogging( getLogger() );
  +        m_pool.enableLogging( getLogger() );
   
           if( getLogger().isDebugEnabled() )
           {
  
  
  
  1.3       +13 -19    jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java
  
  Index: ThreadSafeComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ThreadSafeComponentHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadSafeComponentHandler.java	10 Apr 2002 05:37:27 -0000	1.2
  +++ ThreadSafeComponentHandler.java	2 Jun 2002 06:03:01 -0000	1.3
  @@ -7,14 +7,12 @@
    */
   package org.apache.avalon.excalibur.component;
   
  -import org.apache.avalon.excalibur.logger.LogKitManager;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Startable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.context.Context;
  -import org.apache.log.Logger;
   
   /**
    * The ThreadSafeComponentHandler to make sure components are initialized
  @@ -23,10 +21,11 @@
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
    * @author <a href="mailto:leif@tanukisoftware.com">Leif Mortenson</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/04/10 05:37:27 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/06/02 06:03:01 $
    * @since 4.0
    */
  -public class ThreadSafeComponentHandler extends ComponentHandler
  +public class ThreadSafeComponentHandler
  +    extends ComponentHandler
   {
       private Component m_instance;
       private final DefaultComponentFactory m_factory;
  @@ -43,7 +42,7 @@
                                             final ComponentManager manager,
                                             final Context context,
                                             final RoleManager roles,
  -                                          final LogKitManager logkit )
  +                                          final LogkitLoggerManager logkit )
           throws Exception
       {
           this(
  @@ -78,16 +77,6 @@
           m_factory = null;
       }
   
  -    public void setLogger( Logger log )
  -    {
  -        if( this.m_factory != null )
  -        {
  -            m_factory.setLogger( log );
  -        }
  -
  -        super.setLogger( log );
  -    }
  -
       /**
        * Initialize the ComponentHandler.
        */
  @@ -98,21 +87,26 @@
           {
               return;
           }
  +        if( null != m_factory )
  +        {
  +            m_factory.setLogger( getLogkitLogger() );
  +            m_factory.enableLogging( getLogger() );
  +        }
   
           if( m_instance == null )
           {
  -            m_instance = (Component)this.m_factory.newInstance();
  +            m_instance = (Component)m_factory.newInstance();
           }
   
           if( getLogger().isDebugEnabled() )
           {
  -            if( this.m_factory != null )
  +            if( m_factory != null )
               {
  -                getLogger().debug( "ComponentHandler initialized for: " + this.m_factory.getCreatedClass().getName()
);
  +                getLogger().debug( "ComponentHandler initialized for: " + m_factory.getCreatedClass().getName()
);
               }
               else
               {
  -                getLogger().debug( "ComponentHandler initialized for: " + this.m_instance.getClass().getName()
);
  +                getLogger().debug( "ComponentHandler initialized for: " + m_instance.getClass().getName()
);
               }
           }
   
  
  
  
  1.2       +41 -0     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/AbstractDualLogEnabled.java
  
  
  
  
  1.2       +93 -0     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/LogKit2LoggerTarget.java
  
  
  
  
  1.2       +52 -0     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/Logger2LogKitManager.java
  
  
  
  
  1.2       +76 -0     jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/LogkitLoggerManager.java
  
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/component/src/test/org/apache/avalon/excalibur/component/test/ExcaliburComponentManagerTestCase.java
  
  Index: ExcaliburComponentManagerTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/test/org/apache/avalon/excalibur/component/test/ExcaliburComponentManagerTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExcaliburComponentManagerTestCase.java	4 Apr 2002 05:09:02 -0000	1.1
  +++ ExcaliburComponentManagerTestCase.java	2 Jun 2002 06:03:01 -0000	1.2
  @@ -37,7 +37,7 @@
    * it is correctly handling component lifestyle management.
    *
    * @author <a href="mailto:ryan@silveregg.co.jp">Ryan Shaw</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class ExcaliburComponentManagerTestCase extends TestCase
   {
  @@ -433,7 +433,7 @@
               {new StreamTarget( System.out, new PatternFormatter( pattern ) )} );
           logger.setPriority( Priority.INFO );
   
  -        m_manager.setLogger( logger );
  +        m_manager.enableLogging( new LogKitLogger( logger ) );
           m_manager.contextualize( new DefaultContext() );
           m_manager.configure( new DefaultConfiguration( "", "" ) );
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message