Hello Berin!

It great so much of my patches has been applied.

I'm particularly glad Patch #8 has made it through
and that you have even managed to make it work for store!

Cheers to you and us :)

AT> .. Now I'm proposing to ... return to the original code
BL> :)  I guess I'm smarter than I thought.  Although, humility just went
BL> out the window with that comment ;P

:) I've been always putting my hat down at you!
Especially when I managed to get a couple year old pdf of
"Developing With Apache Avalon", printed it out and kept reading
for a couple of days (it turned out to be a bit outdated version,
but that was okay). So, thank you, Berin! :-))

B> Patch #10 needs to be reimplemented.
Will do. It will be called Patch #10.1 then.
Is it okay tomorrow?

Now, about the current Patch (#11):

1) ========================

BL> Interestingly enough my thoughts on this was that if a container
BL> wanted to define its own SourceResolver, it would create its own to
BL> override what was passed in.

Okay, okay! You have persuaded me, it's great to have a default one :)
However, _if_ the invoker has supplied a ServiceManager, then we may
assume that _those_ service manager already contains a SourceResolver,
probably cofigured differently.

Hmm.. can ContextManager be used in a _nested_ container?
Not likely, but theoretically possible.

Hence, this patch. Do you like what is in the patch on this subject?

2) =======================

AT> LoggerManager, PoolManager, InstrumentManager, MetaInfoManager
AT> LifecycleExtensionsManager, Queue are passed to the Container
AT> twice: via contextualize() and via service()

BL> This duplication originated from having them *originally* passed in as
BL> context entries.  Later, after looking at what these things really were,
BL> we determined that we were using a Context to access services.  We
BL> should go the other way and make them only available via the service
BL> mechanism.

I understand they are service because they have an interface and
a ROLE in it? But we never really release them -- is not that an
argument for accessing them via Context?

And after all they are quite different from user services - these
are system entities.

If they are available via ServiceManager someone may configure a
component implementing a PoolManager or a Queue interface or a
MetaInfoManager in the normal .xconf file and have nested containers
use that.

But should these things really be configured like that?
I do not mean this is a security violation but rather that
these things are so deep internal to system things ( like Queue )
that it looks a bit of order to configure them where normal
user components are configured.

So, I personally would have been more comfortable with accessing
them from the Context. Mainly because we never release them.
ServiceManager context contract is just to "heavy" in concept
for such a simple thing as "take what I give you once and live on it".

Is there any use to discussion this topic?

The patch supplied in this mail goes the ServiceManager
way and removes the duplicated entities from m_childContext.

3) ===============================
This patch also hides *CONFIGURAION and *CONFIGURATION_URI
from the container implementation.

4) ===============================
I have also updated the main section of the
inline documentation on ContextManager a bit.
The inline sections on separate methods still
are outdated sometimes - but I think this is
bearable at them moment.

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:45:06.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 container the 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]

Reply via email to