From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/dbecho/ComponentAImpl.java | 85 ++++++++++++++++++++++ .../src/main/java/dbecho/ComponentBImpl.java | 59 +++++++++++++++ .../src/main/java/dbecho/Echo.java | 32 ++++++++ .../main/java/dbecho/EchoDataBindingClient.java | 45 ++++++++++++ .../src/main/java/dbecho/Interface1.java | 32 ++++++++ .../src/main/java/dbecho/Interface2.java | 36 +++++++++ .../src/main/resources/EchoDataBinding.composite | 54 ++++++++++++++ .../org.apache.tuscany.sca.core.ModuleActivator | 18 +++++ .../src/main/resources/wsdl/echo.wsdl | 63 ++++++++++++++++ .../test/java/dbecho/EchoDataBindingTestCase.java | 49 +++++++++++++ 10 files changed, 473 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface1.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface2.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/EchoDataBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java (limited to 'sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src') diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java new file mode 100644 index 0000000000..a0b39ad460 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java @@ -0,0 +1,85 @@ +/* + * 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 dbecho; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +@SuppressWarnings("unused") +public class ComponentAImpl implements Interface1 { + + private Interface1 componentBReference; + + @SuppressWarnings("unused") + private String prefix; + + private String prefix1; + + private String bar; + + @Constructor + public ComponentAImpl(@Reference(name = "componentBReference", required = true) + Interface1 componentBReference) { + this.componentBReference = componentBReference; + } + + public String call(String msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return (String) ret; + } + + public String call1(String msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call1(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return (String) ret; + } + + @Property(name="prefix") + public void setPrefix(String prefix) { + System.out.println("[Property] prefix: " + prefix); + this.prefix = prefix; + } + + @Property(name="prefix1") + public void setPrefix1(String prefix1) { + System.out.println("[Property] prefix1: " + prefix1); + this.prefix1 = prefix1; + } + + /** + * @param bar the bar to set + */ + @Property(name="bar") + public void setBar(String bar) { + System.out.println("[Property] bar: " + bar); + this.bar = bar; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java new file mode 100644 index 0000000000..ff8968837d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java @@ -0,0 +1,59 @@ +/* + * 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 dbecho; + +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@AllowsPassByReference +public class ComponentBImpl implements Interface2 { + + private Echo echoReference; + + @Constructor + public ComponentBImpl(@Reference(name = "echoReference", required = true) + Echo echoReference) { + this.echoReference = echoReference; + } + + public Node call(Node msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); + Node ret = (Node) echoReference.echo(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentB --> Returned message: " + response); + return ret; + } + + public XMLStreamReader call1(XMLStreamReader msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); +// XMLStreamReader ret = (XMLStreamReader) echoReference.echo(msg); + String response = request; + System.out.println("ComponentB --> Returned message: " + response); + return msg; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Echo.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Echo.java new file mode 100644 index 0000000000..25ecc90454 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Echo.java @@ -0,0 +1,32 @@ +/* + * 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 dbecho; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Echo { + Object echo(Object msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java new file mode 100644 index 0000000000..9ec3819899 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java @@ -0,0 +1,45 @@ +/* + * 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 dbecho; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + * @version $Rev$ $Date$ + */ +public class EchoDataBindingClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("EchoDataBinding.composite"); + + Interface1 componentA = scaDomain.getService(Interface1.class, "ComponentA"); + String response = componentA.call("123"); + String response1= componentA.call1("123"); + + + System.out.println("call response = " + response ); + System.out.println("call1 response = " + response1 ); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface1.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface1.java new file mode 100644 index 0000000000..70b450e358 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface1.java @@ -0,0 +1,32 @@ +/* + * 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 dbecho; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("java.lang.String") +@Remotable +public interface Interface1 { + String call(String msg); + String call1(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface2.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface2.java new file mode 100644 index 0000000000..b62f1f425d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/java/dbecho/Interface2.java @@ -0,0 +1,36 @@ +/* + * 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 dbecho; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Interface2 { + Node call(Node msg); + @DataBinding("javax.xml.stream.XMLStreamReader") + XMLStreamReader call1(XMLStreamReader msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/EchoDataBinding.composite b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/EchoDataBinding.composite new file mode 100644 index 0000000000..931d5c756c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/EchoDataBinding.composite @@ -0,0 +1,54 @@ + + + + + + + + ABC + + + + + + + + + + + + + + + + + ABC + + + BAR + + + + diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator new file mode 100644 index 0000000000..13d0d6f570 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator @@ -0,0 +1,18 @@ +# 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. +# Implementation class for the ExtensionActivator +echo.module.EchoModuleActivator diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl new file mode 100644 index 0000000000..ef2308aa73 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java new file mode 100644 index 0000000000..43434d8cee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java @@ -0,0 +1,49 @@ +/* + * 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 dbecho; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class EchoDataBindingTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoDataBinding.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + protected Interface1 componentA; + + public void testTransform() { + componentA = scaDomain.getService(Interface1.class, "ComponentA"); + componentA.call("123"); + componentA.call1("123"); + } +} -- cgit v1.2.3