avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util ContextManager.java
Date Tue, 20 May 2003 20:26:08 GMT
bloritsch    2003/05/20 13:26:08

  Modified:    fortress/src/java/org/apache/avalon/fortress/impl
                        AbstractContainer.java
               fortress/src/java/org/apache/avalon/fortress/impl/role
                        ConfigurableRoleManager.java
               fortress/src/java/org/apache/avalon/fortress/util
                        ContextManager.java
  Log:
  apply patch from Anton Tugonov, but reserve the removal of the use of FortressRoleManager
until our distribution system can handle it
  
  Revision  Changes    Path
  1.28      +10 -4     avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/AbstractContainer.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AbstractContainer.java	20 May 2003 13:05:41 -0000	1.27
  +++ AbstractContainer.java	20 May 2003 20:26:08 -0000	1.28
  @@ -74,6 +74,7 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.service.DefaultServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
  @@ -239,8 +240,12 @@
           {
               if ( serviceManager.hasService( MetaInfoManager.ROLE ) )
               {
  -                m_metaManager = createMetaManager(
  -                    (MetaInfoManager) serviceManager.lookup( MetaInfoManager.ROLE ) );
  +                m_metaManager = (MetaInfoManager) serviceManager.lookup( MetaInfoManager.ROLE
);
  +
  +                if ( serviceManager.hasService( RoleManager.ROLE ) )
  +                {
  +                    getLogger().warn( "MetaInfoManager found, ignoring RoleManager" );
  +                }
               }
               else if ( serviceManager.hasService( RoleManager.ROLE ) )
               {
  @@ -294,7 +299,8 @@
       {
           final ServiceMetaManager metaManager =
               new ServiceMetaManager( root, m_classLoader );
  -        ContainerUtil.enableLogging( metaManager, getLogger().getChildLogger( "roles" )
);
  +        final Logger mmLogger = m_loggerManager.getLoggerForCategory( "system.meta" );
  +        ContainerUtil.enableLogging( metaManager, mmLogger );
           ContainerUtil.initialize( metaManager );
           return metaManager;
       }
  
  
  
  1.9       +14 -3     avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/ConfigurableRoleManager.java
  
  Index: ConfigurableRoleManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/role/ConfigurableRoleManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConfigurableRoleManager.java	18 Apr 2003 20:02:30 -0000	1.8
  +++ ConfigurableRoleManager.java	20 May 2003 20:26:08 -0000	1.9
  @@ -72,9 +72,20 @@
        */
       public ConfigurableRoleManager()
       {
  -        super( null );
  +        super( null, null );
       }
  -
  +    
  +    /**
  +     * Alternate constructor--this RoleManager has the specified
  +     * classloader.
  +     *
  +     * @param parent  The parent <code>RoleManager</code>.
  +     */
  +    public ConfigurableRoleManager( final ClassLoader loader )
  +    {
  +        super( null, loader );
  +    }
  +    
       /**
        * Alternate constructor--this RoleManager has the specified
        * parent.
  
  
  
  1.27      +33 -54    avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/util/ContextManager.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ContextManager.java	15 May 2003 13:50:36 -0000	1.26
  +++ ContextManager.java	20 May 2003 20:26:08 -0000	1.27
  @@ -233,7 +233,6 @@
           initializeServiceManager();
           initializeLoggerManager();
           initializeRoleManager();
  -        initializeMetaInfoManager();
           initializeCommandQueue();
           initializePoolManager();
           initializeContext();
  @@ -302,6 +301,27 @@
           m_containerManagerContext.put( key, m_rootContext.get( key ) );
           m_childContext.put( key, null );
       }
  +    
  +    /**
  +     * Checks if a specified entry in <code>rootContext</code>
  +     * has been supplied by the invoker.
  +     */
  +    protected boolean entryPresent( final String key )
  +    {
  +        boolean isPresent = false;
  +        
  +        try
  +        {
  +            m_rootContext.get( key );
  +            isPresent = true;
  +        }
  +        catch( ContextException ce )
  +        {
  +            // It is not present, so the value remains false
  +        }
  +        
  +        return isPresent;
  +    }
   
       /**
        * Disposes all items that this ContextManager has created.
  @@ -470,31 +490,27 @@
       }
   
       /**
  -     * Set up the RoleManager for the Container.
  +     * Set up a RoleManager for the Container if configuration for
  +     * it has been supplied.
        *
        * @throws Exception if there is an error.
        */
       protected void initializeRoleManager() throws Exception
       {
  -        try
  -        {
  -            m_rootContext.get( RoleManager.ROLE );
  -            return;
  -        }
  -        catch ( ContextException ce )
  -        {
  -            getLogger().debug( "Could not copy context entry: " + RoleManager.ROLE
  -                + ".  This may be Ok depending on other configured context values." );
  -        }
  +        /* we don't want an error message from getConfiguration, so
  +         * check if there is job to do first
  +         */
  +        if ( entryPresent(RoleManager.ROLE) ) return;
  +        if ( !entryPresent(  ROLE_MANAGER_CONFIGURATION     ) &&
  +             !entryPresent(  ROLE_MANAGER_CONFIGURATION_URI )    ) return;
   
           Configuration roleConfig =
               getConfiguration( ROLE_MANAGER_CONFIGURATION, ROLE_MANAGER_CONFIGURATION_URI
);
   
           if ( roleConfig == null )
           {
  -            getLogger().debug( "Could not initialize the RoleManager, no configuration"
);
  -            // No RoleManager available anywhere.
  -            roleConfig = EMPTY_CONFIG;
  +            // Something went wrong, but the error has already been reported
  +            return;
           }
   
           // Get the context Logger Manager
  @@ -522,42 +538,6 @@
       }
   
       /**
  -     * Set up the RoleManager for the Container.
  -     *
  -     * @throws Exception if there is an error.
  -     */
  -    protected void initializeMetaInfoManager() throws Exception
  -    {
  -        try
  -        {
  -            m_rootContext.get( MetaInfoManager.ROLE );
  -            return;
  -        }
  -        catch ( ContextException ce )
  -        {
  -            getLogger().debug( "Could not copy context entry: " + MetaInfoManager.ROLE
  -                + ".  This may be Ok depending on other configured context values." );
  -        }
  -
  -        // Get the context Logger Manager
  -        final LoggerManager loggerManager = (LoggerManager) m_childContext.get( LoggerManager.ROLE
);
  -
  -        // Create a logger for the role manager
  -        final Logger rmLogger = loggerManager.getLoggerForCategory( "system.meta" );
  -
  -        // Lookup the context class loader
  -        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 );
  -        smm.enableLogging( rmLogger.getChildLogger( "defaults" ) );
  -        smm.initialize();
  -
  -        assumeOwnership( smm );
  -        m_childContext.put( org.apache.avalon.fortress.MetaInfoManager.ROLE, smm );
  -    }
  -
  -    /**
        * 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.
  @@ -621,8 +601,7 @@
           }
           catch ( ContextException ce )
           {
  -            getLogger().debug( "A configuration URI was not specified either: " + uriKey
  -                + "  One or the other is required." );
  +            getLogger().debug( "A configuration URI was not specified: " + uriKey );
               return null;
           }
   
  
  
  

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


Mime
View raw message