From f0797f0026f729fa612930fbd0acefc5343a0fe6 Mon Sep 17 00:00:00 2001 From: nash Date: Mon, 22 Nov 2010 09:49:22 +0000 Subject: Copy 1.6.1-RC2 tag as 1.6.1 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1037648 13f79535-47bb-0310-9956-ffa450edef68 --- .../tags/1.6.1/samples/callback-ws-client/README | 311 +++++++++++++++++++++ .../1.6.1/samples/callback-ws-client/build.xml | 71 +++++ .../callback-ws-client/callback-ws-client.png | Bin 0 -> 8812 bytes .../callback-ws-client/callback-ws-client.svg | 204 ++++++++++++++ .../tags/1.6.1/samples/callback-ws-client/pom.xml | 86 ++++++ .../src/main/java/myapp/MyClient.java | 29 ++ .../src/main/java/myapp/MyClientImpl.java | 64 +++++ .../src/main/java/myserver/MyService.java | 34 +++ .../src/main/java/myserver/MyServiceCallback.java | 30 ++ .../main/resources/META-INF/sca-contribution.xml | 22 ++ .../src/main/resources/myapp.composite | 36 +++ .../test/java/myapp/CallbackClientTestCase.java | 53 ++++ 12 files changed, 940 insertions(+) create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/README create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/build.xml create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.png create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.svg create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/pom.xml create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClient.java create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyService.java create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/myapp.composite create mode 100644 sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java (limited to 'sca-java-1.x/tags/1.6.1/samples/callback-ws-client') diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/README b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/README new file mode 100644 index 0000000000..66121362c9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/README @@ -0,0 +1,311 @@ +Callback Web Services Client Sample +=================================== +This sample demonstrates an SCA client that sends service requests to a +remote server and receives asynchronous callbacks from the server, using +Web service bindings for the service and the callback. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look +there first. + +If you just want to run it to see what happens, you need to start the +server first, so open a command prompt and navigate to the +callback-ws-service sample directory and do: + +ant run + +OR if you don't have ant, on Windows do: + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-callback-ws-service.jar myserver.CallbackServer + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-service.jar myserver.CallbackServer + +Once the server is running open a command prompt, navigate to this sample +directory and do: + +ant run + +OR if you don't have ant, on Windows do: + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-callback-ws-client.jar myapp.MyClientImpl + +and on *nix do: + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-callback-ws-client.jar myapp.MyClientImpl + + +Sample Overview +--------------- +The sample has a single component that has a reference with a service +interface and a callback interface, with Web service bindings for both +these interfaces. The service interface binding URI identifies the +service exposed by the callback-ws-service sample. + +callback-ws-client/ + src/ + main/ + java/ + myapp/ + MyClient.java - interface description for + MyClientComponent + MyClientImpl.java - component implementation + myserver/ + MyService.java - interface description for + MyServiceComponent + MyServiceCallback.java - interface description for callback + resources/ + myapp.composite - the SCA assembly for this sample + test/ + java/ + myapp/ + CallbackClientTestCase.java - JUnit test case + callback-ws-client.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant. +Before you do this, run the callback-ws-service sample to start up the +service that the client will talk to. Take a look at the README in +that sample and you will see you need the following commands: + +cd callback-ws-service +ant run + +You can then compile and run this sample using the following commands: + +cd callback-ws-client +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 15-Jan-2008 10:21:38 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl init + [java] INFO: Domain will be started stand-alone as domain URL is not provid +ed + [java] 15-Jan-2008 10:21:39 org.apache.tuscany.sca.domain.impl.SCADomainImp +l registerNode + [java] INFO: Registered node: http://L3AW203:1336 at endpoint http://L3AW20 +3:1336 + [java] 15-Jan-2008 10:21:39 org.apache.tuscany.sca.node.impl.SCADomainProxy +Impl createRuntime + [java] INFO: Domain management configured from file:/C:/simon/tuscany/relea +se/sca-r1.1-rc2/tuscany-sca-1.1-incubating-SNAPSHOT/lib/tuscany-sca-all-1.1-incu +bating-SNAPSHOT.jar + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomainEventServi +ceProxyComponent + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomainAPIService +ProxyComponent + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/SCANodeManagerService + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/ComponentManagerService/* + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCANodeManagerCompo +nent/ComponentManagerService + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/SCADomain/scaDomain +.js + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.node.impl.SCANodeImpl ac +tivateComposite + [java] INFO: Building composite: {http://myapp}myapp + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.node.impl.SCANodeImpl st +artComposite + [java] INFO: Starting composite: {http://myapp}myapp + [java] 15-Jan-2008 10:21:48 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:1336/MyClientComponent/m +yService + [java] aClientMethod on thread Thread[main,5,main] + [java] aClientMethod return from someMethod on thread Thread[main,5,main] + [java] receiveResult on thread Thread[pool-1-thread-2,5,main] + [java] Result: -> someMethod -> receiveResult + [java] Closing the domain + [java] 15-Jan-2008 10:21:54 org.apache.tuscany.sca.node.impl.SCANodeImpl st +opComposite + [java] INFO: Stopping composite: {http://myapp}myapp + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and +run using Maven as follows. When using Maven you don't need to run the +callback-ws-service sample first as Maven does this for you. With Maven, +both client and server code run in the same JVM, which rather defeats the +purpose of this sample (to show a standalone SCA client), but it's good +enough for a unit test. + +cd callback-ws-client +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running myapp.CallbackClientTestCase +15-Jan-2008 10:17:46 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:17:46 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1322 at endpoint http://L3AW203:1322 +15-Jan-2008 10:17:46 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:17:52 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:53 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +15-Jan-2008 10:17:53 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +15-Jan-2008 10:17:53 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1322 +15-Jan-2008 10:17:53 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1322 +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:17:53 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1322/SCADomain/scaDomain.js +15-Jan-2008 10:17:53 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://callbackws}callbackws +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://callbackws}callbackws +15-Jan-2008 10:17:54 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:54 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:54 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:17:54 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:17:54 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:8086/MyServiceComponent +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl init +INFO: Domain will be started stand-alone as domain URL is not provided +15-Jan-2008 10:17:54 org.apache.tuscany.sca.domain.impl.SCADomainImpl registerNo +de +INFO: Registered node: http://L3AW203:1323 at endpoint http://L3AW203:1323 +15-Jan-2008 10:17:54 org.apache.tuscany.sca.node.impl.SCADomainProxyImpl createR +untime +INFO: Domain management configured from file:/C:/Documents%20and%20Settings/slaw +s/.m2/repository/org/apache/tuscany/sca/tuscany-node-impl/1.1-incubating-SNAPSHO +T/tuscany-node-impl-1.1-incubating-SNAPSHOT.jar +15-Jan-2008 10:17:56 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +15-Jan-2008 10:17:56 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +15-Jan-2008 10:17:56 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:17:56 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomainEventServiceProxyCompo +nent +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomainAPIServiceProxyCompone +nt +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/SCANode +ManagerService +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/Compone +ntManagerService/* +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCANodeManagerComponent/Compone +ntManagerService +15-Jan-2008 10:17:56 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/SCADomain/scaDomain.js +15-Jan-2008 10:17:56 org.apache.tuscany.sca.node.impl.SCANodeImpl activateCompos +ite +INFO: Building composite: {http://myapp}myapp +15-Jan-2008 10:17:57 org.apache.tuscany.sca.node.impl.SCANodeImpl startComposite + +INFO: Starting composite: {http://myapp}myapp +15-Jan-2008 10:17:57 org.apache.tuscany.sca.http.tomcat.TomcatServer addServletM +apping +INFO: Added Servlet mapping: http://L3AW203:1323/MyClientComponent/myService +aClientMethod on thread Thread[main,5,main] +aClientMethod return from someMethod on thread Thread[main,5,main] +setMyServiceCallback on thread Thread[pool-1-thread-1,5,main] +someMethod on thread Thread[pool-1-thread-1,5,main] +Sleeping ... +receiveResult on thread Thread[pool-2-thread-1,5,main] +Result: -> someMethod -> receiveResult +Closing the domain +15-Jan-2008 10:18:02 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://myapp}myapp +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1323 +15-Jan-2008 10:18:03 org.apache.tuscany.sca.node.impl.SCANodeImpl stopComposite +INFO: Stopping composite: {http://callbackws}callbackws +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8086 +15-Jan-2008 10:18:03 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-1322 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.343 sec + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/build.xml b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/build.xml new file mode 100644 index 0000000000..0fada69531 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.png b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.png new file mode 100644 index 0000000000..802ef604a7 Binary files /dev/null and b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.png differ diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.svg b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.svg new file mode 100644 index 0000000000..f49aeadbbf --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/callback-ws-client.svg @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + myapp + + MyClientComponent + + http://localhost:8086/MyServiceComponent + + myservice callback + + diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/pom.xml b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/pom.xml new file mode 100644 index 0000000000..5f5bf763af --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6.1 + ../../pom.xml + + sample-callback-ws-client + Apache Tuscany SCA Sample Callback Web Service Remote Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 1.6.1 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6.1 + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6.1 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6.1 + runtime + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + sample-callback-ws-service + 1.6.1 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClient.java b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClient.java new file mode 100644 index 0000000000..e515b55788 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClient.java @@ -0,0 +1,29 @@ +/* + * 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 myapp; + +import org.osoa.sca.annotations.OneWay; + +/** + * The client interface + */ +public interface MyClient { + + void aClientMethod(); +} diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java new file mode 100644 index 0000000000..ece769236c --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myapp/MyClientImpl.java @@ -0,0 +1,64 @@ +/* + * 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 myapp; + +import myserver.MyService; +import myserver.MyServiceCallback; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Remote Web service client with callback interface + */ +@Service(MyClient.class) +@Scope("COMPOSITE") +public class MyClientImpl implements MyClient, MyServiceCallback { + @Reference + protected MyService myService; + + public void aClientMethod() { + System.out.println("aClientMethod on thread " + Thread.currentThread()); + myService.someMethod(" -> someMethod "); // calls the server + System.out.println("aClientMethod return from someMethod on thread " + Thread.currentThread()); + } + + public void receiveResult(String result) { + System.out.println("receiveResult on thread " + Thread.currentThread()); + System.out.println("Result: " + result); // callback from the server + } + + public static void main(String[] args) throws Exception { + SCANode node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("myapp.composite", MyClientImpl.class.getClassLoader()); + node.start(); + run(node); + System.out.println("Closing the domain"); + node.stop(); + } + + public static void run(SCANode node) throws InterruptedException { + MyClient myClient = ((SCAClient)node).getService(MyClient.class, "MyClientComponent"); + myClient.aClientMethod(); + Thread.sleep(5000); // don't exit before callback arrives + } +} diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyService.java b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyService.java new file mode 100644 index 0000000000..1850eae1bc --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyService.java @@ -0,0 +1,34 @@ +/* + * 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 myserver; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * The remote service that will be invoked by the client + */ +@Remotable +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java new file mode 100644 index 0000000000..bf5f87a4f9 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/java/myserver/MyServiceCallback.java @@ -0,0 +1,30 @@ +/* + * 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 myserver; + +import org.osoa.sca.annotations.Remotable; + +/** + * The callback interface for {@link MyService}. + */ +@Remotable +public interface MyServiceCallback { + + void receiveResult(String result); +} diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..314747d548 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/myapp.composite b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/myapp.composite new file mode 100644 index 0000000000..5b776d6df8 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/main/resources/myapp.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java new file mode 100644 index 0000000000..fb2f6952c4 --- /dev/null +++ b/sca-java-1.x/tags/1.6.1/samples/callback-ws-client/src/test/java/myapp/CallbackClientTestCase.java @@ -0,0 +1,53 @@ +/* + * 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 myapp; + +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the callback server is available + */ +public class CallbackClientTestCase { + + private SCANode node; + + @Before + public void startServer() throws Exception { + try { + node = SCANodeFactory.newInstance().createSCANodeFromClassLoader(null, getClass().getClassLoader()); + node.start(); + } catch (Exception ex) { + System.out.println(ex.toString()); + } + } + + @Test + public void testClient() throws Exception { + MyClientImpl.run(node); + } + + @After + public void stopServer() throws Exception { + node.stop(); + } +} -- cgit v1.2.3