Author: rmannibucau
Date: Mon Jan 5 10:31:18 2015
New Revision: 1649497
URL: http://svn.apache.org/r1649497
Log:
NonexistentConversationException shouldn't be wrapped by FacesException
Added:
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandler.java
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandlerFactory.java
Modified:
openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml
Added:
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandler.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandler.java?rev=1649497&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandler.java
(added)
+++
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandler.java
Mon Jan 5 10:31:18 2015
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.jsf;
+
+import javax.enterprise.context.NonexistentConversationException;
+import javax.faces.FacesException;
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerWrapper;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+import java.util.Iterator;
+
+public class OwbExceptionHandler extends ExceptionHandlerWrapper
+{
+ private final ExceptionHandler delegate;
+
+ public OwbExceptionHandler(ExceptionHandler exceptionHandler)
+ {
+ this.delegate = exceptionHandler;
+ }
+
+ @Override
+ public ExceptionHandler getWrapped()
+ {
+ return delegate;
+ }
+
+ @Override
+ public void handle() throws FacesException
+ {
+ Iterator<ExceptionQueuedEvent> i =
getUnhandledExceptionQueuedEvents().iterator();
+ while (i.hasNext())
+ {
+ ExceptionQueuedEvent event = i.next();
+ ExceptionQueuedEventContext context =
(ExceptionQueuedEventContext) event.getSource();
+
+ // get the exception from context
+ Throwable t = context.getException();
+ if (NonexistentConversationException.class.isInstance(t))
+ {
+ i.remove();
+ throw RuntimeException.class.cast(t);
+ }
+ }
+ delegate.handle();
+ }
+}
Added:
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandlerFactory.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandlerFactory.java?rev=1649497&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandlerFactory.java
(added)
+++
openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/OwbExceptionHandlerFactory.java
Mon Jan 5 10:31:18 2015
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.jsf;
+
+import javax.faces.context.ExceptionHandler;
+import javax.faces.context.ExceptionHandlerFactory;
+
+public class OwbExceptionHandlerFactory extends ExceptionHandlerFactory
+{
+ private ExceptionHandlerFactory parent;
+
+ public OwbExceptionHandlerFactory(ExceptionHandlerFactory parent)
+ {
+ this.parent = parent;
+ }
+
+ @Override
+ public ExceptionHandler getExceptionHandler()
+ {
+ return new OwbExceptionHandler(parent.getExceptionHandler());
+ }
+}
Modified:
openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml?rev=1649497&r1=1649496&r2=1649497&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml
(original)
+++
openwebbeans/trunk/webbeans-jsf/src/main/resources/META-INF/faces-config.xml
Mon Jan 5 10:31:18 2015
@@ -18,14 +18,16 @@ specific language governing permissions
under the License.
-->
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<name>org_apache_openwebbeans</name>
<factory>
<application-factory>org.apache.webbeans.jsf.OwbApplicationFactory</application-factory>
+
<exception-handler-factory>org.apache.webbeans.jsf.OwbExceptionHandlerFactory</exception-handler-factory>
</factory>
<application>