From 4ed0ed906e82c9484b384419fa4ef4c980768731 Mon Sep 17 00:00:00 2001 From: lresende Date: Thu, 13 Nov 2008 20:02:36 +0000 Subject: Creating Java SCA 1.x branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@713805 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-1.x/samples/chat-webapp/README | 83 +++++++++ .../samples/chat-webapp/chat-webapp.png | Bin 0 -> 6552 bytes .../samples/chat-webapp/chat-webapp.svg | 187 +++++++++++++++++++++ branches/sca-java-1.x/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 branches/sca-java-1.x/samples/chat-webapp/README create mode 100644 branches/sca-java-1.x/samples/chat-webapp/chat-webapp.png create mode 100644 branches/sca-java-1.x/samples/chat-webapp/chat-webapp.svg create mode 100644 branches/sca-java-1.x/samples/chat-webapp/pom.xml create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/java/sample/ChatService.java create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/resources/chat.composite create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/chat.html (limited to 'branches/sca-java-1.x/samples/chat-webapp') diff --git a/branches/sca-java-1.x/samples/chat-webapp/README b/branches/sca-java-1.x/samples/chat-webapp/README new file mode 100644 index 0000000000..09b9c6f6be --- /dev/null +++ b/branches/sca-java-1.x/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/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.png b/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.png new file mode 100644 index 0000000000..fdf540d243 Binary files /dev/null and b/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.png differ diff --git a/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.svg b/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.svg new file mode 100644 index 0000000000..b37c1dc590 --- /dev/null +++ b/branches/sca-java-1.x/samples/chat-webapp/chat-webapp.svg @@ -0,0 +1,187 @@ + + + + + + + + + + image/svg+xml + + + + + + + + store + + + DWR + + + DWR + + Catalog + + + diff --git a/branches/sca-java-1.x/samples/chat-webapp/pom.xml b/branches/sca-java-1.x/samples/chat-webapp/pom.xml new file mode 100644 index 0000000000..50be91f202 --- /dev/null +++ b/branches/sca-java-1.x/samples/chat-webapp/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.4-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 + 1.4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 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-java-1.x/samples/chat-webapp/src/main/java/sample/ChatService.java b/branches/sca-java-1.x/samples/chat-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..ca90b8f579 --- /dev/null +++ b/branches/sca-java-1.x/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.osoa.sca.annotations.Remotable; + +@Remotable +public interface ChatService { + + public void chat(String msg); + +} diff --git a/branches/sca-java-1.x/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java b/branches/sca-java-1.x/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..7d0bfb3307 --- /dev/null +++ b/branches/sca-java-1.x/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.osoa.sca.annotations.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/branches/sca-java-1.x/samples/chat-webapp/src/main/resources/chat.composite b/branches/sca-java-1.x/samples/chat-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..c9ce95e2dc --- /dev/null +++ b/branches/sca-java-1.x/samples/chat-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..897849ff8d --- /dev/null +++ b/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..97d91fec56 --- /dev/null +++ b/branches/sca-java-1.x/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/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/chat.html b/branches/sca-java-1.x/samples/chat-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..7a449a906a --- /dev/null +++ b/branches/sca-java-1.x/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