diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-08 11:20:25 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-08 11:20:25 +0000 |
commit | 2065b96f925aba5d811a24c64eaa65306f49ce64 (patch) | |
tree | 5064a02d9d5bc2526d32fe2faebec08355030fa7 /branches/sca-java-1.4/modules | |
parent | deb9cefca7bae23e525b864c8400a3f379cb0bbe (diff) |
TUSCANY-2593, fix for handling exceptions merged from 1.x branch fixes in r732680, 732679, 732664, 732663, 732416, and 732415.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@732687 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.4/modules')
4 files changed, 58 insertions, 23 deletions
diff --git a/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java index 2fcb07a07f..e229cc9043 100644 --- a/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java +++ b/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.jms.provider; +import java.lang.reflect.InvocationTargetException; + import javax.jms.JMSException; import javax.jms.Message; import javax.jms.ObjectMessage; @@ -101,7 +103,11 @@ public abstract class AbstractMessageProcessor implements JMSMessageProcessor { try { ObjectMessage message = session.createObjectMessage(); - message.setObject(o); + if (o instanceof ServiceRuntimeException && ((ServiceRuntimeException)o).getCause() instanceof InvocationTargetException) { + message.setObject(o.getCause() ); + } else { + message.setObject(o); + } message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; diff --git a/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java index 96d6ab7c46..a4cc79426e 100644 --- a/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java +++ b/branches/sca-java-1.4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java @@ -30,6 +30,7 @@ import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingException; import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.util.FaultException; import org.apache.tuscany.sca.invocation.DataExchangeSemantics; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -204,8 +205,10 @@ public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics { if ((e.getCause().getCause() instanceof RuntimeException)) { tuscanyMsg.setFaultBody(e.getCause()); } else { - tuscanyMsg.setFaultBody(e.getCause().getCause()); + tuscanyMsg.setFaultBody(((InvocationTargetException)e.getCause()).getTargetException()); } + } else if (e.getCause() instanceof FaultException) { + tuscanyMsg.setFaultBody(e.getCause()); } else { tuscanyMsg.setFaultBody(e); } diff --git a/branches/sca-java-1.4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java b/branches/sca-java-1.4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java index 925a7c10a5..906628ee32 100644 --- a/branches/sca-java-1.4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java +++ b/branches/sca-java-1.4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java @@ -88,7 +88,7 @@ public class RuntimeWireInvoker implements Invoker{ // shouldn't take it out of the response message in the first place msg.setBody(response); } catch (InvocationTargetException e) { - throw new ServiceRuntimeException(e); +// throw new ServiceRuntimeException(e); } return msg; diff --git a/branches/sca-java-1.4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java b/branches/sca-java-1.4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java index 75a0aa8131..0cd6286c87 100644 --- a/branches/sca-java-1.4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java +++ b/branches/sca-java-1.4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java @@ -120,36 +120,62 @@ public class JAXWSFaultExceptionMapper implements FaultExceptionMapper { } catch (Throwable e) { // Ignore } - try { - // FIXME: What about if the faultBeanClass is a subclass of the argument type? - ctor = exceptionClass.getConstructor(String.class, faultBeanClass, Throwable.class); - ex = ctor.newInstance(message, faultInfo, cause); - } catch (NoSuchMethodException e1) { + if (faultInfo == null) { try { - ctor = exceptionClass.getConstructor(String.class, faultInfo.getClass()); - ex = ctor.newInstance(message, faultInfo); - } catch (NoSuchMethodException e2) { + ctor = exceptionClass.getConstructor(String.class, Throwable.class); + ex = ctor.newInstance(message, cause); + } catch (NoSuchMethodException e1) { try { - ctor = exceptionClass.getConstructor(String.class, Throwable.class); - ex = ctor.newInstance(message, cause); - populateException(ex, faultInfo); - } catch (NoSuchMethodException e3) { + ctor = exceptionClass.getConstructor(String.class); + ex = ctor.newInstance(message); + } catch (NoSuchMethodException e2) { try { - ctor = exceptionClass.getConstructor(String.class); - ex = ctor.newInstance(message); - populateException(ex, faultInfo); - } catch (NoSuchMethodException e4) { + ctor = exceptionClass.getConstructor(Throwable.class); + ex = ctor.newInstance(cause); + } catch (NoSuchMethodException e3) { ctor = exceptionClass.getConstructor(); - if (ctor != null) { - ex = ctor.newInstance(); + ex = ctor.newInstance(); + } + } + } + } else { + try { + // FIXME: What about if the faultBeanClass is a subclass of the argument type? + ctor = exceptionClass.getConstructor(String.class, faultBeanClass, Throwable.class); + ex = ctor.newInstance(message, faultInfo, cause); + } catch (NoSuchMethodException e1) { + try { + ctor = exceptionClass.getConstructor(String.class, faultInfo.getClass()); + ex = ctor.newInstance(message, faultInfo); + } catch (NoSuchMethodException e2) { + try { + ctor = exceptionClass.getConstructor(String.class, Throwable.class); + ex = ctor.newInstance(message, cause); + populateException(ex, faultInfo); + } catch (NoSuchMethodException e3) { + try { + ctor = exceptionClass.getConstructor(String.class); + ex = ctor.newInstance(message); populateException(ex, faultInfo); - } else { - ex = new FaultException(message, faultInfo, cause); + } catch (NoSuchMethodException e4) { + try { + ctor = exceptionClass.getConstructor(); + if (ctor != null) { + ex = ctor.newInstance(); + populateException(ex, faultInfo); + } else { + ex = new FaultException(message, faultInfo, cause); + } + } catch (NoSuchMethodException e5) { + ctor = exceptionClass.getConstructor(); + ex = ctor.newInstance(); + } } } } } } + return ex; } |