[jbossws-commits] JBossWS SVN: r3942 - in branches/asoldano: integration/spi/src/main/java/org/jboss/wsf/spi/deployment and 4 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Jul 18 15:30:23 EDT 2007


Author: palin
Date: 2007-07-18 15:30:23 -0400 (Wed, 18 Jul 2007)
New Revision: 3942

Added:
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationExceptionHandler.java
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationExceptionHandler.java
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/UnwrapInvocationExceptionHandler.java
Modified:
   branches/asoldano/integration/native/src/main/resources/jbossws-native-config.xml
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/EndpointHandlerDeploymentAspect.java
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationHandler.java
   branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationHandler.java
   branches/asoldano/integration/sunri/src/main/resources/jbossws-sunri-config.xml
   branches/asoldano/integration/xfire/src/main/resources/jbossws-xfire-config.xml
   branches/asoldano/testsuite/src/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java
Log:
[JBWS-1670] fix UserException handling with SunRI and the latest deployment architecture


Modified: branches/asoldano/integration/native/src/main/resources/jbossws-native-config.xml
===================================================================
--- branches/asoldano/integration/native/src/main/resources/jbossws-native-config.xml	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/native/src/main/resources/jbossws-native-config.xml	2007-07-18 19:30:23 UTC (rev 3942)
@@ -71,6 +71,7 @@
         <entry><key>JAXRPC_JSE</key><value>org.jboss.wsf.stack.jbws.ServiceLifecycleInvocationHandler</value></entry>
       </map>
     </property>
+    <property name="invocationExceptionHandler">org.jboss.wsf.spi.invocation.UnwrapInvocationExceptionHandler</property>
   </bean>
   
   <bean name="WSNativeEventingDeploymentAspect" class="org.jboss.wsf.stack.jbws.EventingDeploymentAspect">

Modified: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/EndpointHandlerDeploymentAspect.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/EndpointHandlerDeploymentAspect.java	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/EndpointHandlerDeploymentAspect.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -26,6 +26,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.jboss.wsf.spi.invocation.InvocationExceptionHandler;
 import org.jboss.wsf.spi.invocation.InvocationHandler;
 import org.jboss.wsf.spi.invocation.RequestHandler;
 import org.jboss.wsf.spi.metadata.j2ee.UnifiedApplicationMetaData;
@@ -44,6 +45,7 @@
    private String lifecycleHandler;
 
    private Map<String, String> invocationHandlerMap = new HashMap<String, String>();
+   private String invocationExceptionHandler;
    
    public void setLifecycleHandler(String handler)
    {
@@ -77,6 +79,13 @@
             if (invocationHandler != null)
                ep.setInvocationHandler(invocationHandler);
          }
+         
+         if (invocationExceptionHandler != null)
+         {
+            InvocationHandler invocationHandler = ep.getInvocationHandler();
+            if (invocationHandler != null)
+               invocationHandler.setExceptionHandler(getInvocationExceptionHandler(dep));
+         }
       }
    }
 
@@ -138,4 +147,24 @@
       }
       return invocationHandler;
    }
+   
+   private InvocationExceptionHandler getInvocationExceptionHandler(Deployment dep)
+   {
+      InvocationExceptionHandler exceptionHandler = null;
+      try
+      {
+         Class<?> handlerClass = dep.getInitialClassLoader().loadClass(invocationExceptionHandler);
+         exceptionHandler = (InvocationExceptionHandler)handlerClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new IllegalStateException("Cannot load invocation exception handler: " + invocationExceptionHandler);
+      }
+      return exceptionHandler;
+   }
+
+   public void setInvocationExceptionHandler(String invocationExceptionHandler)
+   {
+      this.invocationExceptionHandler = invocationExceptionHandler;
+   }
 }
\ No newline at end of file

Added: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationExceptionHandler.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationExceptionHandler.java	                        (rev 0)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationExceptionHandler.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.wsf.spi.invocation;
+
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.management.MBeanException;
+
+/**
+ * A basic invocation exception handler that simply rethrows Throwable as Exception
+ * 
+ * @author Alessio Soldano, <alessio.soldano at javalinux.it>
+ * @since 17-Jun-2007
+ *
+ */
+public class BasicInvocationExceptionHandler implements InvocationExceptionHandler
+{
+   
+   public void handleInvocationException(Throwable th) throws Exception
+   {
+      if (th instanceof MBeanException)
+      {
+         throw ((MBeanException)th).getTargetException();
+      }
+
+      handleInvocationThrowable(th);
+   }
+   
+   protected void handleInvocationThrowable(Throwable th) throws Exception
+   {
+      if (th instanceof Exception)
+      {
+         throw (Exception)th;
+      }
+      else if (th instanceof Error)
+      {
+         throw (Error)th;
+      }
+      else
+      {
+         throw new UndeclaredThrowableException(th);
+      }
+   }
+   
+}

Modified: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationHandler.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationHandler.java	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/BasicInvocationHandler.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -44,6 +44,8 @@
    // provide logging
    private static final Logger log = Logger.getLogger(BasicInvocationHandler.class);
    
+   protected InvocationExceptionHandler exceptionHandler;
+   
    public Invocation createInvocation()
    {
       return new BasicEndpointInvocation();
@@ -88,30 +90,43 @@
       log.debug("Destroy: " + ep.getName());
    }
    
-   protected void handleInvocationException(Throwable th) throws Exception
+   protected final void handleInvocationException(Throwable th) throws Exception
    {
-      if (th instanceof MBeanException)
-      {
-         throw ((MBeanException)th).getTargetException();
-      }
-
-      if (th instanceof InvocationTargetException)
-      {
-         // Unwrap the throwable raised by the service endpoint implementation
-         Throwable targetEx = ((InvocationTargetException)th).getTargetException();
-         handleInvocationException(targetEx);
-      }
+//      if (th instanceof MBeanException)
+//      {
+//         throw ((MBeanException)th).getTargetException();
+//      }
+//
+//      if (th instanceof InvocationTargetException)
+//      {
+//         // Unwrap the throwable raised by the service endpoint implementation
+//         Throwable targetEx = ((InvocationTargetException)th).getTargetException();
+//         handleInvocationException(targetEx);
+//      }
+//      
+//      if (th instanceof Exception)
+//      {
+//         throw (Exception)th;
+//      }
+//      
+//      if (th instanceof Error)
+//      {
+//         throw (Error)th;
+//      }
+//      
+//      throw new UndeclaredThrowableException(th);
       
-      if (th instanceof Exception)
-      {
-         throw (Exception)th;
-      }
-      
-      if (th instanceof Error)
-      {
-         throw (Error)th;
-      }
-      
-      throw new UndeclaredThrowableException(th);
+      //delegate exception handling to the configured handler
+      exceptionHandler.handleInvocationException(th);
    }
+
+   public InvocationExceptionHandler getExceptionHandler()
+   {
+      return exceptionHandler;
+   }
+
+   public void setExceptionHandler(InvocationExceptionHandler exceptionHandler)
+   {
+      this.exceptionHandler = exceptionHandler;
+   }
 }

Added: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationExceptionHandler.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationExceptionHandler.java	                        (rev 0)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationExceptionHandler.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.wsf.spi.invocation;
+
+/**
+ * A general invocation exception handler
+ * 
+ * @author Alessio Soldano, <alessio.soldano at javalinux.it>
+ * @since 17-Jun-2007
+ *
+ */
+public interface InvocationExceptionHandler
+{
+   public void handleInvocationException(Throwable th) throws Exception;
+
+}

Modified: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationHandler.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationHandler.java	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/InvocationHandler.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -50,4 +50,7 @@
 
    /** Destroy the invocation handler */
    void destroy(Endpoint ep);
+   
+   /** Set the handler to be used to deal with invocation exceptions **/
+   void setExceptionHandler(InvocationExceptionHandler exceptionHandler);
 }

Added: branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/UnwrapInvocationExceptionHandler.java
===================================================================
--- branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/UnwrapInvocationExceptionHandler.java	                        (rev 0)
+++ branches/asoldano/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/UnwrapInvocationExceptionHandler.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.wsf.spi.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.management.MBeanException;
+
+/**
+ * An invocation exception handler that unwraps InvocationExceptions
+ * 
+ * @author Alessio Soldano, <alessio.soldano at javalinux.it>
+ * @since 17-Jun-2007
+ *
+ */
+public class UnwrapInvocationExceptionHandler extends BasicInvocationExceptionHandler
+{
+   
+   public void handleInvocationException(Throwable th) throws Exception
+   {
+      if (th instanceof InvocationTargetException)
+      {
+         // unwrap the throwable raised by the service endpoint implementation
+         Throwable targetEx = ((InvocationTargetException)th).getTargetException();
+         handleInvocationThrowable(targetEx);
+      }
+
+      if (th instanceof MBeanException)
+      {
+         throw ((MBeanException)th).getTargetException();
+      }
+
+      handleInvocationThrowable(th);
+   }
+   
+}

Modified: branches/asoldano/integration/sunri/src/main/resources/jbossws-sunri-config.xml
===================================================================
--- branches/asoldano/integration/sunri/src/main/resources/jbossws-sunri-config.xml	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/sunri/src/main/resources/jbossws-sunri-config.xml	2007-07-18 19:30:23 UTC (rev 3942)
@@ -78,6 +78,7 @@
     <property name="provides">StackEndpointHandler</property>
     <property name="requestHandler">org.jboss.wsf.stack.sunri.RequestHandlerImpl</property>
     <property name="lifecycleHandler">org.jboss.wsf.stack.sunri.LifecycleHandlerImpl</property>
+    <property name="invocationExceptionHandler">org.jboss.wsf.spi.invocation.BasicInvocationExceptionHandler</property>
   </bean>
   
   <bean name="WSMetroDescriptorDeploymentAspect" class="org.jboss.wsf.stack.sunri.SunJaxwsDeploymentAspect">

Modified: branches/asoldano/integration/xfire/src/main/resources/jbossws-xfire-config.xml
===================================================================
--- branches/asoldano/integration/xfire/src/main/resources/jbossws-xfire-config.xml	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/integration/xfire/src/main/resources/jbossws-xfire-config.xml	2007-07-18 19:30:23 UTC (rev 3942)
@@ -43,6 +43,7 @@
     <property name="provides">StackEndpointHandler</property>
     <property name="requestHandler">org.jboss.wsf.stack.xfire.RequestHandlerImpl</property>
     <property name="lifecycleHandler">org.jboss.wsf.stack.xfire.LifecycleHandlerImpl</property>
+    <property name="invocationExceptionHandler">org.jboss.wsf.spi.invocation.UnwrapInvocationExceptionHandler</property>
   </bean>
 
   <bean name="WSXFireServicesDeploymentAspect" class="org.jboss.wsf.stack.xfire.XFireServicesDeploymentAspect">

Modified: branches/asoldano/testsuite/src/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java
===================================================================
--- branches/asoldano/testsuite/src/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java	2007-07-18 19:16:32 UTC (rev 3941)
+++ branches/asoldano/testsuite/src/java/org/jboss/test/ws/jaxws/samples/exception/ExceptionTestCase.java	2007-07-18 19:30:23 UTC (rev 3942)
@@ -114,12 +114,6 @@
 
    public void testApplicationException() throws Exception
    {
-      if (isIntegrationSunRI())
-      {
-         System.out.println("FIXME: [JBWS-1670] SunRI client does not throw UserException");
-         return;
-      }
-      
       try
       {
          proxy.throwApplicationException();




More information about the jbossws-commits mailing list