[seam-commits] Seam SVN: r13077 - in modules/faces/branches/exception_handling/impl/src/main: resources/META-INF and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Jun 7 11:35:45 EDT 2010
Author: lightguard
Date: 2010-06-07 11:35:45 -0400 (Mon, 07 Jun 2010)
New Revision: 13077
Modified:
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
modules/faces/branches/exception_handling/impl/src/main/resources/META-INF/faces-config.xml
Log:
I got a little help, still not there yet though
Modified: 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 2010-06-07 07:50:09 UTC (rev 13076)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandler.java 2010-06-07 15:35:45 UTC (rev 13077)
@@ -22,12 +22,20 @@
package org.jboss.seam.exceptionhandling;
+import org.jboss.seam.faces.util.BeanManagerUtils;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.TypeLiteral;
import javax.faces.FacesException;
import javax.faces.context.*;
import javax.faces.context.ExceptionHandler;
import javax.faces.event.ExceptionQueuedEvent;
import javax.inject.Inject;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.List;
@@ -35,43 +43,60 @@
public class SeamExceptionHandler extends ExceptionHandlerWrapper
{
- @Inject
private BeanManager beanManager;
+ private BeanManagerUtils managerUtils;
+
private ExceptionHandler wrapped;
- public SeamExceptionHandler()
+ public SeamExceptionHandler() throws NamingException
{
+ this.beanManager = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
+ this.managerUtils = new BeanManagerUtils();
}
- public SeamExceptionHandler(ExceptionHandler wrappedHandler)
+ public SeamExceptionHandler(ExceptionHandler wrappedHandler) throws NamingException
{
+ this();
this.wrapped = wrappedHandler;
}
@Override
public void handle() throws FacesException
{
- Set<?> beans;
+ Set<Bean<?>> beans;
ExceptionQueuedEvent event;
Throwable exception;
- Throwable realException;
+ HandlerChain chain;
+ FacesState state = this.managerUtils.getContextualInstance(this.beanManager, FacesStateImpl.class);
for (Iterator<ExceptionQueuedEvent> i = this.getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();)
{
event = i.next();
exception = event.getContext().getException();
- realException = this.getRootCause(exception);
+ final Throwable realException = (this.getRootCause(exception) != null) ? this.getRootCause(exception) : exception;
- if (realException == null)
- {
- realException = exception;
- }
+ chain = new HandlerChainImpl();
+ beans = this.beanManager.getBeans(new ParameterizedType() {
+ public Type[] getActualTypeArguments()
+ {
+ return new Type[] {realException.getClass(), FacesState.class};
+ }
+ public Type getRawType()
+ {
+ return org.jboss.seam.exceptionhandling.ExceptionHandler.class;
+ }
+
+ public Type getOwnerType()
+ {
+ return null;
+ }
+ });
// TODO: Find handlers for the exception type
- // TODO: Create handler chain
// TODO: execute handler
+
}
if (this.wrapped != null)
Modified: 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 2010-06-07 07:50:09 UTC (rev 13076)
+++ modules/faces/branches/exception_handling/impl/src/main/java/org/jboss/seam/exceptionhandling/SeamExceptionHandlerFactory.java 2010-06-07 15:35:45 UTC (rev 13077)
@@ -24,6 +24,7 @@
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;
+import javax.naming.NamingException;
public class SeamExceptionHandlerFactory extends ExceptionHandlerFactory
{
@@ -38,7 +39,13 @@
public javax.faces.context.ExceptionHandler getExceptionHandler()
{
ExceptionHandler result = this.parent.getExceptionHandler();
- result = new SeamExceptionHandler(result);
- return result;
+ try
+ {
+ return new SeamExceptionHandler(result);
+ }
+ catch (NamingException e)
+ {
+ return result;
+ }
}
}
Modified: modules/faces/branches/exception_handling/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- modules/faces/branches/exception_handling/impl/src/main/resources/META-INF/faces-config.xml 2010-06-07 07:50:09 UTC (rev 13076)
+++ modules/faces/branches/exception_handling/impl/src/main/resources/META-INF/faces-config.xml 2010-06-07 15:35:45 UTC (rev 13077)
@@ -19,6 +19,7 @@
<factory>
<external-context-factory>org.jboss.seam.faces.environment.SeamExternalContextFactory</external-context-factory>
+ <exception-handler-factory>org.jboss.seam.exceptionhandling.SeamExceptionHandlerFactory</exception-handler-factory>
</factory>
<application>
@@ -60,4 +61,4 @@
</system-event-listener>
</application>
-</faces-config>
\ No newline at end of file
+</faces-config>
More information about the seam-commits
mailing list