From 9e31ffd14a9ea192f990f5ef9eced846a90c441e Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 14 Aug 2008 09:33:56 +0000 Subject: Add new sample demonstrating callbacks with implementation.web clients git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685834 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/samples/helloworld-web-callback/pom.xml | 68 ++++++++++++++++++++++ .../src/main/java/sample/HelloworldCallback.java | 30 ++++++++++ .../src/main/java/sample/HelloworldService.java | 14 +++++ .../main/java/sample/HelloworldServiceImpl.java | 27 +++++++++ .../webapp/META-INF/sca-deployables/web.composite | 45 ++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 42 +++++++++++++ .../src/main/webapp/hello.html | 63 ++++++++++++++++++++ 7 files changed, 289 insertions(+) create mode 100644 java/sca/samples/helloworld-web-callback/pom.xml create mode 100644 java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java create mode 100644 java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java create mode 100644 java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 java/sca/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite create mode 100644 java/sca/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml create mode 100644 java/sca/samples/helloworld-web-callback/src/main/webapp/hello.html (limited to 'java/sca/samples/helloworld-web-callback') diff --git a/java/sca/samples/helloworld-web-callback/pom.xml b/java/sca/samples/helloworld-web-callback/pom.xml new file mode 100644 index 0000000000..54b422d64f --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-helloworld-web-callback + war + Apache Tuscany SCA Web 2.0 Callbacks Sample + + + + + org.apache.tuscany.sca + tuscany-sca-api + 1.4-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.4-SNAPSHOT + runtime + + + + + + ${artifactId} + + + diff --git a/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.java new file mode 100644 index 0000000000..661f703dc8 --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldCallback.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 sample; + +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface HelloworldCallback { + + @OneWay + void sayHelloCallback(String reply); +} diff --git a/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..d2c1fc2def --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldService.java @@ -0,0 +1,14 @@ +package sample; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Remotable +@Callback(HelloworldCallback.class) +public interface HelloworldService { + + @OneWay + void sayHello(String name); + +} diff --git a/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..8b52e42754 --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,27 @@ +package sample; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Service; + +@Service(HelloworldService.class) +public class HelloworldServiceImpl implements HelloworldService { + + @Callback + public HelloworldCallback callback; + + public void sayHello(final String name) { + Thread t = new Thread(new Runnable() { + public void run() { + for (int i=0; i<5; i++) { + callback.sayHelloCallback(i + "Hello " + name); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }}); + t.start(); + } + +} diff --git a/java/sca/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite b/java/sca/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite new file mode 100644 index 0000000000..fdd5a95f58 --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/webapp/META-INF/sca-deployables/web.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml b/java/sca/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..f29262a147 --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + Apache Tuscany Helloworld Servlet Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.html + + + diff --git a/java/sca/samples/helloworld-web-callback/src/main/webapp/hello.html b/java/sca/samples/helloworld-web-callback/src/main/webapp/hello.html new file mode 100644 index 0000000000..6d4c17626b --- /dev/null +++ b/java/sca/samples/helloworld-web-callback/src/main/webapp/hello.html @@ -0,0 +1,63 @@ + + + + + Apache Tuscany Helloworld Web2.0 Callbacks Sample + + + + + + + +

Apache Tuscany Helloworld Web2.0 Callbacks Sample

+ + + + + + + + + + + + +
Enter your name: + +
+ +
+
+
+ + + -- cgit v1.2.3