donaldp     02/05/18 22:38:29

  Modified:    src/java/org/apache/avalon/phoenix/components/application
                        DefaultApplication.java
               src/java/org/apache/avalon/phoenix/components/lifecycle
                        LifecycleHelper.java
  Added:       src/java/org/apache/avalon/phoenix/components/lifecycle
                        LifecycleException.java
  Log:
  Make the LifecycleHelper throw a LifecycleException if a failure occurs when 
processing a component.
  
  Revision  Changes    Path
  1.23      +8 -7      
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java
  
  Index: DefaultApplication.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DefaultApplication.java   19 May 2002 03:58:30 -0000      1.22
  +++ DefaultApplication.java   19 May 2002 05:38:29 -0000      1.23
  @@ -12,11 +12,15 @@
   import java.util.List;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.phoenix.ApplicationListener;
  +import org.apache.avalon.phoenix.BlockListener;
  +import org.apache.avalon.phoenix.components.lifecycle.LifecycleHelper;
  +import org.apache.avalon.phoenix.components.lifecycle.LifecycleException;
   import org.apache.avalon.phoenix.interfaces.Application;
   import org.apache.avalon.phoenix.interfaces.ApplicationContext;
   import org.apache.avalon.phoenix.interfaces.ApplicationException;
  @@ -24,9 +28,6 @@
   import org.apache.avalon.phoenix.metadata.BlockListenerMetaData;
   import org.apache.avalon.phoenix.metadata.BlockMetaData;
   import org.apache.avalon.phoenix.metadata.SarMetaData;
  -import org.apache.avalon.phoenix.components.lifecycle.LifecycleHelper;
  -import org.apache.avalon.phoenix.ApplicationListener;
  -import org.apache.avalon.phoenix.BlockListener;
   import org.apache.excalibur.threadcontext.ThreadContext;
   
   /**
  @@ -439,7 +440,6 @@
           }
       }
   
  -
       /**
        * Method to run a <code>Block</code> through it's startup phase.
        * This will involve notification of <code>BlockListener</code>
  @@ -490,6 +490,7 @@
        * @param entry the entry containing Block
        */
       public void shutdown( final BlockEntry entry )
  +        throws LifecycleException
       {
           entry.setState( State.DESTROYING );
   
  
  
  
  1.8       +22 -7     
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/LifecycleHelper.java
  
  Index: LifecycleHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/LifecycleHelper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LifecycleHelper.java      19 May 2002 03:04:26 -0000      1.7
  +++ LifecycleHelper.java      19 May 2002 05:38:29 -0000      1.8
  @@ -9,7 +9,6 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  -import org.apache.avalon.framework.CascadingException;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
  @@ -17,6 +16,7 @@
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  @@ -26,7 +26,6 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.framework.container.ContainerUtil;
   
   /**
    * This is a class to help an Application manage lifecycle of
  @@ -65,13 +64,13 @@
        *
        * @param name the name o f the component
        * @param entry the entry representing object
  -     * @throws Exception if an error occurs when block passes
  +     * @throws LifecycleException if an error occurs when block passes
        *            through a specific lifecycle stage
        */
       public Object startup( final String name,
                              final Object entry,
                              final ResourceAccessor accessor )
  -        throws Exception
  +        throws LifecycleException
       {
           int stage = 0;
           try
  @@ -175,7 +174,14 @@
        */
       public void shutdown( final String name,
                             final Object object )
  +        throws LifecycleException
       {
  +        //Stage at which failure occured
  +        int stage = 0;
  +
  +        //Failure exception
  +        Throwable failure = null;
  +
           //Stoppable stage
           if( object instanceof Startable )
           {
  @@ -187,6 +193,8 @@
               catch( final Throwable t )
               {
                   safeFail( name, STAGE_STOP, t );
  +                failure = t;
  +                stage = STAGE_STOP;
               }
           }
   
  @@ -201,10 +209,17 @@
               catch( final Throwable t )
               {
                   safeFail( name, STAGE_DISPOSE, t );
  +                failure = t;
  +                stage = STAGE_DISPOSE;
               }
           }
   
           notice( name, STAGE_DESTROY );
  +
  +        if( null != failure )
  +        {
  +            fail( name, stage, failure );
  +        }
       }
   
       /**
  @@ -250,10 +265,10 @@
        * @param name the name of block that caused failure
        * @param stage the stage
        * @param t the exception thrown
  -     * @throws java.lang.Exception containing error
  +     * @throws LifecycleException containing error
        */
       private void fail( final String name, final int stage, final Throwable t 
)
  -        throws Exception
  +        throws LifecycleException
       {
           //final String reason = t.getMessage();
           final String reason = t.toString();
  @@ -262,6 +277,6 @@
                              name,
                              new Integer( stage ), reason );
           getLogger().error( message );
  -        throw new CascadingException( message, t );
  +        throw new LifecycleException( message, t );
       }
   }
  
  
  
  1.1                  
jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/lifecycle/LifecycleException.java
  
  Index: LifecycleException.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.phoenix.components.lifecycle;
  
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * Exception to indicate error processing block through its lifecycle.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/05/19 05:38:29 $
   */
  public final class LifecycleException
      extends CascadingException
  {
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public LifecycleException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>VerifyException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public LifecycleException( final String message, final Throwable 
throwable )
      {
          super( message, throwable );
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to