From 28f92c6fc62f3bc0637ac77681aabcc8c0b5e42c Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 11 Sep 2008 04:12:24 +0000 Subject: Renaming branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@694107 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca-trunk-20080910/samples/chat2-webapp/README | 61 +++++++++++ .../samples/chat2-webapp/build.xml | 117 +++++++++++++++++++++ .../samples/chat2-webapp/pom.xml | 104 ++++++++++++++++++ .../src/main/java/sample/ChatCallback.java | 27 +++++ .../src/main/java/sample/ChatService.java | 32 ++++++ .../src/main/java/sample/ChatServiceImpl.java | 36 +++++++ .../chat2-webapp/src/main/resources/chat.composite | 40 +++++++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 +++++ .../chat2-webapp/src/main/webapp/WEB-INF/web.xml | 37 +++++++ .../samples/chat2-webapp/src/main/webapp/chat.html | 73 +++++++++++++ 10 files changed, 551 insertions(+) create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/README create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/build.xml create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/pom.xml create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/resources/chat.composite create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/chat.html (limited to 'branches/sca-trunk-20080910/samples/chat2-webapp') diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/README b/branches/sca-trunk-20080910/samples/chat2-webapp/README new file mode 100644 index 0000000000..0186006211 --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/README @@ -0,0 +1,61 @@ +Chat WebApp Sample +================== +This sample demonstrates the SCA DWR binding to implement the classic Ajax sample +of a chat application which allows multiple users to chat from their browsers. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-chat-webapp.war) +to your web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-chat-webapp + +The port and hostname will of course vary depending on your local installation. + +Sample Overview +--------------- +The sample provides an SCA component which has an SCA service using the SCA DWR +binding and an SCA reference also using the DWR binding. The component implementation +simply forwards every invocation of the service as an invocation on the reference. The +component reference is scoped by the composite so every active client of the composite +will receive every message sent to the component service, thus implementing the chat +application with very little code. + +chat-webapp/ + src/ + main/ + java/ + sample/ + ChatService.java - service interface + ChatServiceImpl.java - service implementation + resources/ + chat.composite - the SCA assembly for this sample + webapp + chat.html - the html UserInterface for this application + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + + pom.xml - the Maven build file + +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. + +cd chat-webapp +mvn + +Again this should result in a war file (sample-chat-webapp.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/build.xml b/branches/sca-trunk-20080910/samples/chat2-webapp/build.xml new file mode 100644 index 0000000000..2d3fc0c5f3 --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/build.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/pom.xml b/branches/sca-trunk-20080910/samples/chat2-webapp/pom.xml new file mode 100644 index 0000000000..c9def0ae48 --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/pom.xml @@ -0,0 +1,104 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-SNAPSHOT + ../../pom.xml + + sample-chat2-webapp + war + Apache Tuscany SCA Chat Sample WebApp using callbacks + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-web + 1.4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.4-SNAPSHOT + runtime + + + + + stax + stax-api + 1.0.1 + provided + + + + + javax.servlet + servlet-api + 2.3 + provided + + + + + + ${artifactId} + + + org.apache.tuscany.sca + tuscany-maven-ant-generator + 1.4-SNAPSHOT + + + + generate + + + + + + + + diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java new file mode 100644 index 0000000000..7d668052b2 --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatCallback.java @@ -0,0 +1,27 @@ +/* + * 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.Remotable; + +@Remotable +public interface ChatCallback { + void newMsg(String msg); +} diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..cc9d00ca4a --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatService.java @@ -0,0 +1,32 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed 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 javax.jws.Oneway; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Scope; + +@Remotable +@Scope("COMPOSITE") +@Callback(ChatCallback.class) +public interface ChatService { + + @Oneway + public void addMsg(String msg); +} diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..d714ff82ed --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.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 sample; + +import org.osoa.sca.annotations.Callback; + +public class ChatServiceImpl implements ChatService { + + ChatCallback chatCallback; + + @Callback + public void setCallback(ChatCallback chatCallback) { + this.chatCallback = chatCallback; + } + + public void addMsg(String msg) { + chatCallback.newMsg(msg); + } +} diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/resources/chat.composite b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..93a10d0fdf --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..897849ff8d --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..6919372e87 --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + + + Apache Tuscany AJAX/DWR Chat Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + chat.jsp + + + diff --git a/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/chat.html b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..a063e27f8e --- /dev/null +++ b/branches/sca-trunk-20080910/samples/chat2-webapp/src/main/webapp/chat.html @@ -0,0 +1,73 @@ + + + + Apache Tuscany Ajax/DWR Chat Sample + + + + + + +

Apache Tuscany Ajax/DWR Chat Sample

+ + A simple client to chat between multiple web browsers:

+ + Nickname: +

+ + Enter text: + + +

+
+ + + -- cgit v1.2.3