avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Tagunov <atagu...@mail.cnt.ru>
Subject [Fortress.ContextManager][PATCH #1]
Date Thu, 15 May 2003 09:32:54 GMT
Hello, Berin!
Hello, Developers!

Here goes patch #1.

--- ContextManager.orig 2003-05-15 12:11:26.000000000 +0400
+++ ContextManager.java 2003-05-15 13:09:37.000000000 +0400
@@ -251,28 +251,17 @@
     {
         try
         {
-            m_containerManagerContext.put( CONFIGURATION, m_rootContext.get( CONFIGURATION
) );
+            copyEntry( CONFIGURATION );
+            return;
         }
         catch ( ContextException ce )
         {
             final Configuration containerConfig = getConfiguration( CONFIGURATION, CONFIGURATION_URI
);
             if ( containerConfig == null )
             {
-                // No config.
-                // Does the parent supply a logger manager?
-                try
-                {
-                    m_containerManagerContext.get( CONFIGURATION );
-
-                    // OK, done.
-                    return;
-                }
-                catch ( ContextException cex )
-                {
-                    getLogger().debug( "Could not initialize the Configuration", ce );
-                    // Guess there is none.
-                    return;
-                }
+                getLogger().debug( "Could not initialize the Configuration", ce );
+                // Guess there is none.
+                return;
             }
             else
             {
@@ -310,6 +299,7 @@
     protected void copyEntry( final String key ) throws ContextException
     {
         m_containerManagerContext.put( key, m_rootContext.get( key ) );
+        m_childContext.put( key, null );
     }
 
     /**
@@ -371,22 +361,12 @@
     {
         try
         {
-            m_childContext.put( Queue.ROLE, m_rootContext.get( Queue.ROLE ) );
+            m_rootContext.get( Queue.ROLE );
             return;
         }
         catch ( ContextException ce )
         {
         }
-
-        try
-        {
-            m_childContext.get( Queue.ROLE );
-            return;
-        }
-        catch ( ContextException ce )
-        {
-        }
-
         // No CommandQueue specified, create a default one
         m_childContext.put( Queue.ROLE, createCommandSink() );
     }
@@ -475,7 +455,7 @@
     {
         try
         {
-            m_childContext.put( PoolManager.ROLE, m_rootContext.get( PoolManager.ROLE ) );
+            m_rootContext.get( PoolManager.ROLE );
             return;
         }
         catch ( ContextException ce )
@@ -496,12 +476,12 @@
     {
         try
         {
-            m_childContext.put( RoleManager.ROLE, m_rootContext.get( RoleManager.ROLE ) );
+            m_rootContext.get( RoleManager.ROLE );
             return;
         }
         catch ( ContextException ce )
         {
-            getLogger().debug( "Could not copy context entry: " + RoleManager.ROLE
+            getLogger().debug( "Could not find context entry: " + RoleManager.ROLE
                 + ".  This may be Ok depending on other configured context values." );
         }
 
@@ -510,20 +490,9 @@
 
         if ( roleConfig == null )
         {
-            // See if we can inherit from the parent...
-            try
-            {
-                m_childContext.get( RoleManager.ROLE );
-
-                // OK, done.
-                return;
-            }
-            catch ( ContextException ce )
-            {
-                getLogger().debug( "Could not initialize the RoleManager", ce );
-                // No RoleManager available anywhere.
-                roleConfig = EMPTY_CONFIG;
-            }
+            getLogger().debug( "Could not initialize the RoleManager, no configuration" );
+            // No RoleManager available anywhere.
+            roleConfig = EMPTY_CONFIG;
         }
 
         // Get the context Logger Manager
@@ -534,15 +503,15 @@
             roleConfig.getAttribute( "logger", "system.roles" ) );
 
         // Lookup the context class loader
-        final ClassLoader classLoader = (ClassLoader) m_containerManagerContext.get( ClassLoader.class.getName()
);
+        final ClassLoader classLoader = (ClassLoader) m_rootContext.get( ClassLoader.class.getName()
);
 
         // Create a parent role manager with all the default roles
-        final FortressRoleManager erm = new FortressRoleManager( null, classLoader );
-        erm.enableLogging( rmLogger.getChildLogger( "defaults" ) );
-        erm.initialize();
+        final FortressRoleManager frm = new FortressRoleManager( null, classLoader );
+        frm.enableLogging( rmLogger.getChildLogger( "defaults" ) );
+        frm.initialize();
 
         // Create a role manager with the configured roles
-        final ConfigurableRoleManager rm = new ConfigurableRoleManager();
+        final ConfigurableRoleManager rm = new ConfigurableRoleManager( frm );
         rm.enableLogging( rmLogger );
         rm.configure( roleConfig );
 
@@ -559,7 +528,7 @@
     {
         try
         {
-            m_childContext.put( MetaInfoManager.ROLE, m_rootContext.get( MetaInfoManager.ROLE
) );
+            m_rootContext.get( MetaInfoManager.ROLE );
             return;
         }
         catch ( ContextException ce )
@@ -575,7 +544,7 @@
         final Logger rmLogger = loggerManager.getLoggerForCategory( "system.meta" );
 
         // Lookup the context class loader
-        final ClassLoader classLoader = (ClassLoader) m_containerManagerContext.get( ClassLoader.class.getName()
);
+        final ClassLoader classLoader = (ClassLoader) m_rootContext.get( ClassLoader.class.getName()
);
 
         // Create a parent role manager with all the default roles
         final ServiceMetaManager smm = new ServiceMetaManager( new Role2MetaInfoManager(
(RoleManager) m_childContext.get( RoleManager.ROLE ) ), classLoader );
@@ -748,22 +717,9 @@
                 getConfiguration( LOGGER_MANAGER_CONFIGURATION, LOGGER_MANAGER_CONFIGURATION_URI
);
             if ( loggerManagerConfig == null )
             {
-                // No config specified.
-
-                // Does the parent supply a logger manager?
-                try
-                {
-                    m_childContext.get( LoggerManager.ROLE );
-
-                    // OK, done.
-                    return;
-                }
-                catch ( ContextException cex )
-                {
-                    // The parent did not supply a Logger Manager, so create an empty
-                    //  configuration so that a default logger can be created.
-                    loggerManagerConfig = EMPTY_CONFIG;
-                }
+                // Create an empty configuration so that 
+                // a default logger can be created.
+                loggerManagerConfig = EMPTY_CONFIG;
             }
 
             // Resolve a name for the logger, taking the logPrefix into account
@@ -821,9 +777,7 @@
     {
         try
         {
-            // Try copying an already existing instrument manager from the override context.
-
-            m_childContext.put( InstrumentManager.ROLE, m_rootContext.get( InstrumentManager.ROLE
) );
+            m_rootContext.get( InstrumentManager.ROLE );
         }
         catch ( ContextException ce )
         {
@@ -832,19 +786,6 @@
             Configuration instrumentConfig = getConfiguration( INSTRUMENT_MANAGER_CONFIGURATION,
INSTRUMENT_MANAGER_CONFIGURATION_URI );
             if ( instrumentConfig == null )
             {
-                // No config.
-                // Does the parent supply a logger manager?
-                try
-                {
-                    m_childContext.get( InstrumentManager.ROLE );
-
-                    // OK, done.
-                    return;
-                }
-                catch ( ContextException cex )
-                {
-                }
-
                 instrumentConfig = EMPTY_CONFIG;
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message