Sorry to double post. An incorrectly placed "the" in the inline doc
has made me resend the patch.
diff -ru src.orig/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
--- src.orig/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
2003-05-28 10:20:10.000000000 +0400
+++ src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
2003-05-28 12:33:30.000000000 +0400
@@ -205,7 +205,7 @@
ContainerUtil.enableLogging( instance, m_logger );
ContainerUtil.contextualize( instance, implContext );
- final ServiceManager serviceManager = createServiceManager( implContext );
+ final ServiceManager serviceManager = createServiceManager(
managerContext );
ContainerUtil.service( instance, serviceManager );
diff -ru src.orig/java/org/apache/avalon/fortress/util/ContextManager.java
src/java/org/apache/avalon/fortress/util/ContextManager.java
--- src.orig/java/org/apache/avalon/fortress/util/ContextManager.java 2003-05-28
10:20:26.000000000 +0400
+++ src/java/org/apache/avalon/fortress/util/ContextManager.java 2003-05-28
12:53:45.000000000 +0400
@@ -103,20 +103,16 @@
* get an instance of the Context, it is made read-only and returned. No
* further operations will be possible on it.</p>
*
- * <p>You can get two different contexts from the ContextManager: the child
- * context and the impl manager context. The former contains all
- * managers, such as the pool manager etc. necessary for a child impl to
- * create additional child containers. The impl manager context contains
- * all of the child context, but also initialization parameters for the
- * impl, such as a Configuration object, a ComponentLocator, etc., that
- * the impl wants, but does not want to pass on to its children.</p>
+ * <p>You can get two different contexts from the ContextManager:
+ * the container context (m_childContext)
+ * and the container manager context (m_contaimerManagerContext).
*
- * <p>You would typically use the impl manager context to initialize
- * the impl manager, and let it pass the child context on to the
- * impl.</p>
+ * <p>The container manager context is used to provide the container manager
+ * with all the data needed to initialize the container.</p>
+ * <p>The container context is passed directly to the container.</p>
*
- * <p>The ContextManager will sometimes create new components, such as a
- * component manager, a pool manager, etc. It will manage these components
+ * <p>The ContextManager will sometimes create new components, such as
+ * a service manager, a pool manager, etc. It will manage these components
* and dispose of them properly when it itself is disposed .</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
@@ -163,7 +159,6 @@
*/
private Logger m_logger;
private final Logger m_primordialLogger;
- private ServiceManager m_manager;
/**
* The components that are "owned" by this context and should
@@ -237,6 +232,7 @@
*/
public void initialize() throws Exception
{
+ initializeDefaultSourceResolver();
initializeServiceManager();
initializeLoggerManager();
initializeMetaInfoManager();
@@ -248,6 +244,8 @@
m_childContext.makeReadOnly();
m_containerManagerContext.makeReadOnly();
+
+ m_defaultSourceResolver = null;
}
/**
@@ -295,6 +293,16 @@
getLogger().debug( "Could not copy Context parameters. This may be Ok
depending on "
+ "other configured context values." );
}
+
+ // hide from the container implementation what it does not need
+ m_childContext.put( CONFIGURATION, null );
+ m_childContext.put( CONFIGURATION_URI, null );
+ m_childContext.put( ROLE_MANAGER_CONFIGURATION, null );
+ m_childContext.put( ROLE_MANAGER_CONFIGURATION_URI, null );
+ m_childContext.put( LOGGER_MANAGER_CONFIGURATION, null );
+ m_childContext.put( LOGGER_MANAGER_CONFIGURATION_URI, null );
+ m_childContext.put( INSTRUMENT_MANAGER_CONFIGURATION, null );
+ m_childContext.put( INSTRUMENT_MANAGER_CONFIGURATION_URI, null );
}
/**
@@ -392,7 +400,7 @@
{
try
{
- m_rootContext.get( Queue.ROLE );
+ copyEntry( Queue.ROLE );
return;
}
catch ( ContextException ce )
@@ -400,7 +408,7 @@
}
// No CommandQueue specified, create a default one
- m_childContext.put( Queue.ROLE, createCommandSink() );
+ m_containerManagerContext.put( Queue.ROLE, createCommandSink() );
}
/**
@@ -418,7 +426,7 @@
assumeOwnership( tm );
// Get the context Logger Manager
- final LoggerManager loggerManager = (LoggerManager) m_childContext.get(
LoggerManager.ROLE );
+ final LoggerManager loggerManager = (LoggerManager)
m_containerManagerContext.get( LoggerManager.ROLE );
// Get the logger for the thread manager
final Logger tmLogger = loggerManager.getLoggerForCategory(
"system.threadmgr" );
@@ -487,16 +495,16 @@
{
try
{
- m_rootContext.get( PoolManager.ROLE );
+ copyEntry( PoolManager.ROLE );
return;
}
catch ( ContextException ce )
{
}
- final PoolManager pm = new DefaultPoolManager( (Sink) m_childContext.get(
Queue.ROLE ) );
+ final PoolManager pm = new DefaultPoolManager( (Sink)
m_containerManagerContext.get( Queue.ROLE ) );
assumeOwnership( pm );
- m_childContext.put( PoolManager.ROLE, pm );
+ m_containerManagerContext.put( PoolManager.ROLE, pm );
}
/**
@@ -535,7 +543,7 @@
}
// Get the context Logger Manager
- final LoggerManager loggerManager = (LoggerManager) m_childContext.get(
LoggerManager.ROLE );
+ final LoggerManager loggerManager = (LoggerManager)
m_containerManagerContext.get( LoggerManager.ROLE );
// Lookup the context class loader
final ClassLoader classLoader = (ClassLoader) m_rootContext.get(
ClassLoader.class.getName() );
@@ -560,7 +568,17 @@
protected void initializeMetaInfoManager() throws Exception
{
- final boolean mmSupplied = entryPresent( m_rootContext, MetaInfoManager.ROLE
);
+ boolean mmSupplied = false;
+ try
+ {
+ copyEntry( MetaInfoManager.ROLE );
+ mmSupplied = true;
+ }
+ catch( ContextException ce )
+ {
+ // okay, we will create one
+ }
+
RoleManager roleManager = obtainRoleManager();
final boolean rmSupplied = roleManager != null;
@@ -575,7 +593,7 @@
}
else
{
- final LoggerManager loggerManager = (LoggerManager)m_childContext.get(
LoggerManager.ROLE );
+ final LoggerManager loggerManager =
(LoggerManager)m_containerManagerContext.get( LoggerManager.ROLE );
final ClassLoader classLoader = (ClassLoader)m_rootContext.get(
ClassLoader.class.getName() );
if ( ! rmSupplied )
@@ -592,21 +610,25 @@
metaManager.enableLogging(
loggerManager.getLoggerForCategory("system.meta") );
metaManager.initialize();
assumeOwnership( metaManager );
- m_childContext.put( MetaInfoManager.ROLE, metaManager );
+ m_containerManagerContext.put( MetaInfoManager.ROLE, metaManager );
}
}
/**
- * Get a reference to the initial ComponentLocator used by the
- * ContainerManager to hold the Components used for parsing the config
- * files and setting up the environment.
- *
- * @throws Exception when there is an error.
+ * Source resolver used to read-in the configurations.
+ * and provided as a default source resolver if the
+ * user has not supplied a ServiceManager.
+ * (Otherwise it or an overriding sourceresolver
+ * is probably available from that.)
*/
- protected void initializeServiceManager() throws Exception
+ protected SourceResolver m_defaultSourceResolver;
+
+ /**
+ * Initialize the default SrouceResolver.
+ */
+ protected void initializeDefaultSourceResolver() throws Exception
{
- final ServiceManager parent = (ServiceManager) get( m_rootContext,
SERVICE_MANAGER, null );
- final DefaultServiceManager manager = new DefaultServiceManager( parent );
+ final DefaultServiceManager manager = new DefaultServiceManager();
final DefaultServiceSelector selector = new DefaultServiceSelector();
final URLSourceFactory file = new URLSourceFactory();
file.enableLogging( getLogger() );
@@ -623,15 +645,32 @@
ContainerUtil.service( resolver, manager );
ContainerUtil.parameterize( resolver, new Parameters() );
- manager.put( SourceResolver.ROLE, resolver );
-
- manager.makeReadOnly();
-
- assumeOwnership( manager );
-
- m_manager = manager;
-
- m_childContext.put( ContextManagerConstants.SERVICE_MANAGER, m_manager );
+ m_defaultSourceResolver = resolver;
+ }
+ /**
+ * Get a reference to the initial ComponentLocator used by the
+ * ContainerManager to hold the Components used for parsing the config
+ * files and setting up the environment.
+ *
+ * @throws Exception when there is an error.
+ */
+ protected void initializeServiceManager() throws Exception
+ {
+ try
+ {
+ copyEntry( SERVICE_MANAGER );
+ }
+ catch( ContextException ce )
+ {
+ final DefaultServiceManager manager = new DefaultServiceManager();
+
+ // provide a default source resolver good in many situations
+ manager.put( SourceResolver.ROLE, m_defaultSourceResolver );
+
+ manager.makeReadOnly();
+
+ m_containerManagerContext.put( ContextManagerConstants.SERVICE_MANAGER,
manager );
+ }
}
/**
@@ -668,8 +707,7 @@
Source src = null;
try
{
- resolver = (SourceResolver) m_manager.lookup( SourceResolver.ROLE );
- src = resolver.resolveURI( configUri );
+ src = m_defaultSourceResolver.resolveURI( configUri );
if ( configBuilder == null )
{
configBuilder = new DefaultConfigurationBuilder();
@@ -685,12 +723,7 @@
}
finally
{
- if ( null != resolver )
- {
- resolver.release( src );
- }
-
- m_manager.release( resolver );
+ m_defaultSourceResolver.release( src );
}
}
@@ -747,7 +780,7 @@
{
// Try copying an already existing logger manager from the override
context.
- m_childContext.put( LoggerManager.ROLE, m_rootContext.get(
LoggerManager.ROLE ) );
+ copyEntry( LoggerManager.ROLE );
}
catch ( ContextException ce )
{
@@ -788,7 +821,7 @@
assumeOwnership( logManager );
- m_childContext.put( LoggerManager.ROLE, logManager );
+ m_containerManagerContext.put( LoggerManager.ROLE, logManager );
}
// Since we now have a LoggerManager, we can update the this.logger field
@@ -798,7 +831,7 @@
{
getLogger().debug( "Switching to default Logger provided by
LoggerManager." );
- final LoggerManager loggerManager = (LoggerManager) m_childContext.get(
LoggerManager.ROLE );
+ final LoggerManager loggerManager = (LoggerManager)
m_containerManagerContext.get( LoggerManager.ROLE );
m_logger = loggerManager.getDefaultLogger();
}
}
@@ -819,7 +852,7 @@
{
// Try copying an already existing instrument manager from the override
context.
- m_rootContext.get( InstrumentManager.ROLE );
+ copyEntry( InstrumentManager.ROLE );
}
catch ( ContextException ce )
{
@@ -833,7 +866,7 @@
}
// Get the context Logger Manager
- final LoggerManager loggerManager = (LoggerManager) m_childContext.get(
LoggerManager.ROLE );
+ final LoggerManager loggerManager = (LoggerManager)
m_containerManagerContext.get( LoggerManager.ROLE );
// Get the logger for the instrument manager
final Logger imLogger = loggerManager.getLoggerForCategory(
@@ -847,7 +880,7 @@
assumeOwnership( instrumentManager );
- m_childContext.put( InstrumentManager.ROLE, instrumentManager );
+ m_containerManagerContext.put( InstrumentManager.ROLE, instrumentManager
);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]