diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-15 20:44:49 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-15 20:44:49 +0000 |
commit | 08e6d577358362d8da1172a47da4ace6916e6d2e (patch) | |
tree | 952bfda2ecf48191f94531e975e99035f0f8d88a | |
parent | 73ffdb3c639f918474bc0df9dac57af8b121f3ab (diff) |
TUSCANY-2967 Fix up just jmsBytes wire format to return exceptions as bytes to see if this is what we want
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775324 13f79535-47bb-0310-9956-ffa450edef68
7 files changed, 118 insertions, 4 deletions
diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java new file mode 100644 index 0000000000..e8a7102afd --- /dev/null +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.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.format.jmsbytes.helloworld; + +public class CheckedException extends Exception { + private static final long serialVersionUID = 1L; + + public CheckedException(String s) { + super(s); + } +} diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java index 878fdb4fe4..febf918d9d 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java @@ -24,11 +24,23 @@ import org.osoa.sca.annotations.Reference; public class HelloWorldReferenceImpl implements HelloWorldReference { @Reference - protected HelloWorldService helloWorldService1; + protected HelloWorldServiceReference helloWorldService1; public String getGreetings(String name){ byte[] bytesValue = helloWorldService1.getByteArrayGreetings(name.getBytes()); - String stringValue = new String(bytesValue); + String stringValue = new String(bytesValue); + + try { + helloWorldService1.throwChecked(null); + } catch (Exception e) { + stringValue += " CheckedException"; + } + + try { + helloWorldService1.throwUnChecked(null); + } catch (Exception e) { + stringValue += " UncheckedException"; + } return stringValue; } } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java index 82c57dfe75..5ae7032993 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java @@ -18,7 +18,6 @@ */ package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld; -import org.osoa.sca.annotations.OneWay; import org.osoa.sca.annotations.Remotable; /** @@ -29,5 +28,8 @@ public interface HelloWorldService { public byte[] getByteArrayGreetings(byte[] msg); + public void throwChecked(byte[] msg) throws CheckedException; + public void throwUnChecked(byte[] msg); + } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java index f0b7819c3b..803be4cbe6 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java @@ -18,6 +18,7 @@ */ package org.apache.tuscany.sca.binding.jms.format.jmsbytes.helloworld; + public class HelloWorldServiceImpl implements HelloWorldService { public byte[] getByteArrayGreetings(byte[] msg){ @@ -28,6 +29,12 @@ public class HelloWorldServiceImpl implements HelloWorldService { return name.getBytes(); } + public void throwChecked(byte[] msg) throws CheckedException { + throw new CheckedException("foo"); + } + public void throwUnChecked(byte[] msg) { + throw new RuntimeException("bla"); + } } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java new file mode 100644 index 0000000000..5fad413ebe --- /dev/null +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java @@ -0,0 +1,35 @@ +/* + * 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.format.jmsbytes.helloworld; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +public interface HelloWorldServiceReference { + + public byte[] getByteArrayGreetings(byte[] msg); + + public void throwChecked(byte[] msg) ; + public void throwUnChecked(byte[] msg); + +} + diff --git a/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java b/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java index a242206080..8b03049f5a 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java +++ b/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java @@ -51,7 +51,7 @@ public class FormatJMSBytesTestCase { HelloWorldReference helloWorldService = ((SCAClient)node).getService(HelloWorldReference.class, "HelloWorldReferenceComponent"); System.out.println(helloWorldService.getGreetings("Fred Bloggs")); - assertEquals("Hello Fred Bloggs", helloWorldService.getGreetings("Fred Bloggs")); + assertEquals("Hello Fred Bloggs CheckedException UncheckedException", helloWorldService.getGreetings("Fred Bloggs")); } diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java index 057b58ca11..b2f5102bb7 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java @@ -18,16 +18,20 @@ */ package org.apache.tuscany.sca.binding.jms.provider; +import java.lang.reflect.InvocationTargetException; import java.util.logging.Logger; import javax.jms.BytesMessage; import javax.jms.JMSException; import javax.jms.Message; +import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TextMessage; 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.osoa.sca.ServiceRuntimeException; /** * MessageProcessor for sending/receiving javax.jms.BytesMessage with the JMSBinding. @@ -42,6 +46,21 @@ public class BytesMessageProcessor extends AbstractMessageProcessor { } @Override + public Object extractPayloadFromJMSMessage(Message msg) { + byte [] bytes = (byte [])extractPayload(msg); + + try { + if (msg.getBooleanProperty(JMSBindingConstants.FAULT_PROPERTY)) { + return new InvocationTargetException(new ServiceRuntimeException(bytes.toString())); + } else { + return bytes; + } + } catch (JMSException e) { + throw new JMSBindingException(e); + } + } + + @Override protected Object extractPayload(Message msg) { try { @@ -58,6 +77,17 @@ public class BytesMessageProcessor extends AbstractMessageProcessor { throw new JMSBindingException(e); } } + + @Override + public Message createFaultMessage(Session session, Throwable o) { + try { + Message message = createJMSMessage(session, o.toString().getBytes()); + message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); + return message; + } catch (JMSException e) { + throw new JMSBindingException(e); + } + } @Override protected Message createJMSMessage(Session session, Object o) { |