[jboss-cvs] jboss-seam/src/main/org/jboss/seam/exceptions ...

Gavin King gavin.king at jboss.com
Sat Feb 3 20:13:19 EST 2007


  User: gavin   
  Date: 07/02/03 20:13:19

  Modified:    src/main/org/jboss/seam/exceptions           
                        AnnotationErrorHandler.java
                        AnnotationRedirectHandler.java
                        ConfigErrorHandler.java ConfigRedirectHandler.java
                        DebugPageHandler.java ErrorHandler.java
                        ExceptionHandler.java RedirectHandler.java
  Removed:     src/main/org/jboss/seam/exceptions           
                        AnnotationRenderHandler.java
                        ConfigRenderHandler.java RenderHandler.java
  Log:
  redesigned exception handling
  
  Revision  Changes    Path
  1.2       +0 -1      jboss-seam/src/main/org/jboss/seam/exceptions/AnnotationErrorHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AnnotationErrorHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/AnnotationErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- AnnotationErrorHandler.java	17 Dec 2006 19:46:41 -0000	1.1
  +++ AnnotationErrorHandler.java	4 Feb 2007 01:13:19 -0000	1.2
  @@ -31,7 +31,6 @@
         return e.getClass().getAnnotation(HttpError.class).end();
      }
      
  -   @Override
      protected boolean isRollback(Exception e)
      {
         return e.getClass().getAnnotation(HttpError.class).rollback();
  
  
  
  1.2       +1 -7      jboss-seam/src/main/org/jboss/seam/exceptions/AnnotationRedirectHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: AnnotationRedirectHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/AnnotationRedirectHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- AnnotationRedirectHandler.java	17 Dec 2006 19:46:41 -0000	1.1
  +++ AnnotationRedirectHandler.java	4 Feb 2007 01:13:19 -0000	1.2
  @@ -3,19 +3,14 @@
    */
   package org.jboss.seam.exceptions;
   
  -import javax.faces.event.PhaseId;
  -
   import org.jboss.seam.annotations.Redirect;
  -import org.jboss.seam.contexts.Lifecycle;
   
   public class AnnotationRedirectHandler extends RedirectHandler
   {
      @Override
      public boolean isHandler(Exception e)
      {
  -      return e.getClass().isAnnotationPresent(Redirect.class) && 
  -            Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE && 
  -            Lifecycle.getPhaseId()!=null;
  +      return e.getClass().isAnnotationPresent(Redirect.class);
      }
      
      @Override
  @@ -36,7 +31,6 @@
         return e.getClass().getAnnotation(Redirect.class).end();
      } 
   
  -   @Override
      protected boolean isRollback(Exception e)
      {
         return e.getClass().getAnnotation(Redirect.class).rollback();
  
  
  
  1.2       +0 -1      jboss-seam/src/main/org/jboss/seam/exceptions/ConfigErrorHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConfigErrorHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/ConfigErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ConfigErrorHandler.java	17 Dec 2006 19:46:41 -0000	1.1
  +++ ConfigErrorHandler.java	4 Feb 2007 01:13:19 -0000	1.2
  @@ -45,7 +45,6 @@
         return conversation;
      }
   
  -   @Override
      protected boolean isRollback(Exception e)
      {
         return rollback;
  
  
  
  1.3       +1 -7      jboss-seam/src/main/org/jboss/seam/exceptions/ConfigRedirectHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ConfigRedirectHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/ConfigRedirectHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ConfigRedirectHandler.java	25 Jan 2007 18:08:23 -0000	1.2
  +++ ConfigRedirectHandler.java	4 Feb 2007 01:13:19 -0000	1.3
  @@ -3,9 +3,6 @@
    */
   package org.jboss.seam.exceptions;
   
  -import javax.faces.event.PhaseId;
  -
  -import org.jboss.seam.contexts.Lifecycle;
   
   public final class ConfigRedirectHandler extends RedirectHandler
   {
  @@ -39,9 +36,7 @@
      @Override
      public boolean isHandler(Exception e)
      {
  -      return clazz.isInstance(e) && 
  -            Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE && 
  -            Lifecycle.getPhaseId()!=null;
  +      return clazz.isInstance(e);
      }
   
      @Override
  @@ -50,7 +45,6 @@
         return conversation;
      }
   
  -   @Override
      protected boolean isRollback(Exception e)
      {
         return rollback;
  
  
  
  1.3       +3 -7      jboss-seam/src/main/org/jboss/seam/exceptions/DebugPageHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DebugPageHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/DebugPageHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- DebugPageHandler.java	20 Dec 2006 04:35:55 -0000	1.2
  +++ DebugPageHandler.java	4 Feb 2007 01:13:19 -0000	1.3
  @@ -3,8 +3,6 @@
    */
   package org.jboss.seam.exceptions;
   
  -import javax.faces.event.PhaseId;
  -
   import org.jboss.seam.contexts.Context;
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
  @@ -15,7 +13,7 @@
   {
   
      @Override
  -   public Object handle(Exception e) throws Exception
  +   public void handle(Exception e) throws Exception
      {
         Exceptions.log.error("redirecting to debug page", e);
         Context conversationContext = Contexts.getConversationContext();
  @@ -28,15 +26,13 @@
         redirect.setParameter( manager.getConversationIdParameter(), manager.getCurrentConversationId() );
         redirect.execute();
         conversationContext.flush();
  -      return rethrow(e);
  +      //(e);
      }
   
      @Override
      public boolean isHandler(Exception e)
      {
  -      return Lifecycle.getPhaseId()!=PhaseId.RENDER_RESPONSE && 
  -            Lifecycle.getPhaseId()!=null &&
  -            Contexts.isConversationContextActive();
  +      return true;
      }
      
      @Override
  
  
  
  1.2       +8 -5      jboss-seam/src/main/org/jboss/seam/exceptions/ErrorHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ErrorHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/ErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ErrorHandler.java	17 Dec 2006 19:46:41 -0000	1.1
  +++ ErrorHandler.java	4 Feb 2007 01:13:19 -0000	1.2
  @@ -1,21 +1,24 @@
   package org.jboss.seam.exceptions;
   
  +import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.Conversation;
   import org.jboss.seam.core.Interpolator;
  -import org.jboss.seam.util.Transactions;
   
   public abstract class ErrorHandler extends ExceptionHandler
   {
   
  +   protected abstract int getCode(Exception e);
  +
      @Override
  -   public Object handle(Exception e) throws Exception
  +   public void handle(Exception e) throws Exception
  +   {
  +      if ( Contexts.isConversationContextActive() && isEnd(e) ) 
      {
  -      if ( isEnd(e) ) Conversation.instance().end();
  -      if ( isRollback(e) ) Transactions.setTransactionRollbackOnly();
  +         Conversation.instance().end();
  +      }
         String message = getMessage(e);
         //addFacesMessage(e, message);
         error( getCode(e), Interpolator.instance().interpolate( getDisplayMessage(e, message) ) );
  -      return rethrow(e);
      }
   
   }
  \ No newline at end of file
  
  
  
  1.3       +2 -32     jboss-seam/src/main/org/jboss/seam/exceptions/ExceptionHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ExceptionHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/ExceptionHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ExceptionHandler.java	20 Dec 2006 04:35:55 -0000	1.2
  +++ ExceptionHandler.java	4 Feb 2007 01:13:19 -0000	1.3
  @@ -3,8 +3,6 @@
    */
   package org.jboss.seam.exceptions;
   
  -import javax.faces.context.FacesContext;
  -
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.FacesMessages;
   import org.jboss.seam.core.Navigator;
  @@ -12,29 +10,18 @@
   
   public abstract class ExceptionHandler extends Navigator
   {
  -   public abstract Object handle(Exception e) throws Exception;
  +   public abstract void handle(Exception e) throws Exception;
      public abstract boolean isHandler(Exception e);
      
      protected String getMessage(Exception e)
      {
         throw new UnsupportedOperationException();
      }
  -   protected String getViewId(Exception e)
  -   {
  -      throw new UnsupportedOperationException();
  -   }
  +   
      protected boolean isEnd(Exception e)
      {
         throw new UnsupportedOperationException();
      }
  -   protected boolean isRollback(Exception e)
  -   {
  -      throw new UnsupportedOperationException();
  -   }
  -   protected int getCode(Exception e)
  -   {
  -      throw new UnsupportedOperationException();
  -   }
   
      public static String getDisplayMessage(Exception e, String message)
      {
  @@ -60,22 +47,5 @@
         }
      }
      
  -   public static Object rethrow(Exception e) throws Exception
  -   {
  -      //SeamExceptionFilter does *not* do these things, which 
  -      //would normally happen in the phase listener after a 
  -      //responseComplete() call, but because we are rethrowing,
  -      //the phase listener might not get called (due to a bug!)
  -      /*FacesMessages.afterPhase();
  -      if ( Contexts.isConversationContextActive() )
  -      {
  -         Manager.instance().endRequest( ContextAdaptor.getSession( externalContext, true ) );
  -      }*/
  -      
  -      FacesContext facesContext = FacesContext.getCurrentInstance();
  -      facesContext.responseComplete();
  -      facesContext.getExternalContext().getRequestMap().put("org.jboss.seam.exceptionHandled", e);
  -      throw e;
  -   }
   
   }
  \ No newline at end of file
  
  
  
  1.3       +18 -7     jboss-seam/src/main/org/jboss/seam/exceptions/RedirectHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RedirectHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/exceptions/RedirectHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- RedirectHandler.java	25 Jan 2007 16:40:46 -0000	1.2
  +++ RedirectHandler.java	4 Feb 2007 01:13:19 -0000	1.3
  @@ -1,19 +1,30 @@
   package org.jboss.seam.exceptions;
  +
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.Conversation;
  -import org.jboss.seam.util.Transactions;
  +import org.jboss.seam.core.RedirectException;
  +
   public abstract class RedirectHandler extends ExceptionHandler
   {
      
  +   protected abstract String getViewId(Exception e);
  +
      @Override
  -   public Object handle(Exception e) throws Exception
  +   public void handle(Exception e) throws Exception
      {
         addFacesMessage( e, getMessage(e) );
         
  -      if (Contexts.isConversationContextActive() && isEnd(e) ) Conversation.instance().end();
  -      if ( isRollback(e) ) Transactions.setTransactionRollbackOnly();
  -      
  +      if ( Contexts.isConversationContextActive() && isEnd(e) ) 
  +      {
  +         Conversation.instance().end();
  +      }
  +      try
  +      {
         redirect( getViewId(e), null );
  -      return rethrow(e);
  +      }
  +      catch (RedirectException re)
  +      {
  +         //do nothing
  +      }
      }
   }
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list