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

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util ContextBuilder.java ContextManager.java ContextManagerConstants.java

bloritsch    02/03/12 12:51:12

  Modified:    src/scratchpad/org/apache/avalon/excalibur/system
                        ContainerConstants.java
                        ContainerManagerConstants.java
               src/scratchpad/org/apache/avalon/excalibur/system/util
                        ContextBuilder.java ContextManager.java
                        ContextManagerConstants.java
  Log:
  enable hooks to use ProfileManager in container package
  
  Revision  Changes    Path
  1.2       +18 -16    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerConstants.java
  
  Index: ContainerConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerConstants.java	7 Mar 2002 07:03:15 -0000	1.1
  +++ ContainerConstants.java	12 Mar 2002 20:51:12 -0000	1.2
  @@ -11,24 +11,26 @@
    * Provides constants used to access the Context object for containers.
    * A container should allow these values to propagate down to child containers,
    * so that they may create child containers in turn.
  - * 
  + *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/03/07 07:03:15 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/03/12 20:51:12 $
    */
   public interface ContainerConstants
   {
  -    public static final String CONTEXT_CLASSLOADER = "container.classloader";
  -    public static final String CONTEXT_DIRECTORY   = "context-root";
  -    public static final String WORK_DIRECTORY      = "container.workDir";
  -    
  -    public static final String LOGGER_MANAGER      = "container.logManager";
  -    
  -    public static final String COMMAND_QUEUE       = "container.commandQueue";
  -    
  -    public static final String POOL_MANAGER        = "container.poolManager";
  -    
  -    public static final String ROLE_MANAGER        = "container.roleManager";
  -    
  -    public static final String THREADS_CPU         = "container.threadsPerCPU";
  -    public static final String THREAD_TIMEOUT      = "container.threadTimeout";    
  +    String CONTEXT_CLASSLOADER = "container.classloader";
  +    String CONTEXT_DIRECTORY   = "context-root";
  +    String WORK_DIRECTORY      = "container.workDir";
  +
  +    String LOGGER_MANAGER      = "container.logManager";
  +
  +    String COMMAND_QUEUE       = "container.commandQueue";
  +
  +    String POOL_MANAGER        = "container.poolManager";
  +
  +    String INSTRUMENT_MANAGER  = "container.instrumentManager";
  +
  +    String ROLE_MANAGER        = "container.roleManager";
  +
  +    String THREADS_CPU         = "container.threadsPerCPU";
  +    String THREAD_TIMEOUT      = "container.threadTimeout";
   }
  
  
  
  1.2       +9 -9      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManagerConstants.java
  
  Index: ContainerManagerConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManagerConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerManagerConstants.java	7 Mar 2002 07:03:15 -0000	1.1
  +++ ContainerManagerConstants.java	12 Mar 2002 20:51:12 -0000	1.2
  @@ -11,29 +11,29 @@
    * Provides constants used to access the Context object for container managers.
    * A container manager can assume that all these elements are present in
    * the initial context.
  - * 
  + *
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/03/07 07:03:15 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/03/12 20:51:12 $
    */
   public interface ContainerManagerConstants extends ContainerConstants
   {
       /**
        * Class: The class of the container.
        */
  -    public static final String CONTAINER_CLASS                     = "container.class";
  -    
  +    String CONTAINER_CLASS                     = "container.class";
  +
       /**
        * ComponentManager: The component manager to give to the container.
        */
  -    public static final String COMPONENT_MANAGER                   = "container.componentManager";
  -    
  +    String COMPONENT_MANAGER                   = "container.componentManager";
  +
       /**
        * Configuration: The configuration to give to the container.
        */
  -    public static final String CONFIGURATION                       = "container.configuration";
  -    
  +    String CONFIGURATION                       = "container.configuration";
  +
       /**
        * Parameters: The Parameters object to give to the container.
        */
  -    public static final String PARAMETERS                          = "container.parameters";
  +    String PARAMETERS                          = "container.parameters";
   }
  
  
  
  1.2       +51 -41    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextBuilder.java
  
  Index: ContextBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextBuilder.java	7 Mar 2002 07:03:34 -0000	1.1
  +++ ContextBuilder.java	12 Mar 2002 20:51:12 -0000	1.2
  @@ -15,25 +15,25 @@
   public class ContextBuilder implements ContextManagerConstants
   {
       private final DefaultContext context;
  -    
  +
       /**
        * Creates a context builder and initializes it with default values.
        * The default values are:
  -     * 
  +     *
        * <ul>
  -     * <li>THREADS_CPU =  2
  -     * <li>THREAD_TIMEOUT = 1000
  -     * <li>CONTEXT_DIRECTORY = "./"
  -     * <li>WORK_DIRECTORY = "/tmp"
  -     * <li>LOG_CATEGORY = "test"
  -     * <li>CONTEXT_CLASSLOADER = the thread context class loader
  +     * <li>THREADS_CPU =  2</li>
  +     * <li>THREAD_TIMEOUT = 1000</li>
  +     * <li>CONTEXT_DIRECTORY = "./"</li>
  +     * <li>WORK_DIRECTORY = "/tmp"</li>
  +     * <li>LOG_CATEGORY = "test"</li>
  +     * <li>CONTEXT_CLASSLOADER = the thread context class loader</li>
        * </ul>
        */
       public ContextBuilder( )
       {
           context = new DefaultContext( createDefaultContext() );
       }
  -    
  +
       /**
        * Creates a context builder and initializes it with default values.
        *
  @@ -43,7 +43,7 @@
       {
           context = new DefaultContext( parent );
       }
  -    
  +
       /**
        * Creates a default context.
        */
  @@ -51,26 +51,26 @@
       {
           return createDefaultContext( Thread.currentThread().getContextClassLoader() );
       }
  -    
  +
       /**
        * Creates a default context.
        */
       public static final Context createDefaultContext( ClassLoader contextClassLoader )
       {
           DefaultContext defaultContext = new DefaultContext();
  -        
  +
           defaultContext.put( THREADS_CPU, new Integer( 2 ) );
           defaultContext.put( THREAD_TIMEOUT, new Long( 1000 ) );
           defaultContext.put( CONTEXT_DIRECTORY, new File( "./" ) );
           defaultContext.put( WORK_DIRECTORY, new File( "/tmp" ) );
           defaultContext.put( LOG_CATEGORY, "test" );
           defaultContext.put( CONTEXT_CLASSLOADER, contextClassLoader );
  -        
  +
           defaultContext.makeReadOnly();
  -        
  +
           return defaultContext;
       }
  -    
  +
       /**
        * Finalizes the context and returns it.
        */
  @@ -79,27 +79,27 @@
           context.makeReadOnly();
           return context;
       }
  -    
  +
       public void setCommandQueue( Queue commandQueue )
       {
           context.put( COMMAND_QUEUE, commandQueue );
       }
  -    
  +
       public void setComponentManagerParent( ComponentManager componentManager )
       {
           context.put( COMPONENT_MANAGER_PARENT, componentManager );
       }
  -        
  +
       public void setComponentManager( ComponentManager componentManager )
       {
           context.put( COMPONENT_MANAGER, componentManager );
       }
  -    
  +
       public void setContainerClass( String containerClass )
  -        throws ClassNotFoundException 
  +        throws ClassNotFoundException
       {
           ClassLoader classLoader = null;
  -        try 
  +        try
           {
               classLoader = (ClassLoader) context.get( CONTEXT_CLASSLOADER );
           }
  @@ -107,95 +107,105 @@
           {
               classLoader = Thread.currentThread().getContextClassLoader();
           }
  -        
  +
           context.put( CONTAINER_CLASS, classLoader.loadClass (containerClass) );
       }
  -    
  +
       public void setContainerClass( Class containerClass )
       {
           context.put( CONTAINER_CLASS, containerClass );
       }
  -    
  +
       public void setContainerConfiguration( Configuration config )
       {
           context.put( CONFIGURATION, config );
       }
  -    
  +
       public void setContainerConfiguration( String location )
       {
           context.put( CONFIGURATION_URI, location );
       }
  -    
  +
       public void setContextClassLoader( ClassLoader loader )
       {
           context.put( CONTEXT_CLASSLOADER, loader );
       }
  -    
  +
       public void setContextDirectory( File file )
       {
           context.put( CONTEXT_DIRECTORY, file );
       }
  -    
  +
       public void setContextDirectory( String directory )
       {
           context.put( CONTEXT_DIRECTORY, new File(directory) );
       }
  -    
  +
       public void setLoggerCategory( String category )
       {
           context.put( LOG_CATEGORY, category );
       }
  -    
  +
       public void setLoggerManager( LoggerManager logManager )
       {
           context.put( LOGGER_MANAGER, logManager );
       }
  -    
  -    public void setLoggerManagerConfiguration( Configuration config ) 
  +
  +    public void setLoggerManagerConfiguration( Configuration config )
       {
           context.put( LOGGER_MANAGER_CONFIGURATION, config );
       }
  -    
  +
       public void setLoggerManagerConfiguration( String location )
       {
           context.put( LOGGER_MANAGER_CONFIGURATION_URI, location );
       }
  -    
  +
  +    public void setInstrumentManagerConfiguration( Configuration config )
  +    {
  +        context.put( INSTRUMENT_MANAGER_CONFIGURATION, config );
  +    }
  +
  +    public void setInstrumentManagerConfiguration( String location )
  +    {
  +        context.put( INSTRUMENT_MANAGER_CONFIGURATION_URI, location );
  +    }
  +
       public void setNumberOfThreadsPerCPU( int numberOfThreads )
       {
           context.put( THREADS_CPU, new Integer( numberOfThreads ) );
       }
  -    
  +
       public void setPoolManager( PoolManager poolManager )
       {
           context.put( POOL_MANAGER, poolManager );
       }
  -    
  +
       public void setRoleManager( RoleManager roleManager )
       {
           context.put( ROLE_MANAGER, roleManager );
       }
  -    
  +
       public void setRoleManagerConfiguration( Configuration config )
       {
           context.put( ROLE_MANAGER_CONFIGURATION, config );
       }
  -    
  +
       public void setRoleManagerConfiguration( String location )
       {
           context.put( ROLE_MANAGER_CONFIGURATION_URI, location );
       }
  -    
  +
       public void setThreadTimeout( long timeout )
       {
           context.put( THREAD_TIMEOUT, new Long( timeout ) );
       }
  -    
  +
       public void setWorkDirectory( File file )
       {
           context.put( WORK_DIRECTORY, file );
       }
  -    
  +
       public void setWorkDirectory( String directory )
       {
           setWorkDirectory( new File( directory ) );
  
  
  
  1.7       +162 -98   jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ContextManager.java	7 Mar 2002 07:03:34 -0000	1.6
  +++ ContextManager.java	12 Mar 2002 20:51:12 -0000	1.7
  @@ -24,6 +24,7 @@
   import org.apache.avalon.excalibur.mpool.PoolManager;
   import org.apache.avalon.excalibur.source.*;
   import org.apache.avalon.excalibur.system.*;
  +import org.apache.avalon.excalibur.altprofile.profiler.*;
   
   import java.io.File;
   import java.util.ArrayList;
  @@ -55,40 +56,40 @@
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2002/03/07 07:03:34 $
  + * @version CVS $Revision: 1.7 $ $Date: 2002/03/12 20:51:12 $
    * @since 4.1
    */
   public class ContextManager implements ContextManagerConstants
   {
  -   
  +
       private static final Configuration EMPTY_CONFIG;
  -    
  +
       static
       {
           DefaultConfiguration config = new DefaultConfiguration("", "", "", "");
           config.makeReadOnly();
           EMPTY_CONFIG = config;
  -    }    
  -    
  +    }
  +
       /**
        * The root context.
        */
       private final Context          rootContext;
  -    
  +
       /**
        * The context of the new container. This context has the rootContext
        * as its parent. Put everything here that you want the new container
        * to have in its own context.
        */
       private final DefaultContext   childContext;
  -    
  +
       /**
        * Container manager's context. This context has the child context
  -     * as parent. Put things here that you want the container manager 
  +     * as parent. Put things here that you want the container manager
        * to see, but do not wish to expose to the container.
        */
       private final DefaultContext   containerManagerContext;
  -    
  +
       /**
        * New context passed in, maybe from a ContextBuilder.
        * This context may not have objects, but rather URI's or
  @@ -99,7 +100,7 @@
       private       Logger           logger;
       private final Logger           primordialLogger;
       private       ComponentManager manager;
  -    
  +
       /**
        * The components that are "owned" by this context and should
        * be disposed by it. Any manager that is created as a result
  @@ -107,12 +108,12 @@
        * or having been created by the ContextManager should go in here.
        */
       private final ArrayList      ownedComponents = new ArrayList ();
  -    
  +
       private final DefaultConfigurationBuilder    configBuilder =
           new DefaultConfigurationBuilder();
       private final DefaultConfigurationSerializer configSerializer =
           new DefaultConfigurationSerializer();
  -    
  +
       /**
        * Create a new ContextManager.
        *
  @@ -128,10 +129,10 @@
           this.containerManagerContext = new DefaultContext( childContext );
           this.overrideContext = overrides;
           this.logger = logger;
  -        
  +
           this.primordialLogger = new ConsoleLogger();
       }
  -    
  +
       public void assumeOwnership( Object o )
       {
           if (o == null)
  @@ -140,7 +141,7 @@
           }
           ownedComponents.add(o);
       }
  -    
  +
       public void initialize() throws Exception
       {
           initializeOwnComponentManager();
  @@ -150,18 +151,19 @@
           initializeCommandQueue();
           initializePoolManager();
           initializeContext();
  +        initializeInstrumentManager();
           initializeConfiguration();
  -                
  +
           childContext.makeReadOnly ();
           containerManagerContext.makeReadOnly ();
       }
  -    
  +
       protected void initializeConfiguration() throws Exception
       {
  -        try 
  +        try
           {
               containerManagerContext.put( CONFIGURATION, overrideContext.get( CONFIGURATION ) );
  -        } 
  +        }
           catch (ContextException ce)
           {
               Configuration containerConfig = getConfiguration( CONFIGURATION, CONFIGURATION_URI );
  @@ -169,10 +171,10 @@
               {
                   // No config.
                   // Does the parent supply a logger manager?
  -                try 
  +                try
                   {
                       containerManagerContext.get(CONFIGURATION);
  -                    
  +
                       // OK, done.
                       return;
                   }
  @@ -194,10 +196,10 @@
           copyEntry( CONTAINER_CLASS );
           copyEntry( PARAMETERS );
       }
  -    
  +
       protected void copyEntry( String key ) throws Exception
       {
  -        try 
  +        try
           {
               containerManagerContext.put( key, overrideContext.get( key ) );
           }
  @@ -205,7 +207,7 @@
           {
           }
       }
  -    
  +
       /**
        * Disposes all items that this ContextManager has created.
        */
  @@ -216,39 +218,39 @@
           while ( ownedComponentsIter.hasNext() )
           {
               Object o = ownedComponentsIter.next();
  -            
  -            try 
  +
  +            try
               {
                   if (o instanceof Startable)
                   {
                       ((Startable) o).stop();
                   }
  -                
  +
                   if (o instanceof Disposable)
                   {
                       ((Disposable) o).dispose();
  -                }                
  -            } 
  -            catch (Exception e) 
  +                }
  +            }
  +            catch (Exception e)
               {
                   getLogger().warn( "Unable to dispose of owned component " + o.getClass().getName(), e);
               }
           }
  -        ownedComponents.clear ();        
  +        ownedComponents.clear ();
       }
   
       protected Object get( Context context, String key, Object defaultValue )
       {
  -        try 
  +        try
           {
               return context.get(key);
  -        } 
  +        }
           catch (ContextException ce)
           {
               return defaultValue;
           }
       }
  -    
  +
       /**
        * Will set up a ComponentManager if none is supplied.
        *
  @@ -260,16 +262,16 @@
           try {
               childContext.put( COMPONENT_MANAGER, overrideContext.get(COMPONENT_MANAGER) );
               return;
  -        } 
  -        catch (ContextException ce) 
  +        }
  +        catch (ContextException ce)
           {
           }
  -        
  +
           // See if we can inherit from the parent...
  -        try 
  +        try
           {
               childContext.get(COMPONENT_MANAGER);
  -            
  +
               // OK, done.
               return;
           }
  @@ -282,71 +284,71 @@
           // TODO: Load configuration from COMPONENT_MANAGER_CONFIGURATION or COMPONENT_MANAGER_CONFIGURATION_URI
           //       and create a proper CM from those (ECM?). Need a container CM for that, though. /LS
           //
  -        ComponentManager cm = new DefaultComponentManager( 
  +        ComponentManager cm = new DefaultComponentManager(
               (ComponentManager) get(overrideContext, COMPONENT_MANAGER_PARENT, null) );
           assumeOwnership(cm);
  -        containerManagerContext.put( COMPONENT_MANAGER, cm );        
  +        containerManagerContext.put( COMPONENT_MANAGER, cm );
       }
   
       protected void initializeCommandQueue() throws Exception
       {
  -        try 
  +        try
           {
               childContext.put( COMMAND_QUEUE, overrideContext.get(COMMAND_QUEUE) );
               return;
  -        } 
  -        catch (ContextException ce) 
  +        }
  +        catch (ContextException ce)
           {
           }
  -        
  -        try 
  +
  +        try
           {
               childContext.get( COMMAND_QUEUE );
               return;
           }
  -        catch (ContextException ce) 
  +        catch (ContextException ce)
           {
           }
  -        
  +
           CommandManager cm = new CommandManager();
           assumeOwnership(cm);
           childContext.put( COMMAND_QUEUE, cm.getCommandQueue() );
  -    }        
  -    
  +    }
  +
       protected void initializePoolManager() throws Exception
       {
           try {
               childContext.put( POOL_MANAGER, overrideContext.get(POOL_MANAGER) );
               return;
  -        } 
  -        catch (ContextException ce) 
  +        }
  +        catch (ContextException ce)
           {
           }
  -        
  +
           PoolManager pm = new DefaultPoolManager( (Queue) childContext.get(COMMAND_QUEUE) );
           assumeOwnership(pm);
           childContext.put( POOL_MANAGER, pm );
       }
  -    
  +
       protected void initializeRoleManager() throws Exception
       {
           try {
               childContext.put( ROLE_MANAGER, overrideContext.get(ROLE_MANAGER) );
               return;
  -        } 
  -        catch (ContextException ce) 
  +        }
  +        catch (ContextException ce)
           {
           }
  -        
  +
           // Attempt to load config...
  -        //if (config == null) 
  +        //if (config == null)
           //{
  -        
  +
           // See if we can inherit from the parent...
  -        try 
  +        try
           {
               childContext.get(ROLE_MANAGER);
  -            
  +
               // OK, done.
               return;
           }
  @@ -355,7 +357,7 @@
               // No RoleManager available anywhere. (Set one up.)
           }
           //}
  -        
  +
           //
           // TODO: Load configuration from ROLE_MANAGER_CONFIGURATION or ROLE_MANAGER_CONFIGURATION_URI
           //       and create a proper RM from those (ERM?). /LS
  @@ -363,8 +365,8 @@
           RoleManager rm = new ExcaliburRoleManager();
           assumeOwnership(rm);
           childContext.put( ROLE_MANAGER, rm );
  -    }        
  -    
  +    }
  +
       /**
        * Get a reference to the initial ComponentManager used by the ContainerManager
        * to hold the Components used for parsing the config files and setting up the
  @@ -373,57 +375,57 @@
       protected void initializeOwnComponentManager() throws Exception
       {
           DefaultComponentManager manager = new DefaultComponentManager();
  -        
  +
           DefaultComponentSelector selector = new DefaultComponentSelector();
           ResourceSourceFactory resource = new ResourceSourceFactory();
           resource.enableLogging( getLogger() );
           selector.put("resource", resource);
  -        
  +
           manager.put( resource.ROLE + "Selector", selector );
  -        
  +
           SourceResolverImpl resolver = new SourceResolverImpl();
           resolver.enableLogging( getLogger() );
           resolver.contextualize( this.childContext );
           resolver.compose( manager );
  -        
  +
           manager.put( resolver.ROLE, resolver );
  -        
  +
           manager.makeReadOnly();
  -        
  +
           assumeOwnership( manager );
  -        
  +
           this.manager = manager;
  -    } 
  -    
  +    }
  +
       protected Configuration getConfiguration( String configKey, String uriKey )
       {
           Configuration config = null;
           SourceResolver resolver = null;
           Source src = null;
  -        
  -        try 
  +
  +        try
           {
               return (Configuration) overrideContext.get( configKey );
           }
           catch (ContextException ce)
           {
           }
  -        
  +
           String configUri = null;
  -        try 
  +        try
           {
               configUri = (String) overrideContext.get( uriKey );
           }
           catch (ContextException ce)
           {
               return null;
  -        }            
  -        
  +        }
  +
           try
           {
               resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
               src = resolver.resolve( configUri );
  -            
  +
               return configBuilder.build( src.getInputStream() );
           }
           catch (Exception e)
  @@ -437,7 +439,7 @@
               manager.release( resolver );
           }
       }
  -    
  +
       /**
        * Finalizes and returns the context.
        */
  @@ -445,7 +447,7 @@
       {
           return containerManagerContext;
       }
  -    
  +
       /**
        * Finalizes and returns the context.
        */
  @@ -453,7 +455,7 @@
       {
           return childContext;
       }
  -        
  +
       /**
        * Get a reference the Logger.
        */
  @@ -468,9 +470,9 @@
               return logger;
           }
       }
  -    
  +
       /**
  -     * Will set up a LogKitLoggerManager if none is supplied.  This can be 
  +     * Will set up a LogKitLoggerManager if none is supplied.  This can be
        * overridden if you don't want a LogKitLoggerManager.
        *
        * The postcondition is that childContext.get( Container.LOGGER_MANAGER )
  @@ -478,12 +480,12 @@
        */
       protected void initializeLoggerManager() throws Exception
       {
  -        try 
  +        try
           {
               // Try copying an already existing logger manager from the override context.
  -            
  +
               childContext.put( LOGGER_MANAGER, overrideContext.get( LOGGER_MANAGER ) );
  -        } 
  +        }
           catch (ContextException ce)
           {
               // Should we set one up?
  @@ -493,10 +495,10 @@
               {
                   // No config.
                   // Does the parent supply a logger manager?
  -                try 
  +                try
                   {
                       childContext.get(LOGGER_MANAGER);
  -                    
  +
                       // OK, done.
                       return;
                   }
  @@ -504,30 +506,92 @@
                   {
                   }
               }
  -            
  +
               String logCategory = (String) get( overrideContext, LOG_CATEGORY, get( childContext, LOG_CATEGORY, null ) );
  -            
  +
               LogKitLoggerManager logManager = new LogKitLoggerManager( logCategory );
  -            
  +
               logManager.contextualize( rootContext );
               logManager.configure( loggerManagerConfig );
  -            
  +
               assumeOwnership( logManager );
  -            
  +
               childContext.put( LOGGER_MANAGER, logManager );
           }
           finally
           {
               // Since we now have a LoggerManager, we can update the this.logger field
               // if it is null and start logging to the "right" logger.
  -            
  +
               if (this.logger == null)
               {
                   getLogger().info( "Switching to default Logger provided by LoggerManager." );
  -                
  +
                   LoggerManager loggerManager = (LoggerManager) childContext.get(LOGGER_MANAGER);
                   this.logger = loggerManager.getDefaultLogger();
               }
           }
  -    }    
  +    }
  +
  +    /**
  +     * Will set up a LogKitLoggerManager if none is supplied.  This can be
  +     * overridden if you don't want a LogKitLoggerManager.
  +     *
  +     * The postcondition is that childContext.get( Container.LOGGER_MANAGER )
  +     * should return a valid logger manager.
  +     */
  +    protected void initializeInstrumentManager() throws Exception
  +    {
  +        try
  +        {
  +            // Try copying an already existing logger manager from the override context.
  +
  +            childContext.put( INSTRUMENT_MANAGER, overrideContext.get( INSTRUMENT_MANAGER ) );
  +        }
  +        catch (ContextException ce)
  +        {
  +            // Should we set one up?
  +            // Try to get a configuration for it...
  +            Configuration profilerConfig = getConfiguration( INSTRUMENT_MANAGER, INSTRUMENT_MANAGER_CONFIGURATION_URI );
  +            if (profilerConfig == null)
  +            {
  +                // No config.
  +                // Does the parent supply a logger manager?
  +                try
  +                {
  +                    childContext.get(INSTRUMENT_MANAGER);
  +
  +                    // OK, done.
  +                    return;
  +                }
  +                catch (ContextException cex)
  +                {
  +                }
  +
  +                profilerConfig = EMPTY_CONFIG;
  +            }
  +
  +            DefaultProfilerManager profilerManager = new DefaultProfilerManager();
  +            profilerManager.enableLogging( getLogger() );
  +            profilerManager.configure( profilerConfig );
  +            profilerManager.initialize();
  +
  +            assumeOwnership( profilerManager );
  +
  +            childContext.put( INSTRUMENT_MANAGER, profilerManager );
  +        }
  +        finally
  +        {
  +            // Since we now have a LoggerManager, we can update the this.logger field
  +            // if it is null and start logging to the "right" logger.
  +
  +            if (this.logger == null)
  +            {
  +                getLogger().info( "Switching to default Logger provided by LoggerManager." );
  +
  +                LoggerManager loggerManager = (LoggerManager) childContext.get(LOGGER_MANAGER);
  +                this.logger = loggerManager.getDefaultLogger();
  +            }
  +        }
  +    }
   }
  
  
  
  1.2       +19 -16    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManagerConstants.java
  
  Index: ContextManagerConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/util/ContextManagerConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextManagerConstants.java	7 Mar 2002 07:03:34 -0000	1.1
  +++ ContextManagerConstants.java	12 Mar 2002 20:51:12 -0000	1.2
  @@ -11,24 +11,27 @@
   
   /**
    * Provides constants used to access the Context object for containers.
  - * 
  + *
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/03/07 07:03:34 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/03/12 20:51:12 $
    */
   public interface ContextManagerConstants extends ContainerManagerConstants
   {
  -    public static final String LOG_CATEGORY                        = "container.logcategory";
  -    
  -    public static final String LOGGER_MANAGER_CONFIGURATION        = "container.logManager.config";
  -    public static final String LOGGER_MANAGER_CONFIGURATION_URI    = "container.logManager.config.uri";
  -    
  -    public static final String ROLE_MANAGER_CONFIGURATION          = "container.roleManager.config";
  -    public static final String ROLE_MANAGER_CONFIGURATION_URI      = "container.roleManager.config.uri";
  -    
  -    public static final String CONFIGURATION_URI                   = "container.configuration.uri";
  -    
  -    public static final String COMPONENT_MANAGER_CLASS             = "container.componentManager.config";
  -    public static final String COMPONENT_MANAGER_CONFIGURATION     = "container.componentManager.config";
  -    public static final String COMPONENT_MANAGER_PARENT            = "container.componentManager.parent";
  -    public static final String COMPONENT_MANAGER_CONFIGURATION_URI = "container.componentManager.config.uri";
  +    String LOG_CATEGORY                         = "container.logcategory";
  +
  +    String LOGGER_MANAGER_CONFIGURATION         = "container.logManager.config";
  +    String LOGGER_MANAGER_CONFIGURATION_URI     = "container.logManager.config.uri";
  +
  +    String INSTRUMENT_MANAGER_CONFIGURATION     = "container.instrumentManager.config";
  +    String INSTRUMENT_MANAGER_CONFIGURATION_URI = "container.instrumentManager.config.uri";
  +
  +    String ROLE_MANAGER_CONFIGURATION          = "container.roleManager.config";
  +    String ROLE_MANAGER_CONFIGURATION_URI      = "container.roleManager.config.uri";
  +
  +    String CONFIGURATION_URI                   = "container.configuration.uri";
  +
  +    String COMPONENT_MANAGER_CLASS             = "container.componentManager.config";
  +    String COMPONENT_MANAGER_CONFIGURATION     = "container.componentManager.config";
  +    String COMPONENT_MANAGER_PARENT            = "container.componentManager.parent";
  +    String COMPONENT_MANAGER_CONFIGURATION_URI = "container.componentManager.config.uri";
   }
  
  
  

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