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/08/16 05:44:14 UTC
cvs commit: jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component ExcaliburComponentManagerCreator.java
leif 2002/08/15 20:44:14
Modified: component/examples/instrument-manager/conf components.xml
instrument.xml logkit.xml roles.xml
component/examples/instrument-manager/src/java/org/apache/avalon/excalibur/component/example_im
DefaultExampleInstrumentable.java Main.java
Added: component/src/java/org/apache/avalon/excalibur/component
ExcaliburComponentManagerCreator.java
Log:
Create the ExcaliburComponentManagerCreator as a utility class to make it
MUCH easier to setup an application to use the ExcaliburComponentManager.
Revision Changes Path
1.2 +2 -2 jakarta-avalon-excalibur/component/examples/instrument-manager/conf/components.xml
Index: components.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/conf/components.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- components.xml 6 Aug 2002 16:28:37 -0000 1.1
+++ components.xml 16 Aug 2002 03:44:14 -0000 1.2
@@ -1,6 +1,6 @@
-<components logger="cm">
+<components logger="system.components">
<!-- =============================================================== -->
<!-- Application components. -->
<!-- =============================================================== -->
- <example-instrumentable logger="app"/>
+ <example-instrumentable logger="example-instrumentable"/>
</components>
1.2 +1 -1 jakarta-avalon-excalibur/component/examples/instrument-manager/conf/instrument.xml
Index: instrument.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/conf/instrument.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- instrument.xml 6 Aug 2002 16:28:37 -0000 1.1
+++ instrument.xml 16 Aug 2002 03:44:14 -0000 1.2
@@ -1,4 +1,4 @@
-<instrument logger="im">
+<instrument logger="system.instrument">
<name>example-instrument-manager</name>
<description>ECM Example Instrument Application</description>
1.2 +23 -20 jakarta-avalon-excalibur/component/examples/instrument-manager/conf/logkit.xml
Index: logkit.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/conf/logkit.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- logkit.xml 6 Aug 2002 16:28:37 -0000 1.1
+++ logkit.xml 16 Aug 2002 03:44:14 -0000 1.2
@@ -1,4 +1,4 @@
-<logkit logger="lm" log-level="INFO">
+<logkit logger="system.logkit" log-level="INFO">
<factories>
<factory type="stream"
class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/>
@@ -11,34 +11,37 @@
<stream id="console">
<stream>System.out</stream>
<format type="avalon">
-%19.19{time:yyyy-MM-dd'T'HH:mm:ss.SSS} %5.5{priority} [%15.15{category}]: %{message}\n%{throwable}
+%19.19{time:yyyy-MM-dd'T'HH:mm:ss.SSS} %5.5{priority} [%24.24{category}]: %{message}\n%{throwable}
</format>
</stream>
</targets>
<categories>
- <!-- Profiler Manager Logger -->
- <category name="im" log-level="INFO">
- <log-target id-ref="console"/>
+ <!-- System loggers -->
+ <category name="system" log-level="DEBUG">
+ <!-- Profiler Manager Logger -->
+ <category name="instrument" log-level="DEBUG">
+ <log-target id-ref="console"/>
+
+ <!-- The values child logger can dump out a lot of data. -->
+ <category name="values"
+ log-level="INFO">
+ <log-target id-ref="console"/>
+ </category>
+ </category>
- <!-- The values child logger can dump out a lot of data. -->
- <category name="values"
- log-level="INFO">
+ <!-- Role Manager Logger -->
+ <category name="roles" log-level="INFO">
+ <log-target id-ref="console"/>
+ </category>
+
+ <!-- Component Manager Logger -->
+ <category name="components" log-level="INFO">
<log-target id-ref="console"/>
</category>
</category>
- <!-- Role Manager Logger -->
- <category name="rm" log-level="INFO">
- <log-target id-ref="console"/>
- </category>
-
- <!-- Component Manager Logger -->
- <category name="cm" log-level="INFO">
- <log-target id-ref="console"/>
- </category>
-
- <!-- Application Loggers -->
- <category name="app" log-level="INFO">
+ <!-- Default Loggers -->
+ <category name="" log-level="DEBUG">
<log-target id-ref="console"/>
</category>
</categories>
1.2 +1 -1 jakarta-avalon-excalibur/component/examples/instrument-manager/conf/roles.xml
Index: roles.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/conf/roles.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- roles.xml 6 Aug 2002 16:28:37 -0000 1.1
+++ roles.xml 16 Aug 2002 03:44:14 -0000 1.2
@@ -1,4 +1,4 @@
-<role-list logger="rm">
+<role-list logger="system.roles">
<!-- =================================================================== -->
<!-- Application roles. -->
<!-- =================================================================== -->
1.2 +2 -2 jakarta-avalon-excalibur/component/examples/instrument-manager/src/java/org/apache/avalon/excalibur/component/example_im/DefaultExampleInstrumentable.java
Index: DefaultExampleInstrumentable.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/src/java/org/apache/avalon/excalibur/component/example_im/DefaultExampleInstrumentable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultExampleInstrumentable.java 6 Aug 2002 16:28:37 -0000 1.1
+++ DefaultExampleInstrumentable.java 16 Aug 2002 03:44:14 -0000 1.2
@@ -87,7 +87,7 @@
*/
public void doAction()
{
- getLogger().info( "ExampleInstrumentable.doAction() called." );
+ getLogger().debug( "ExampleInstrumentable.doAction() called." );
// Notify the profiler.
m_doActionInstrument.increment();
1.2 +32 -91 jakarta-avalon-excalibur/component/examples/instrument-manager/src/java/org/apache/avalon/excalibur/component/example_im/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/component/examples/instrument-manager/src/java/org/apache/avalon/excalibur/component/example_im/Main.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Main.java 6 Aug 2002 16:28:37 -0000 1.1
+++ Main.java 16 Aug 2002 03:44:14 -0000 1.2
@@ -11,22 +11,23 @@
import java.io.File;
import java.io.InputStreamReader;
-import org.apache.avalon.excalibur.component.DefaultRoleManager;
-import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
-import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
+//import org.apache.avalon.excalibur.component.DefaultRoleManager;
+import org.apache.avalon.excalibur.component.ExcaliburComponentManagerCreator;
+//import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
import org.apache.avalon.excalibur.concurrent.ThreadBarrier;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.context.DefaultContext;
-import org.apache.avalon.framework.logger.LogKitLogger;
-
-import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
-
-import org.apache.log.Hierarchy;
-import org.apache.log.Logger;
-import org.apache.log.Priority;
+import org.apache.avalon.framework.component.ComponentManager;
+//import org.apache.avalon.framework.configuration.Configuration;
+//import org.apache.avalon.framework.configuration.ConfigurationException;
+//import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+//import org.apache.avalon.framework.context.DefaultContext;
+//import org.apache.avalon.framework.logger.LogKitLogger;
+
+//import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
+
+//import org.apache.log.Hierarchy;
+//import org.apache.log.Logger;
+//import org.apache.log.Priority;
/**
* This example application loads a component which publishes a series
@@ -42,8 +43,7 @@
*/
public class Main
{
- private static ExcaliburComponentManager m_componentManager;
- private static DefaultInstrumentManager m_instrumentManager;
+ private static ExcaliburComponentManagerCreator m_componentManagerCreator;
/*---------------------------------------------------------------
* Constructors
@@ -51,68 +51,6 @@
private Main() {}
/*---------------------------------------------------------------
- * Methods
- *-------------------------------------------------------------*/
- /**
- * Creates and initializes the component manager using config files.
- */
- private static void createComponentManager()
- throws Exception
- {
- // Create a context to use.
- DefaultContext context = new DefaultContext();
- // Add any context variables here.
- context.makeReadOnly();
-
- // Create a ConfigurationBuilder to parse the config files.
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
-
- // Load in the configuration files
- Configuration logKitConfig = builder.build( "../conf/logkit.xml" );
- Configuration instrumentConfig = builder.build( "../conf/instrument.xml" );
- Configuration rolesConfig = builder.build( "../conf/roles.xml" );
- Configuration componentsConfig = builder.build( "../conf/components.xml" );
-
- // Create the default logger for the Logger Manager.
- Logger lmLogger = Hierarchy.getDefaultHierarchy().
- getLoggerFor( logKitConfig.getAttribute( "logger", "lm" ) );
- lmLogger.setPriority(
- Priority.getPriorityForName( logKitConfig.getAttribute( "log-level", "INFO" ) ) );
-
- // Setup the LogKitLoggerManager
- LogKitLoggerManager logManager = new LogKitLoggerManager(
- null, Hierarchy.getDefaultHierarchy(), new LogKitLogger( lmLogger ) );
- logManager.contextualize( context );
- logManager.configure( logKitConfig );
-
- // Set up the Instrument Manager
- DefaultInstrumentManager instrumentManager = new DefaultInstrumentManager();
- instrumentManager.enableLogging(
- logManager.getLoggerForCategory( instrumentConfig.getAttribute( "logger", "im" ) ) );
- instrumentManager.configure( instrumentConfig );
- instrumentManager.initialize();
- m_instrumentManager = instrumentManager;
-
- // Setup the RoleManager
- DefaultRoleManager roleManager = new DefaultRoleManager();
- roleManager.enableLogging(
- logManager.getLoggerForCategory( rolesConfig.getAttribute( "logger", "rm" ) ) );
- roleManager.configure( rolesConfig );
-
- // Set up the ComponentManager
- ExcaliburComponentManager componentManager = new ExcaliburComponentManager();
- componentManager.enableLogging(
- logManager.getLoggerForCategory( componentsConfig.getAttribute( "logger", "cm" ) ) );
- componentManager.setLoggerManager( logManager );
- componentManager.contextualize( context );
- componentManager.setInstrumentManager( m_instrumentManager );
- componentManager.setRoleManager( roleManager );
- componentManager.configure( componentsConfig );
- componentManager.initialize();
- m_componentManager = componentManager;
- }
-
- /*---------------------------------------------------------------
* Main method
*-------------------------------------------------------------*/
/**
@@ -123,12 +61,19 @@
{
System.out.println( "Running the InstrumentManager Example Application" );
- // Create the ComponentManager
- createComponentManager();
+ // Create the ComponentManager using the ExcaliburComponentManagerCreator
+ // utility class. See the contents of that class if you wish to do the
+ // initialization yourself.
+ m_componentManagerCreator = new ExcaliburComponentManagerCreator( null,
+ new File( "../conf/logkit.xml" ), new File( "../conf/roles.xml" ),
+ new File( "../conf/components.xml"), new File( "../conf/instrument.xml" ) );
+
+ // Get a reference to the component manager
+ ComponentManager componentManager = m_componentManagerCreator.getComponentManager();
// Get a reference to the example component.
ExampleInstrumentable instrumentable =
- (ExampleInstrumentable)m_componentManager.lookup( ExampleInstrumentable.ROLE );
+ (ExampleInstrumentable)componentManager.lookup( ExampleInstrumentable.ROLE );
try
{
boolean quit = false;
@@ -183,16 +128,12 @@
finally
{
// Release the component
- m_componentManager.release( instrumentable );
+ componentManager.release( instrumentable );
instrumentable = null;
-
- // Dispose the ComponentManager
- m_componentManager.dispose();
- m_componentManager = null;
-
- // Dispose the InstrumentManager
- m_instrumentManager.dispose();
- m_instrumentManager = null;
+
+ // Dispose of the ComponentManagerCreator. It will dispose all
+ // of its own components, including the ComponentManager
+ m_componentManagerCreator.dispose();
}
System.out.println();
1.1 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManagerCreator.java
Index: ExcaliburComponentManagerCreator.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.excalibur.component;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.LogKitLogger;
import org.apache.excalibur.instrument.InstrumentManager;
import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
/**
* Utility class which can be used to manage the life cycle of a
* ComponentManager and its RoleManager, LoggerManager, and optional
* InstrumentManager.
* <p>
* The code necessary to manage all of the above can be reduced to the
* following:
* <pre>
* m_componentManagerCreator = new ExcaliburComponentManagerCreator(
* null, // Optional Context
* new File( "../conf/logkit.xml" ),
* new File( "../conf/roles.xml" ),
* new File( "../conf/components.xml"),
* new File( "../conf/instrument.xml" ) );
* </pre>
*
* Then simply remember to dispose of the creator when the application
* shuts down.
* <pre>
* m_componentManagerCreator.dispose();
* m_componentManagerCreator = null;
* </pre>
*
* The ComponentManager or any of the other managers can be accessed using their
* getter methods. getComponentManager() for example.
*
* @author <a href="mailto:leif@apache.org">Leif Mortenson</a>
* @version CVS $Revision: 1.1 $ $Date: 2002/08/16 03:44:14 $
* @since 4.1
*/
public class ExcaliburComponentManagerCreator
implements Disposable
{
/** Internal logger set once the LoggerManager has been initialized.
* Always call getLogger() to get the best available logger. */
private Logger m_logger;
/** Simple logger which can be used until the LoggerManager has been setup.
* Always call getLogger() to get the best available logger. */
private final Logger m_primordialLogger;
/** Context to create the ComponentManager with. */
private Context m_context;
/** Internal logger manager. */
private LoggerManager m_loggerManager;
/** Internal role manager. */
private RoleManager m_roleManager;
/** Internal component manager. */
private ComponentManager m_componentManager;
/** Internal instrument manager. */
private InstrumentManager m_instrumentManager;
/*---------------------------------------------------------------
* Static Methods
*-------------------------------------------------------------*/
/**
* Creates and initializes a default context.
*/
private static Context createDefaultContext()
{
DefaultContext context = new DefaultContext();
context.makeReadOnly();
return context;
}
/**
* Creates a Configuration object from data read from an InputStream.
*
* @param is InputStream from which the Configuration is created.
*
* @return Configuration created from the InputStream
*
* @throws Exception If the configuration could not be processed.
*/
private static Configuration readConfigurationFromStream( InputStream is )
throws Exception
{
if ( is == null )
{
return null;
}
else
{
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration config = builder.build( is );
return config;
}
}
/**
* Creates a Configuration object from data read from an InputStream.
*
* @param is InputStream from which the Configuration is created.
*
* @return Configuration created from the InputStream
*
* @throws Exception If the configuration could not be read or processed.
*/
private static Configuration readConfigurationFromFile( File file )
throws Exception
{
if ( file == null )
{
return null;
}
else
{
InputStream is = new FileInputStream( file );
try
{
return readConfigurationFromStream( is );
}
finally
{
is.close();
}
}
}
/*---------------------------------------------------------------
* Constructors
*-------------------------------------------------------------*/
/**
* Create a new ExcaliburComponentManagerCreator using Configuration
* objects.
*
* @param context Context to use when creating the ComponentManager. May
* be null.
* @param loggerManagerConfig Configuration object to use to create a
* LoggerManager.
* @param roleManagerConfig Configuration object to use to create a
* RoleManager.
* @param componentManagerConfig Configuration object to use to create a
* ComponentManager.
* @param instrumentManagerConfig Configuration object to use to create an
* InstrumentManager. May be null.
*
* @throws Exception If there were any problems initializing the
* ComponentManager.
*/
public ExcaliburComponentManagerCreator( Context context,
Configuration loggerManagerConfig,
Configuration roleManagerConfig,
Configuration componentManagerConfig,
Configuration instrumentManagerConfig )
throws Exception
{
if ( context == null )
{
m_context = createDefaultContext();
}
else
{
m_context = context;
}
// The primordial logger is used for all output up until the point
// where the Logger manager has been initialized. However it is set
// into objects used to load the configuration resource files. Any
// problems loading these files will result in warning or error
// messages. However in most cases, the debug information should not
// be displayed, so turn it off by default.
// Unfortunately, there is not a very good place to make this settable.
m_primordialLogger = new ConsoleLogger( ConsoleLogger.LEVEL_INFO );
initializeLoggerManager( loggerManagerConfig );
initializeRoleManager( roleManagerConfig );
initializeInstrumentManager( instrumentManagerConfig );
initializeComponentManager( componentManagerConfig );
}
/**
* Create a new ExcaliburComponentManagerCreator using Input Streams.
*
* @param context Context to use when creating the ComponentManager. May
* be null.
* @param loggerManagerConfigStream InputStream from which to read the
* Configuration object to use to create
* a LoggerManager.
* @param roleManagerConfigStream InputStream from which to read the
* Configuration object to use to create
* a RoleManager.
* @param componentManagerConfigStream InputStream from which to read the
* Configuration object to use to
* create a ComponentManager.
* @param instrumentManagerConfigStream InputStream from which to read the
* Configuration object to use to
* create a InstrumentManager. May
* be null.
*
* @throws Exception If there were any problems initializing the
* ComponentManager.
*/
public ExcaliburComponentManagerCreator( Context context,
InputStream loggerManagerConfigStream,
InputStream roleManagerConfigStream,
InputStream componentManagerConfigStream,
InputStream instrumentManagerConfigStream )
throws Exception
{
this ( context,
readConfigurationFromStream( loggerManagerConfigStream ),
readConfigurationFromStream( roleManagerConfigStream ),
readConfigurationFromStream( componentManagerConfigStream ),
readConfigurationFromStream( instrumentManagerConfigStream ) );
}
/**
* Create a new ExcaliburComponentManagerCreator using Files.
*
* @param context Context to use when creating the ComponentManager. May
* be null.
* @param loggerManagerConfigFile File from which to read the
* Configuration object to use to create
* a LoggerManager.
* @param roleManagerConfigFile File from which to read the Configuration
* object to use to create a RoleManager.
* @param componentManagerConfigFile File from which to read the
* Configuration object to use to
* create a ComponentManager.
* @param instrumentManagerConfigFile File from which to read the
* Configuration object to use to
* create a InstrumentManager. May
* be null.
*
* @throws Exception If there were any problems initializing the
* ComponentManager.
*/
public ExcaliburComponentManagerCreator( Context context,
File loggerManagerConfigFile,
File roleManagerConfigFile,
File componentManagerConfigFile,
File instrumentManagerConfigFile )
throws Exception
{
this ( context,
readConfigurationFromFile( loggerManagerConfigFile ),
readConfigurationFromFile( roleManagerConfigFile ),
readConfigurationFromFile( componentManagerConfigFile ),
readConfigurationFromFile( instrumentManagerConfigFile ) );
}
/*---------------------------------------------------------------
* Disposable Methods
*-------------------------------------------------------------*/
/**
* Disposes the component manager creator along with the CompoentManager
* and other managers which it was responsible for creating.
*/
public void dispose()
{
// Clean up all of the objects that we created in the propper order.
try
{
ContainerUtil.shutdown( m_componentManager );
ContainerUtil.shutdown( m_instrumentManager );
ContainerUtil.shutdown( m_roleManager );
ContainerUtil.shutdown( m_loggerManager );
}
catch ( Exception e )
{
getLogger().error( "Unexpected error disposing managers.", e );
}
}
/*---------------------------------------------------------------
* Methods
*-------------------------------------------------------------*/
/**
* Returns the configured LoggerManager.
*
* @return The configured LoggerManager.
*/
public LoggerManager getLoggerManager()
{
return m_loggerManager;
}
/**
* Returns the configured RoleManager.
*
* @return The configured RoleManager.
*/
public RoleManager getRoleManager()
{
return m_roleManager;
}
/**
* Returns the configured InstrumentManager. May be null if an instrument
* configuration was not specified in the constructor.
*
* @return The configured InstrumentManager.
*/
public InstrumentManager getInstrumentManager()
{
return m_instrumentManager;
}
/**
* Returns the configured ComponentManager.
*
* @return The configured ComponentManager.
*/
public ComponentManager getComponentManager()
{
return m_componentManager;
}
/**
* Returns the logger for internal use.
*/
private Logger getLogger()
{
if ( m_logger != null )
{
return m_logger;
}
return m_primordialLogger;
}
private void initializeLoggerManager( Configuration loggerManagerConfig )
throws Exception
{
// Do we want to allow a log prefix to be set?
String logPrefix = null;
// Resolve a name for the logger, taking the logPrefix into account
String lmDefaultLoggerName;
String lmLoggerName;
if ( logPrefix == null )
{
lmDefaultLoggerName = "";
lmLoggerName = loggerManagerConfig.getAttribute( "logger", "system.logkit" );
}
else
{
lmDefaultLoggerName = logPrefix;
lmLoggerName = logPrefix + org.apache.log.Logger.CATEGORY_SEPARATOR
+ loggerManagerConfig.getAttribute( "logger", "system.logkit" );
}
// Create the default logger for the Logger Manager.
org.apache.log.Logger lmDefaultLogger =
Hierarchy.getDefaultHierarchy().getLoggerFor( lmDefaultLoggerName );
// The default logger is not used until after the logger conf has been loaded
// so it is possible to configure the priority there.
lmDefaultLogger.setPriority( Priority.DEBUG );
// Create the logger for use internally by the Logger Manager.
org.apache.log.Logger lmLogger =
Hierarchy.getDefaultHierarchy().getLoggerFor( lmLoggerName );
lmLogger.setPriority( Priority.getPriorityForName(
loggerManagerConfig.getAttribute( "log-level", "DEBUG" ) ) );
// Setup the Logger Manager
LogKitLoggerManager loggerManager = new LogKitLoggerManager(
logPrefix, Hierarchy.getDefaultHierarchy(),
new LogKitLogger( lmDefaultLogger ), new LogKitLogger( lmLogger ) );
loggerManager.contextualize( m_context );
loggerManager.configure( loggerManagerConfig );
m_loggerManager = loggerManager;
// Since we now have a LoggerManager, we can update the m_logger field
// if it is null and start logging to the "right" logger.
if( m_logger == null )
{
getLogger().debug( "Switching to default Logger provided by LoggerManager." );
m_logger = m_loggerManager.getDefaultLogger();
}
}
private void initializeRoleManager( Configuration roleManagerConfig )
throws Exception
{
// Get the logger for the role manager
Logger rmLogger = m_loggerManager.getLoggerForCategory(
roleManagerConfig.getAttribute( "logger", "system.roles" ) );
// Setup the RoleManager
DefaultRoleManager roleManager = new DefaultRoleManager();
roleManager.enableLogging( rmLogger );
roleManager.configure( roleManagerConfig );
m_roleManager = roleManager;
}
private void initializeInstrumentManager( Configuration instrumentManagerConfig )
throws Exception
{
if ( instrumentManagerConfig != null )
{
// Get the logger for the instrument manager
Logger imLogger = m_loggerManager.getLoggerForCategory(
instrumentManagerConfig.getAttribute( "logger", "system.instrument" ) );
// Set up the Instrument Manager
DefaultInstrumentManager instrumentManager = new DefaultInstrumentManager();
instrumentManager.enableLogging( imLogger );
instrumentManager.configure( instrumentManagerConfig );
instrumentManager.initialize();
m_instrumentManager = instrumentManager;
}
}
private void initializeComponentManager( Configuration componentManagerConfig )
throws Exception
{
// Get the logger for the component manager
Logger cmLogger = m_loggerManager.getLoggerForCategory(
componentManagerConfig.getAttribute( "logger", "system.components" ) );
// Set up the ComponentManager
ExcaliburComponentManager componentManager = new ExcaliburComponentManager();
componentManager.enableLogging( cmLogger );
componentManager.setLoggerManager( m_loggerManager );
componentManager.contextualize( m_context );
if ( m_instrumentManager != null )
{
componentManager.setInstrumentManager( m_instrumentManager );
}
componentManager.setRoleManager( m_roleManager );
componentManager.configure( componentManagerConfig );
componentManager.initialize();
m_componentManager = componentManager;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>