avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress ContainerManager.java DefaultContainerManager.java
Date Tue, 06 Aug 2002 20:24:53 GMT
bloritsch    2002/08/06 13:24:53

  Modified:    fortress/src/java/org/apache/excalibur/fortress
                        ContainerManager.java DefaultContainerManager.java
  Log:
  Hide the use of the ContextManager within the ContainerManager
  
  Revision  Changes    Path
  1.40      +2 -5      jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ContainerManager.java
  
  Index: ContainerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/ContainerManager.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- ContainerManager.java	6 Aug 2002 19:41:17 -0000	1.39
  +++ ContainerManager.java	6 Aug 2002 20:24:52 -0000	1.40
  @@ -68,10 +68,7 @@
    *    contextBuilder.setContainerConfiguration( "resource://org.apache.excalibur.fortress/test/ContainerProfile.xconf"
);
    *    contextBuilder.setLoggerManagerConfiguration( "resource://org.apache.excalibur.fortress/test/ContainerProfile.xlog"
);
    *
  - *    ContextManager contextManager = new ContextManager( null, contextBuilder.getContext(),
null );
  - *    contextManager.initialize();
  - *
  - *    ContainerManager cm = new DefaultContainerManager( contextManager.getContextInstance()
);
  + *    ContainerManager cm = new DefaultContainerManager( contextBuilder.getContext() );
    *    cm.initialize();
    * </code>
    * </pre>
  
  
  
  1.17      +20 -32    jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/DefaultContainerManager.java
  
  Index: DefaultContainerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/fortress/src/java/org/apache/excalibur/fortress/DefaultContainerManager.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DefaultContainerManager.java	6 Aug 2002 19:41:18 -0000	1.16
  +++ DefaultContainerManager.java	6 Aug 2002 20:24:52 -0000	1.17
  @@ -61,6 +61,7 @@
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.ConsoleLogger;
  +import org.apache.avalon.framework.logger.NullLogger;
   import org.apache.avalon.framework.logger.LogEnabled;
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.parameters.Parameterizable;
  @@ -91,8 +92,7 @@
    */
   public class DefaultContainerManager implements ContainerManager, ContainerManagerConstants
   {
  -    private final Context initParameters;
  -    private final Context containerContext;
  +    private final ContextManager contextManager;
       private Logger logger;
       private Object containerInstance;
       private ComponentStateValidator validator;
  @@ -104,29 +104,18 @@
   
       public DefaultContainerManager( ContextManager contextManager, Logger logger )
       {
  -        this( contextManager.getContainerManagerContext(), contextManager.getChildContext(),
logger );
  +        this.contextManager = contextManager;
  +        this.logger = logger == null ? createLoggerFromContext( this.contextManager.getChildContext()
) : logger;
       }
   
       public DefaultContainerManager( Context initParameters )
       {
  -        this( initParameters, null, null );
  +        this( new ContextManager(initParameters, new NullLogger()), null );
       }
   
       public DefaultContainerManager( Context initParameters, Logger logger )
       {
  -        this( initParameters, null, logger );
  -    }
  -
  -    public DefaultContainerManager( Context initParameters, Context containerContext )
  -    {
  -        this( initParameters, containerContext, null );
  -    }
  -
  -    public DefaultContainerManager( Context initParameters, Context containerContext, Logger
logger )
  -    {
  -        this.initParameters = initParameters;
  -        this.containerContext = containerContext != null ? containerContext : initParameters;
  -        this.logger = logger == null ? createLoggerFromContext( initParameters ) : logger;
  +        this( new ContextManager(initParameters, logger), logger );
       }
   
       protected Logger createLoggerFromContext( Context initParameters )
  @@ -148,6 +137,7 @@
        */
       public void initialize() throws Exception
       {
  +        this.contextManager.initialize();
           initializeContainer();
       }
   
  @@ -159,7 +149,7 @@
   
               try
               {
  -                instance = ( (Class)initParameters.get( CONTAINER_CLASS ) ).newInstance();
  +                instance = ( (Class)this.contextManager.getChildContext().get( CONTAINER_CLASS
) ).newInstance();
               }
               catch( Exception e )
               {
  @@ -181,40 +171,37 @@
                   if( instance instanceof Contextualizable )
                   {
                       validator.checkContextualized();
  -                    ( (Contextualizable)instance ).contextualize( containerContext );
  +                    ( (Contextualizable)instance ).contextualize(
  +                        this.contextManager.getContainerManagerContext() );
                   }
   
  -                ComponentManager cmanager = getComponentManager( initParameters );
  -                ServiceManager smanager = getServiceManager( initParameters );
  +                ServiceManager smanager = getServiceManager(
  +                        this.contextManager.getChildContext() );
   
                   if( instance instanceof Composable )
                   {
  -                    validator.checkComposed();
  -
  -                    ComponentManager manager =
  -                        ( smanager == null ) ? cmanager : new ServiceComponentManager(
smanager );
  -                    ( (Composable) instance ).compose( manager );
  +                    throw new InitializationException("Composable containers are not supported");
                   }
   
                   if( instance instanceof Serviceable )
                   {
                       validator.checkServiced();
   
  -                    ServiceManager manager =
  -                        ( cmanager == null ) ? smanager : new ComponentServiceManager(
cmanager );
  -                    ( (Serviceable)instance ).service( manager );
  +                    ( (Serviceable)instance ).service( smanager );
                   }
   
                   if( instance instanceof Configurable )
                   {
                       validator.checkConfigured();
  -                    ( (Configurable)instance ).configure( (Configuration)initParameters.get(
CONFIGURATION ) );
  +                    ( (Configurable)instance ).configure( (Configuration)
  +                        this.contextManager.getChildContext().get( CONFIGURATION ) );
                   }
   
                   if( instance instanceof Parameterizable )
                   {
                       validator.checkParameterized();
  -                    ( (Parameterizable)instance ).parameterize( (Parameters)initParameters.get(
PARAMETERS ) );
  +                    ( (Parameterizable)instance ).parameterize( (Parameters)
  +                        this.contextManager.getChildContext().get( PARAMETERS ) );
                   }
   
                   if( instance instanceof Initializable )
  @@ -324,6 +311,7 @@
       public void dispose()
       {
           disposeContainer();
  +        this.contextManager.dispose();
       }
   
       /**
  
  
  

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


Mime
View raw message