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/src/scratchpad/org/apache/avalon/excalibur/system InitializationException.java Container.java ContainerManager.java
Date Fri, 18 Jan 2002 23:21:02 GMT
bloritsch    02/01/18 15:21:01

  Modified:    src/scratchpad/org/apache/avalon/excalibur/system
                        Container.java ContainerManager.java
  Added:       src/scratchpad/org/apache/avalon/excalibur/system
                        InitializationException.java
  Log:
  add exception
  
  Revision  Changes    Path
  1.3       +5 -7      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/Container.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Container.java	18 Jan 2002 21:33:44 -0000	1.2
  +++ Container.java	18 Jan 2002 23:21:01 -0000	1.3
  @@ -11,19 +11,17 @@
   import org.apache.avalon.framework.component.ComponentManager;
   
   /**
  - * The Container is a base class that can be used to manage your system.  It
  + * The Container is an interface used to mark the Containers in your system.  It
    * exposes a protected getComponentManager() method so that the Container's
    * Manager can expose that to the instantiating class.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/18 21:33:44 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/18 23:21:01 $
    */
  -public class Container
  +public interface Container
   {
       public static final String CONTEXT_CLASSLOADER = "container.classloader";
  -    protected ComponentManager getComponentManager()
  -    {
  -        return null;
  -    }
  +    public static final String CONTEXT_DIRECTORY = "container.rootDir";
  +    public static final String WORK_DIRECTORY    = "container.workDir";
   }
   
  
  
  
  1.4       +24 -4     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java
  
  Index: ContainerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContainerManager.java	18 Jan 2002 21:33:44 -0000	1.3
  +++ ContainerManager.java	18 Jan 2002 23:21:01 -0000	1.4
  @@ -128,13 +128,14 @@
    * </table>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2002/01/18 21:33:44 $
  + * @version CVS $Revision: 1.4 $ $Date: 2002/01/18 23:21:01 $
    */
   public class ContainerManager
   {
  +    public static final String CONTEXT_DIRECTORY = Container.CONTEXT_DIRECTORY;
  +    public static final String WORK_DIRECTORY    = Container.WORK_DIRECTORY;
  +    public static final String CONTAINER_CLASS   = "container.class";
       public static final String XML_PARSER        = "container.xmlParser";
  -    public static final String CONTEXT_DIRECTORY = "container.rootDir";
  -    public static final String WORK_DIRECTORY    = "container.workDir";
       public static final String LOGKIT_CONFIG     = "container.loggerConfig";
       public static final String ROLE_CONFIG       = "container.roles";
       public static final String MAX_THREADS       = "container.threadPoolMax";
  @@ -163,6 +164,7 @@
        * implementation, then use the constructor with two arguments.
        */
       public ContainerManager( final Parameters initialParameters )
  +        throws InitializationException
       {
           this( initialParameters, null );
       }
  @@ -172,6 +174,7 @@
        * supplied LoggerManager.
        */
       public ContainerManager( final Parameters initialParameters, final LoggerManager defaultLogManager
)
  +        throws InitializationException
       {
           this( initialParameters, defaultLogManager, Thread.currentThread().getContextClassLoader()
);
       }
  @@ -183,6 +186,7 @@
       public ContainerManager( final Parameters initialParameters,
                                final LoggerManager defaultLogManager,
                                final ClassLoader rootClassLoader )
  +        throws InitializationException
       {
           m_initialParameters = initialParameters;
           m_contextClassLoader = rootClassLoader;
  @@ -243,6 +247,7 @@
        * wanting to use your own class).
        */
       protected void recycleContainer()
  +        throws InitializationException
       {
           if ( null != m_containerInstance )
           {
  @@ -269,7 +274,22 @@
               m_containerInstance = null;
           }
   
  -        Container instance = new Container();
  +        Container instance = null;
  +        try
  +        {
  +            instance = (Container) m_contextClassLoader
  +                    .loadClass( m_initialParameters.getParameter( CONTAINER_CLASS ) )
  +                    .newInstance();
  +        }
  +        catch ( Exception e )
  +        {
  +            instance = null;
  +            if ( m_defaultLogger.isFatalErrorEnabled() )
  +            {
  +                m_defaultLogger.fatalError( "Cannot set up the Container, this is an error
I cannot recover from.", e );
  +            }
  +            return;
  +        }
   
           try
           {
  
  
  
  1.1                  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/InitializationException.java
  
  Index: InitializationException.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.excalibur.system;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * This exception is used to indicate something went horribly wrong in the
   * ContainerManager, and it is unable to create a new instance of your Container.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/01/18 23:21:01 $
   */
  public class InitializationException extends CascadingException
  {
      public InitializationException( final String message )
      {
          super( message );
      }
  
      public InitializationException( final String message, final Throwable source)
      {
          super( message, source );
      }
  }
  
  
  
  

--
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