avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler PoolableComponentHandler.java
Date Thu, 14 Feb 2002 22:00:29 GMT
bloritsch    02/02/14 14:00:29

  Modified:    src/java/org/apache/avalon/excalibur/monitor
                        ActiveMonitor.java
               src/scratchpad/org/apache/avalon/excalibur/system
                        ContainerManager.java
               src/scratchpad/org/apache/avalon/excalibur/system/handler
                        PoolableComponentHandler.java
  Log:
  Started to add Profile TestCase for ContainerManager--made fixes to bugs
  
  Revision  Changes    Path
  1.5       +3 -3      jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/monitor/ActiveMonitor.java
  
  Index: ActiveMonitor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/monitor/ActiveMonitor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ActiveMonitor.java	11 Dec 2001 16:14:31 -0000	1.4
  +++ ActiveMonitor.java	14 Feb 2002 22:00:29 -0000	1.5
  @@ -12,7 +12,7 @@
   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;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
   
   import java.lang.reflect.Constructor;
  @@ -38,9 +38,9 @@
    * </pre>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version $Id: ActiveMonitor.java,v 1.4 2001/12/11 16:14:31 bloritsch Exp $
  + * @version $Id: ActiveMonitor.java,v 1.5 2002/02/14 22:00:29 bloritsch Exp $
    */
  -public final class ActiveMonitor extends AbstractLoggable
  +public final class ActiveMonitor extends AbstractLogEnabled
       implements Monitor, Component, Startable, ThreadSafe, Configurable, Runnable
   {
       private static final Class[]    m_constructorParams = new Class[] { String.class };
  
  
  
  1.26      +70 -13    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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ContainerManager.java	14 Feb 2002 15:26:13 -0000	1.25
  +++ ContainerManager.java	14 Feb 2002 22:00:29 -0000	1.26
  @@ -109,7 +109,7 @@
    * </table>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.25 $ $Date: 2002/02/14 15:26:13 $
  + * @version CVS $Revision: 1.26 $ $Date: 2002/02/14 22:00:29 $
    */
   public class ContainerManager implements Disposable
   {
  @@ -137,6 +137,7 @@
       private final DefaultConfigurationSerializer m_configSerializer =
                                                        new DefaultConfigurationSerializer();
   
  +    private final Logger                  m_primordialLogger;
       private final Parameters              m_initialParameters;
       private final ClassLoader             m_contextClassLoader;
       private final File                    m_contextDirectory;
  @@ -163,7 +164,18 @@
       public ContainerManager( final Parameters initialParameters )
           throws InitializationException
       {
  -        this( initialParameters, null );
  +        this( initialParameters, new PrimordialLogger() );
  +    }
  +
  +    /**
  +     * This constructor creates a new ContainerManager with a PrimordialLogger
  +     * defined.
  +     */
  +    public ContainerManager( final Parameters initialParameters,
  +                             final Logger primordialLogger )
  +        throws InitializationException
  +    {
  +        this( initialParameters, primordialLogger, null, Thread.currentThread().getContextClassLoader()
);
       }
   
       /**
  @@ -185,6 +197,20 @@
                                final ClassLoader rootClassLoader )
           throws InitializationException
       {
  +        this( initialParameters, new PrimordialLogger(), defaultLogManager, rootClassLoader
);
  +    }
  +
  +    /**
  +     * Create a ContainerManager with all the information in the Context, and the
  +     * supplied LoggerManager.
  +     */
  +    public ContainerManager( final Parameters initialParameters,
  +                             final Logger primordialLogger,
  +                             final LoggerManager defaultLogManager,
  +                             final ClassLoader rootClassLoader )
  +        throws InitializationException
  +    {
  +        m_primordialLogger = ( null == primordialLogger ) ? new PrimordialLogger() : primordialLogger;
           m_initialParameters = initialParameters;
           m_contextClassLoader = rootClassLoader;
           m_contextDirectory = new File(initialParameters.getParameter( CONTEXT_DIRECTORY,
"./" ) );
  @@ -237,7 +263,7 @@
   
                   SourceResolverImpl resolver = new SourceResolverImpl();
                   resolver.enableLogging( getLogger() );
  -                resolver.contextualize( getContext() );
  +                resolver.contextualize( getRootContext() );
                   resolver.compose( manager );
                   manager.put( resolver.ROLE, resolver );
               }
  @@ -281,7 +307,7 @@
                   if ( instance instanceof LogEnabled )
                   {
                       m_validator.checkLogEnabled();
  -                    ( (LogEnabled) instance ).enableLogging( getLogger() );
  +                    ( (LogEnabled) instance ).enableLogging( getLogger(true) );
                   }
   
                   if ( instance instanceof Contextualizable )
  @@ -454,6 +480,19 @@
        */
       public Logger getLogger()
       {
  +        return getLogger( false );
  +    }
  +
  +    /**
  +     * Get a reference the default Logger.
  +     */
  +    public Logger getLogger(final boolean force)
  +    {
  +        if ( !force && m_logManager == null )
  +        {
  +            return m_primordialLogger;
  +        }
  +
           return getLoggerManager().getDefaultLogger();
       }
   
  @@ -506,11 +545,15 @@
               }
               else
               {
  +                SourceResolver resolver = null;
                   try
                   {
  -                    m_containerConfig = m_configBuilder.buildFromFile(
  -                            new File( m_contextDirectory, configFile )
  -                    );
  +                    resolver = (SourceResolver) getComponentManager().lookup(SourceResolver.ROLE);
  +                    Source src = resolver.resolve( configFile );
  +
  +                    m_containerConfig = m_configBuilder.build( src.getInputStream() );
  +
  +                    resolver.release( src );
                   }
                   catch (Exception e)
                   {
  @@ -521,6 +564,10 @@
                           getLogger().warn("Could not read configuration file: " + configFile,
e);
                       }
                   }
  +                finally
  +                {
  +                    getComponentManager().release(resolver);
  +                }
               }
           }
   
  @@ -586,18 +633,28 @@
               }
               else
               {
  +                SourceResolver resolver = null;
                   try
                   {
  -                    m_logKitConfig = m_configBuilder.buildFromFile(
  -                            new File( m_contextDirectory, configFile )
  -                    );
  +                    resolver = (SourceResolver) getComponentManager().lookup(SourceResolver.ROLE);
  +                    Source src = resolver.resolve( configFile );
  +
  +                    m_logKitConfig = m_configBuilder.build( src.getInputStream() );
  +
  +                    resolver.release( src );
                   }
                   catch (Exception e)
                   {
                       m_logKitConfig = EMPTY_CONFIG;
  -                    // We cannot log the exception as the logger has not been set up.
  -                    throw new CascadingRuntimeException(
  -                            "Could not load config file for LogKitConfig.", e );
  +
  +                    if ( getLogger().isWarnEnabled() )
  +                    {
  +                        getLogger().warn("Could not read configuration file: " + configFile,
e);
  +                    }
  +                }
  +                finally
  +                {
  +                    getComponentManager().release(resolver);
                   }
               }
           }
  
  
  
  1.6       +2 -2      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler/PoolableComponentHandler.java
  
  Index: PoolableComponentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/handler/PoolableComponentHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PoolableComponentHandler.java	12 Feb 2002 21:30:43 -0000	1.5
  +++ PoolableComponentHandler.java	14 Feb 2002 22:00:29 -0000	1.6
  @@ -25,7 +25,7 @@
    * and destroyed correctly.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2002/02/12 21:30:43 $
  + * @version CVS $Revision: 1.6 $ $Date: 2002/02/14 22:00:29 $
    * @since 4.0
    */
   public final class PoolableComponentHandler implements ComponentHandler {
  @@ -62,7 +62,7 @@
               new ComponentFactory( componentClass, config, manager, context, roles, logkit
);
   
           PoolManager poolManager = (PoolManager) context.get( Container.POOL_MANAGER );
  -        m_pool = poolManager.getManagedPool( m_factory, config.getAttributeAsInteger( "pool-min",
4 ) );
  +        m_pool = poolManager.getManagedPool( m_factory, config.getAttributeAsInteger( "pool-min",
10 ) );
           m_logger = logkit.getLoggerForCategory("system.handler.poolable");
       }
   
  
  
  

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