diff options
Diffstat (limited to 'branches/sca-java-1.4')
11 files changed, 207 insertions, 25 deletions
diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java new file mode 100644 index 0000000000..19b584950a --- /dev/null +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java @@ -0,0 +1,28 @@ +/*
+ * 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.tuscany.sca.binding.jms;
+
+public class CheckedExcpetion2Args extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetion2Args(String s, Throwable e) {
+ super(s, e);
+ }
+}
diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java new file mode 100644 index 0000000000..b12e3a562e --- /dev/null +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java @@ -0,0 +1,28 @@ +/*
+ * 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.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionChained extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionChained(Throwable e) {
+ super(e);
+ }
+}
diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java new file mode 100644 index 0000000000..b23db73c01 --- /dev/null +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java @@ -0,0 +1,28 @@ +/*
+ * 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.tuscany.sca.binding.jms;
+
+public class CheckedExcpetionNoArgs extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public CheckedExcpetionNoArgs() {
+ super();
+ }
+}
diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java index 46bf911def..4351b17cd6 100644 --- a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java @@ -25,6 +25,9 @@ import org.osoa.sca.annotations.Remotable; public interface ExceptionService { public void throwChecked() throws CheckedExcpetion; + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs; + public void throwChecked2Args() throws CheckedExcpetion2Args; + public void throwCheckedChained() throws CheckedExcpetionChained; public void throwUnChecked(); } diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java index cd3c09e17f..cb244a5160 100644 --- a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java @@ -38,6 +38,18 @@ public class ExceptionServiceClient implements ExceptionService { service.throwChecked(); } + public void throwChecked2Args() throws CheckedExcpetion2Args { + service.throwChecked2Args(); + } + + public void throwCheckedChained() throws CheckedExcpetionChained { + service.throwCheckedChained(); + } + + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs { + service.throwCheckedNoArgs(); + } + public void throwUnChecked() { service.throwUnChecked(); } diff --git a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java index ab293a5df1..40780709f4 100644 --- a/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java +++ b/branches/sca-java-1.4/itest/jms/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java @@ -25,6 +25,18 @@ public class ExceptionServiceImpl implements ExceptionService { throw new CheckedExcpetion("foo"); } + public void throwChecked2Args() throws CheckedExcpetion2Args { + throw new CheckedExcpetion2Args("foo", new Exception("bla")); + } + + public void throwCheckedChained() throws CheckedExcpetionChained { + throw new CheckedExcpetionChained(new Exception("bla")); + } + + public void throwCheckedNoArgs() throws CheckedExcpetionNoArgs { + throw new CheckedExcpetionNoArgs(); + } + public void throwUnChecked() { throw new RuntimeException("bla"); } diff --git a/branches/sca-java-1.4/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/branches/sca-java-1.4/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java index ba3e697e13..22ebe9afcf 100644 --- a/branches/sca-java-1.4/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java +++ b/branches/sca-java-1.4/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java @@ -19,12 +19,12 @@ package org.apache.tuscany.sca.binding.jms; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; /** @@ -41,7 +41,7 @@ public class ExceptionsTestCase { } @Test - @Ignore // TUSCANY-2593, currently fails for some jaxws reason? +// @Ignore // TUSCANY-2593, currently fails for some jaxws reason? public void testChecked() { ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); try { @@ -53,6 +53,42 @@ public class ExceptionsTestCase { } @Test + public void testCheckedNoArgs() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwCheckedNoArgs(); + fail(); + } catch (CheckedExcpetionNoArgs e) { + // ok + } + } + + @Test + public void testChecked2Args() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwChecked2Args(); + fail(); + } catch (CheckedExcpetion2Args e) { + assertEquals("foo", e.getMessage()); + assertNotNull(e.getCause()); + assertEquals("bla", e.getCause().getMessage()); + } + } + + @Test + public void testCheckedChained() { + ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); + try { + service.throwCheckedChained(); + fail(); + } catch (CheckedExcpetionChained e) { + assertNotNull(e.getCause()); + assertEquals("bla", e.getCause().getMessage()); + } + } + + @Test public void testUnChecked() { ExceptionService service = scaDomain.getService(ExceptionService.class, "ExceptionServiceClient"); try { 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; } |