commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons-sandbox/chain/src/test/org/apache/commons/chain/impl ExceptionFilter.java NonDelegatingFilter.java
Date Sun, 31 Aug 2003 21:50:53 GMT
craigmcc    2003/08/31 14:50:53

  Modified:    chain/src/java/org/apache/commons/chain Chain.java
                        Filter.java
               chain/src/java/org/apache/commons/chain/generic
                        LookupCommand.java
               chain/src/java/org/apache/commons/chain/impl
                        CatalogBase.java ChainBase.java
               chain/src/test/org/apache/commons/chain/impl
                        ExceptionFilter.java NonDelegatingFilter.java
  Log:
  Change signature of Filter.postprocess() to return a boolean that indicates
  an exception has been "handled" and therefore does not need to be rethrown
  at the end of the Filter's processing.
  
  Revision  Changes    Path
  1.2       +5 -4      jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/Chain.java
  
  Index: Chain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/Chain.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Chain.java	11 Aug 2003 04:44:16 -0000	1.1
  +++ Chain.java	31 Aug 2003 21:50:53 -0000	1.2
  @@ -148,7 +148,8 @@
        *  {@link Chain}
        *
        * @exception Exception if thrown by one of the {@link Command}s
  -     *  in this {@link Chain}
  +     *  in this {@link Chain} but not handled by a <code>postprocess()</code>
  +     *  method of a {@link Filter}
        * @exception IllegalArgumentException if <code>context</code>
        *  is <code>null</code>
        *
  
  
  
  1.2       +9 -5      jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/Filter.java
  
  Index: Filter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/Filter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Filter.java	11 Aug 2003 04:44:17 -0000	1.1
  +++ Filter.java	31 Aug 2003 21:50:53 -0000	1.2
  @@ -103,8 +103,12 @@
        *
        * @exception IllegalArgumentException if <code>context</code>
        *  is <code>null</code>
  +     *
  +     * @return If a non-null <code>exception</code> was "handled" by this
  +     *  method (and therefore need not be rethrown), return <code>true</code>;
  +     *  otherwise return <code>false</code>
        */ 
  -   public void postprocess(Context context, Exception exception);
  +   public boolean postprocess(Context context, Exception exception);
   
   
   }
  
  
  
  1.2       +7 -6      jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/generic/LookupCommand.java
  
  Index: LookupCommand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/generic/LookupCommand.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LookupCommand.java	11 Aug 2003 04:44:18 -0000	1.1
  +++ LookupCommand.java	31 Aug 2003 21:50:53 -0000	1.2
  @@ -226,14 +226,15 @@
       }
   
   
  -    public void postprocess(Context context, Exception exception) {
  +    public boolean postprocess(Context context, Exception exception) {
   
   	Command command = getCommand(context);
           if (command != null) {
               if (command instanceof Filter) {
  -                ((Filter) command).postprocess(context, exception);
  +                return (((Filter) command).postprocess(context, exception));
               }
           }
  +        return (false);
   
       }
   
  
  
  
  1.3       +5 -4      jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/impl/CatalogBase.java
  
  Index: CatalogBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/impl/CatalogBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CatalogBase.java	12 Aug 2003 20:33:24 -0000	1.2
  +++ CatalogBase.java	31 Aug 2003 21:50:53 -0000	1.3
  @@ -66,6 +66,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import org.apache.commons.chain.Catalog;
  +import org.apache.commons.chain.Chain;
   import org.apache.commons.chain.Command;
   
   
  
  
  
  1.3       +13 -6     jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/impl/ChainBase.java
  
  Index: ChainBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/impl/ChainBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChainBase.java	12 Aug 2003 20:33:24 -0000	1.2
  +++ ChainBase.java	31 Aug 2003 21:50:53 -0000	1.3
  @@ -224,10 +224,17 @@
           if (i >= n) { // Fell off the end of the chain
               i--;
           }
  +        boolean handled = false;
  +        boolean result = false;
           for (int j = i; j >= 0; j--) {
               if (commands[j] instanceof Filter) {
                   try {
  -                    ((Filter) commands[j]).postprocess(context, saveException);
  +                    result =
  +                        ((Filter) commands[j]).postprocess(context,
  +                                                           saveException);
  +                    if (result) {
  +                        handled = true;
  +                    }
                   } catch (Exception e) {
                       ; // Silently ignore
                   }
  @@ -235,7 +242,7 @@
           }
   
           // Return the exception or result state from the last execute()
  -        if (saveException != null) {
  +        if ((saveException != null) && !handled) {
               throw saveException;
           } else {
               return (saveResult);
  
  
  
  1.3       +6 -5      jakarta-commons-sandbox/chain/src/test/org/apache/commons/chain/impl/ExceptionFilter.java
  
  Index: ExceptionFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/test/org/apache/commons/chain/impl/ExceptionFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExceptionFilter.java	12 Aug 2003 20:33:25 -0000	1.2
  +++ ExceptionFilter.java	31 Aug 2003 21:50:53 -0000	1.3
  @@ -106,8 +106,9 @@
   
   
       // Postprocess command for this Filter
  -    public void postprocess(Context context, Exception exception) {
  +    public boolean postprocess(Context context, Exception exception) {
           log(context, id2);
  +        return (false);
       }
   
   
  
  
  
  1.3       +6 -5      jakarta-commons-sandbox/chain/src/test/org/apache/commons/chain/impl/NonDelegatingFilter.java
  
  Index: NonDelegatingFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/chain/src/test/org/apache/commons/chain/impl/NonDelegatingFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NonDelegatingFilter.java	12 Aug 2003 20:33:25 -0000	1.2
  +++ NonDelegatingFilter.java	31 Aug 2003 21:50:53 -0000	1.3
  @@ -118,8 +118,9 @@
   
   
       // Postprocess method for this Filter
  -    public void postprocess(Context context, Exception exception) {
  +    public boolean postprocess(Context context, Exception exception) {
           log(context, id2);
  +        return (false);
       }
   
   
  
  
  

Mime
View raw message