From 8147a9a796ff3530d407c8ed4421efae5515fa71 Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 31 Jan 2009 05:27:28 +0000 Subject: Moving samples that are not part of the main build to contrib folder git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@739507 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/contrib/samples/chat-webapp/README | 83 +++++++++ .../contrib/samples/chat-webapp/chat-webapp.png | Bin 0 -> 6552 bytes .../contrib/samples/chat-webapp/chat-webapp.svg | 187 +++++++++++++++++++++ java/sca/contrib/samples/chat-webapp/pom.xml | 97 +++++++++++ .../src/main/java/sample/ChatService.java | 26 +++ .../src/main/java/sample/ChatServiceImpl.java | 36 ++++ .../chat-webapp/src/main/resources/chat.composite | 40 +++++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 +++ .../chat-webapp/src/main/webapp/WEB-INF/web.xml | 37 ++++ .../samples/chat-webapp/src/main/webapp/chat.html | 70 ++++++++ 10 files changed, 600 insertions(+) create mode 100644 java/sca/contrib/samples/chat-webapp/README create mode 100644 java/sca/contrib/samples/chat-webapp/chat-webapp.png create mode 100644 java/sca/contrib/samples/chat-webapp/chat-webapp.svg create mode 100644 java/sca/contrib/samples/chat-webapp/pom.xml create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatService.java create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/resources/chat.composite create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 java/sca/contrib/samples/chat-webapp/src/main/webapp/chat.html (limited to 'java/sca/contrib/samples/chat-webapp') diff --git a/java/sca/contrib/samples/chat-webapp/README b/java/sca/contrib/samples/chat-webapp/README new file mode 100644 index 0000000000..09b9c6f6be --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/README @@ -0,0 +1,83 @@ +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 Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd chat-webapp +ant package + +This should result in a war file (sample-chat-webapp.war) in the target +directory. Copy this war file to your web app deployment directory in you +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +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. + +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/java/sca/contrib/samples/chat-webapp/chat-webapp.png b/java/sca/contrib/samples/chat-webapp/chat-webapp.png new file mode 100644 index 0000000000..fdf540d243 Binary files /dev/null and b/java/sca/contrib/samples/chat-webapp/chat-webapp.png differ diff --git a/java/sca/contrib/samples/chat-webapp/chat-webapp.svg b/java/sca/contrib/samples/chat-webapp/chat-webapp.svg new file mode 100644 index 0000000000..b37c1dc590 --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/chat-webapp.svg @@ -0,0 +1,187 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + + + DWR + + + DWR + + Catalog + + + diff --git a/java/sca/contrib/samples/chat-webapp/pom.xml b/java/sca/contrib/samples/chat-webapp/pom.xml new file mode 100644 index 0000000000..93fa269cf4 --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../../pom.xml + + sample-chat-webapp + war + Apache Tuscany SCA Chat Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 2.0-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 2.0-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-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 + 2.0-SNAPSHOT + + + + generate + + + + + + + + diff --git a/java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatService.java b/java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..bf34675b8a --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatService.java @@ -0,0 +1,26 @@ +/** + * + * 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 org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface ChatService { + + public void chat(String msg); + +} diff --git a/java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java b/java/sca/contrib/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..f0725dd60c --- /dev/null +++ b/java/sca/contrib/samples/chat-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.oasisopen.sca.annotation.Scope; + +@Scope("COMPOSITE") +public class ChatServiceImpl implements ChatService { + + ChatService chatters; + + public void chat(String msg) { + chatters.chat(msg); + } + + public void setChatters(ChatService chatters) { + this.chatters = chatters; + } +} diff --git a/java/sca/contrib/samples/chat-webapp/src/main/resources/chat.composite b/java/sca/contrib/samples/chat-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..c9ce95e2dc --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/java/sca/contrib/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml b/java/sca/contrib/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..897849ff8d --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/java/sca/contrib/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml b/java/sca/contrib/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..97d91fec56 --- /dev/null +++ b/java/sca/contrib/samples/chat-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.html + + + diff --git a/java/sca/contrib/samples/chat-webapp/src/main/webapp/chat.html b/java/sca/contrib/samples/chat-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..7a449a906a --- /dev/null +++ b/java/sca/contrib/samples/chat-webapp/src/main/webapp/chat.html @@ -0,0 +1,70 @@ + + + + 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