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/fortress/src/java/org/apache/excalibur/fortress/handler ComponentFactory.java
Date Sun, 10 Nov 2002 11:39:37 GMT
donaldp     2002/11/10 03:39:37

  Modified:    fortress/src/java/org/apache/excalibur/fortress/handler
                        ComponentFactory.java
  Log:
  touchups and extend AbstractLogEnabled
  
  Revision  Changes    Path
  1.35      +30 -20    jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ComponentFactory.java
  
  Index: ComponentFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/handler/ComponentFactory.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ComponentFactory.java	10 Nov 2002 02:59:17 -0000	1.34
  +++ ComponentFactory.java	10 Nov 2002 11:39:37 -0000	1.35
  @@ -55,20 +55,21 @@
   import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.logger.LogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
  -import org.apache.avalon.framework.logger.Loggable;
   import org.apache.avalon.framework.logger.LogKit2AvalonLoggerAdapter;
  +import org.apache.avalon.framework.logger.Loggable;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.excalibur.container.lifecycle.LifecycleExtensionManager;
   import org.apache.excalibur.instrument.CounterInstrument;
   import org.apache.excalibur.instrument.Instrument;
   import org.apache.excalibur.instrument.InstrumentManageable;
   import org.apache.excalibur.instrument.InstrumentManager;
   import org.apache.excalibur.instrument.Instrumentable;
   import org.apache.excalibur.mpool.ObjectFactory;
  -import org.apache.excalibur.container.lifecycle.LifecycleExtensionManager;
   
   /**
    * Factory for Avalon components.
  @@ -79,6 +80,7 @@
    * @since 4.0
    */
   public class ComponentFactory
  +    extends AbstractLogEnabled
       implements ObjectFactory, ThreadSafe, Instrumentable
   {
       private CounterInstrument m_newInstance;
  @@ -111,10 +113,6 @@
        */
       private LoggerManager m_loggerManager;
   
  -    /** The logger for the ComponentFactory
  -     */
  -    private Logger m_logger;
  -
       /** Lifecycle extensions manager
        */
       private final LifecycleExtensionManager m_extManager;
  @@ -146,7 +144,7 @@
           m_context = context;
           m_loggerManager = loggerManager;
           m_extManager = extManager;
  -        m_logger = m_loggerManager.getLoggerForCategory( "system.factory" );
  +        enableLogging( m_loggerManager.getLoggerForCategory( "system.factory" ) );
           m_instrumentManager = instrumentManager;
           m_instrumentableName = configuration.getAttribute( "id", componentClass.getName()
);
   
  @@ -159,10 +157,12 @@
       {
           final Object component = m_componentClass.newInstance();
   
  -        if( m_logger.isDebugEnabled() )
  +        if( getLogger().isDebugEnabled() )
           {
  -            m_logger.debug( "ComponentFactory creating new instance of " +
  -                            m_componentClass.getName() + "." );
  +            final String message =
  +                "ComponentFactory creating new instance of " +
  +                m_componentClass.getName() + ".";
  +            getLogger().debug( message );
           }
   
           if( component instanceof LogEnabled ||
  @@ -172,12 +172,20 @@
               final String name = ( m_configuration == null ? null : m_configuration.getAttribute(
"name", null ) );
               if( null == name )
               {
  -                if( m_logger.isDebugEnabled() ) m_logger.debug( "no name attribute available,
using standard name" );
  +                if( getLogger().isDebugEnabled() )
  +                {
  +                    final String message = "no name attribute available, using standard
name";
  +                    getLogger().debug( message );
  +                }
                   logger = m_loggerManager.getDefaultLogger();
               }
               else
               {
  -                if( m_logger.isDebugEnabled() ) m_logger.debug( "name attribute is " +
name );
  +                if( getLogger().isDebugEnabled() )
  +                {
  +                    final String message = "name attribute is " + name;
  +                    getLogger().debug( message );
  +                }
                   logger = m_loggerManager.getLoggerForCategory( name );
               }
   
  @@ -191,12 +199,12 @@
                       " implements the Loggable lifecycle stage. This is " +
                       " a deprecated feature that will be removed in the future. " +
                       " Please upgrade to using LogEnabled.";
  -                m_logger.warn( message );
  +                getLogger().warn( message );
                   System.out.println( message );
   
                   final org.apache.log.Logger logkitLogger =
                       LogKit2AvalonLoggerAdapter.createLogger( logger );
  -                ((Loggable)component).setLogger( logkitLogger );
  +                ( (Loggable)component ).setLogger( logkitLogger );
               }
           }
   
  @@ -246,10 +254,11 @@
       public final void dispose( final Object component )
           throws Exception
       {
  -        if( m_logger.isDebugEnabled() )
  +        if( getLogger().isDebugEnabled() )
           {
  -            m_logger.debug( "ComponentFactory decommissioning instance of " +
  -                            getCreatedClass().getName() + "." );
  +            final String message = "ComponentFactory decommissioning instance of " +
  +                getCreatedClass().getName() + ".";
  +            getLogger().debug( message );
           }
   
           if( getCreatedClass().equals( component.getClass() ) )
  @@ -283,7 +292,8 @@
   
       public final Instrument[] getInstruments()
       {
  -        return new Instrument[]{
  +        return new Instrument[]
  +        {
               m_newInstance,
               m_dispose
           };
  
  
  

--
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