From 34766b4b32027392eb927557cdb6230061803e7c Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 30 Apr 2009 12:29:50 +0000 Subject: TUSCANY-2996 - Add support for wrapSingle attribute that, when set true, ensures that single parameters are wrapped in an array on the wire. When set false single parameters will not be wrapped on the wire. Multiple parameters will always be wrapped. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@770201 13f79535-47bb-0310-9956-ffa450edef68 --- .../jmsobject/helloworld/HelloWorldReference.java | 4 +- .../helloworld/HelloWorldReferenceImpl.java | 69 +++++++++++++++++++--- .../jmsobject/helloworld/HelloWorldService.java | 11 +++- .../helloworld/HelloWorldServiceImpl.java | 28 +++++++-- .../main/resources/jmsobject/helloworld.composite | 24 ++++++-- .../jms/format/FormatJMSObjectTestCase.java | 7 ++- 6 files changed, 121 insertions(+), 22 deletions(-) (limited to 'branches/sca-java-1.x/itest') diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java index 89bae83c77..e89598cb96 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java @@ -26,7 +26,7 @@ import org.osoa.sca.annotations.Remotable; @Remotable public interface HelloWorldReference { - public String getGreetings(String firstName, String lastName); - + public String getGreetingsWrapSingle(String firstName, String lastName); + public String getGreetingsDontWrapSingle(String firstName, String lastName); } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java index e0611f3ddc..d0e10c97e3 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java @@ -24,22 +24,77 @@ import org.osoa.sca.annotations.Reference; public class HelloWorldReferenceImpl implements HelloWorldReference { @Reference - protected HelloWorldService helloWorldService; + protected HelloWorldService helloWorldServiceWrapSingle; - public String getGreetings(String firstName, String lastName){ + @Reference + protected HelloWorldService helloWorldServiceDontWrapSingle; + + public String getGreetingsWrapSingle(String firstName, String lastName){ Person person = new Person(); person.setFirstName(firstName); person.setLastName(lastName); - Person returnPerson = helloWorldService.getGreetings(person); - Person returnNullPerson = helloWorldService.getNullGreetings(person); + + String returnString = ""; + + Person returnPerson = helloWorldServiceWrapSingle.getPersonGreetings(person); + returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName(); - String returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName(); + Person returnNullPerson = helloWorldServiceWrapSingle.getNullReturnGreetings(person); if (returnNullPerson == null){ - returnString += " null"; + returnString += " Hello2 null"; } + String returnGreeting = helloWorldServiceWrapSingle.getArrayGreeting(new String[]{firstName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getMultiGreetings(firstName, lastName); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getObjectGreeting(person); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceWrapSingle.getObjectArrayGreeting(new Object[]{person}); + returnString += " " + returnGreeting; + + return returnString; + } + + public String getGreetingsDontWrapSingle(String firstName, String lastName){ + Person person = new Person(); + person.setFirstName(firstName); + person.setLastName(lastName); + + String returnString = ""; + + Person returnPerson = helloWorldServiceDontWrapSingle.getPersonGreetings(person); + returnString = returnPerson.getFirstName() + " " + returnPerson.getLastName(); + + Person returnNullPerson = helloWorldServiceDontWrapSingle.getNullReturnGreetings(person); + + if (returnNullPerson == null){ + returnString += " Hello2 null"; + } + + String returnGreeting = helloWorldServiceDontWrapSingle.getArrayGreeting(new String[]{firstName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getMultiArrayGreetings(new String[]{firstName, firstName},new String[]{lastName, lastName}); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getMultiGreetings(firstName, lastName); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getObjectGreeting(person); + returnString += " " + returnGreeting; + + returnGreeting = helloWorldServiceDontWrapSingle.getObjectArrayGreeting(new Object[]{person}); + returnString += " " + returnGreeting; + return returnString; - } + } } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java index fdbc894d3c..43a4f9d4bd 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java @@ -26,8 +26,13 @@ import org.osoa.sca.annotations.Remotable; @Remotable public interface HelloWorldService { - public Person getGreetings(Person person); - public Person getNullGreetings(Person person); - + public Person getPersonGreetings(Person person); + public Person getNullReturnGreetings(Person person); + public String getArrayGreeting(String[] names); + public String getMultiArrayGreetings(String[] firstName, String[] lastName); + public String getMultiGreetings(String firstName, String lastName); + public String getObjectGreeting(Object person); + public String getObjectArrayGreeting(Object[] pearson); + } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java index 73f415cc3f..1c8a27d772 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java +++ b/branches/sca-java-1.x/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java @@ -21,16 +21,36 @@ package org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld; public class HelloWorldServiceImpl implements HelloWorldService { - public Person getGreetings(Person person){ + public Person getPersonGreetings(Person person){ - person.setFirstName("Hello " + person.getFirstName()); - person.setLastName("Hello " + person.getLastName()); + person.setFirstName("Hello1 " + person.getFirstName()); + person.setLastName("Hello1 " + person.getLastName()); return person; } - public Person getNullGreetings(Person person){ + public Person getNullReturnGreetings(Person person){ return null; } + + public String getArrayGreeting(String[] names) { + return "Hello3 " + names[0]; + } + + public String getMultiArrayGreetings(String[] firstName, String[] lastName) { + return "Hello4 " + firstName[0] + " " + lastName[0]; + } + + public String getMultiGreetings(String firstName, String lastName) { + return "Hello5 " + firstName + " " + lastName; + } + + public String getObjectGreeting(Object person) { + return "Hello6 " + ((Person)person).getFirstName() + " " + ((Person)person).getLastName(); + } + + public String getObjectArrayGreeting(Object[] person) { + return "Hello7 " + ((Person)person[0]).getFirstName() + " " + ((Person)person[0]).getLastName(); + } } diff --git a/branches/sca-java-1.x/itest/jms-format/src/main/resources/jmsobject/helloworld.composite b/branches/sca-java-1.x/itest/jms-format/src/main/resources/jmsobject/helloworld.composite index 1fc5c095f7..81be76510c 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/main/resources/jmsobject/helloworld.composite +++ b/branches/sca-java-1.x/itest/jms-format/src/main/resources/jmsobject/helloworld.composite @@ -25,12 +25,18 @@ - + - + - + + + + + + + @@ -38,8 +44,18 @@ - + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java index aa34a53d01..7c535773b7 100644 --- a/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java +++ b/branches/sca-java-1.x/itest/jms-format/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java @@ -52,8 +52,11 @@ public class FormatJMSObjectTestCase { HelloWorldReference helloWorldService = ((SCAClient) node).getService( HelloWorldReference.class, "HelloWorldReferenceComponent"); - assertEquals("Hello Fred Hello Bloggs null", - helloWorldService.getGreetings("Fred", "Bloggs")); + assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs", + helloWorldService.getGreetingsWrapSingle("Fred", "Bloggs")); + + assertEquals("Hello1 Fred Hello1 Bloggs Hello2 null Hello3 Fred Hello4 Fred Bloggs Hello5 Fred Bloggs Hello6 Fred Bloggs Hello7 Fred Bloggs", + helloWorldService.getGreetingsDontWrapSingle("Fred", "Bloggs")); } -- cgit v1.2.3