[seam-commits] Seam SVN: r13071 - in modules/faces/branches/exception_handling: api/src/main/java/org/jboss/seam/exceptionhandling and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jun 4 23:32:55 EDT 2010


Author: lightguard
Date: 2010-06-04 23:32:54 -0400 (Fri, 04 Jun 2010)
New Revision: 13071

Added:
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandler.java
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/State.java
   modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/package-info.java
   modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/
   modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java
   modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java
   modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java
   modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java
Log:
Initial checkin of exception handling code.

Main blocker right now is determining how to find the handler classes.
Secondary blocker is creating tests :)

Added: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandler.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandler.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.exceptionhandling;
+
+/**
+ * Registers an exception handler for a specific exception and state, this
+ * is the main entry point for using Seam's exception handling infrastructure.
+ */
+public interface ExceptionHandler<E extends Class<Throwable>, S extends State>
+{
+   /**
+    * @return the numeric priority of this handler in relationship to
+    *         other handlers, 1 being top priority
+    */
+   int getPriority();
+
+   /**
+    * Method called to execute logic for an uncaught exception.
+    * @param chain Chain object used to continue handling chain
+    * @param state container for any useful application state
+    * @param e uncaught exception
+    */
+   void handle(HandlerChain chain, S state, E e);
+}


Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/ExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * Java Server Faces implementation of {@link State}.
+ */
+public interface FacesState extends State
+{
+   /**
+    * @return the currently active Faces Context object
+    */
+   FacesContext getFacesContext();
+
+   /**
+    * Convenience method to facilitate navigation to a view id in an
+    * {@link ExceptionHandler}.
+    * @param viewId JSF view to navigate
+    */
+   void navigate(String viewId);
+}


Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/FacesState.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.exceptionhandling;
+
+/**
+ * Provides the developer methods to affect the traversal of the
+ * chain of {@link ExceptionHandler} instances.
+ */
+public interface HandlerChain
+{
+   /**
+    * Continue with the chain.
+    */
+   void next();
+}


Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/HandlerChain.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/State.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/State.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/State.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * The State object is meant to provide any state that may be helpful for the developer
+ * in determining what to do with a particular exceptionhandling. It may include and application
+ * state, active processes, or other convenience methods for the {@link ExceptionHandler}
+ * developer.
+ * <p>
+ * A servlet state may include methods to retrieve the HttpServletRequest, HttpServletResponse
+ * and possibly a navigation convenience method.
+ */
+public interface State
+{
+   /**
+    * @return current BeanManager.
+    */
+   public BeanManager getBeanManager();
+}


Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/State.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/package-info.java
===================================================================
--- modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/package-info.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/package-info.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+/**
+ * An extensible exception handling handling framework. 
+ */
+package org.jboss.seam.exceptionhandling;


Property changes on: modules/faces/branches/exception_handling/api/src/main/java/org/jboss/seam/exceptionhandling/package-info.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+import javax.inject.Inject;
+
+public class FacesStateImpl implements FacesState
+{
+   @Inject
+   private BeanManager beanManager;
+
+   @Inject
+   private FacesContext facesContext;
+
+   @Inject
+   private NavigationHandler navigationHandler;
+
+   /**
+    * @return the currently active Faces Context object
+    */
+   public FacesContext getFacesContext()
+   {
+      return this.facesContext;
+   }
+
+   /**
+    * Convenience method to facilitate navigation to a view id in an
+    * {@link ExceptionHandler}.
+    *
+    * @param viewId JSF view to navigate
+    */
+   public void navigate(String viewId)
+   {
+      this.navigationHandler.handleNavigation(this.facesContext, null, viewId);
+   }
+
+   /**
+    * @return current BeanManager.
+    */
+   public BeanManager getBeanManager()
+   {
+      return this.beanManager;
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/FacesStateImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+public class HandlerChainImpl implements HandlerChain
+{
+   private boolean continueChain;
+
+   /**
+    * Continue with the chain.
+    */
+   public void next()
+   {
+      this.continueChain = true;
+   }
+
+   boolean isContinueChain()
+   {
+      return this.continueChain;
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/HandlerChainImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.FacesException;
+import javax.faces.context.*;
+import javax.faces.context.ExceptionHandler;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.inject.Inject;
+import java.lang.reflect.Type;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+public class SeamExceptionHandler extends ExceptionHandlerWrapper
+{
+   @Inject
+   private BeanManager beanManager;
+
+   private ExceptionHandler wrapped;
+
+   public SeamExceptionHandler()
+   {
+   }
+
+   public SeamExceptionHandler(ExceptionHandler wrappedHandler)
+   {
+      this.wrapped = wrappedHandler;
+   }
+
+   @Override
+   public void handle() throws FacesException
+   {
+      Set<?> beans;
+      ExceptionQueuedEvent event;
+      Throwable exception;
+      Throwable realException;
+
+      for (Iterator<ExceptionQueuedEvent> i = this.getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();)
+      {
+         event = i.next();
+         exception = event.getContext().getException();
+
+         realException = this.getRootCause(exception);
+
+         if (realException == null)
+         {
+            realException = exception;
+         }
+
+         // TODO: Find handlers for the exception type
+         // TODO: Create handler chain
+         // TODO: execute handler
+      }
+
+      if (this.wrapped != null)
+      {
+         this.wrapped.handle();
+      }
+   }
+
+   @Override
+   public javax.faces.context.ExceptionHandler getWrapped()
+   {
+      return this.wrapped;
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native

Added: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java	                        (rev 0)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java	2010-06-05 03:32:54 UTC (rev 13071)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.exceptionhandling;
+
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerFactory;
+
+public class SeamExceptionHandlerFactory extends ExceptionHandlerFactory
+{
+   private ExceptionHandlerFactory parent;
+
+   public SeamExceptionHandlerFactory(ExceptionHandlerFactory parent)
+   {
+      this.parent = parent;
+   }
+
+   @Override
+   public javax.faces.context.ExceptionHandler getExceptionHandler()
+   {
+      ExceptionHandler result =  this.parent.getExceptionHandler();
+      result = new SeamExceptionHandler(result);
+      return result;
+   }
+}


Property changes on: modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/x-java-source
Name: svn:keywords
   + Author Date Id Revision URL
Name: svn:eol-style
   + native



More information about the seam-commits mailing list