diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-16 08:53:06 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-16 08:53:06 +0000 |
commit | bee80d90df6104edff19cbb6a318fac3d64296aa (patch) | |
tree | 50032a7895eeeccb50520bcceb6dfb1fd06f2357 /branches/sca-java-1.5/samples/chat2-webapp | |
parent | 3d3b8834b93b98cc7d7534e693e937179067eb58 (diff) |
Create 1.5 release branch from current 1.x trunk
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775437 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
10 files changed, 551 insertions, 0 deletions
diff --git a/branches/sca-java-1.5/samples/chat2-webapp/README b/branches/sca-java-1.5/samples/chat2-webapp/README new file mode 100644 index 0000000000..0186006211 --- /dev/null +++ b/branches/sca-java-1.5/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-java-1.5/samples/chat2-webapp/build.xml b/branches/sca-java-1.5/samples/chat2-webapp/build.xml new file mode 100644 index 0000000000..448fa93909 --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/build.xml @@ -0,0 +1,117 @@ +<!-- + * 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. +--> + +<project name="sample-chat2-webapp" default="compile"> + + <target name="compile"> + <mkdir dir="target/classes"/> + <javac destdir="target/classes" debug="on" source="1.5" target="1.5"> + <src path="src\main\java"/> + <classpath> + <fileset refid="tuscany.jars"/> + <fileset refid="3rdparty.jars"/> + </classpath> + </javac> + <copy todir="target/classes"> + <fileset dir="src\main\resources"/> + <fileset dir="." includes="*" excludes="src, target, pom.xml, build.xml"/> + </copy> + <war destfile="target/sample-chat2-webapp.war" webxml="src/main/webapp/WEB-INF/web.xml"> + <fileset dir="src/main/webapp"/> + <lib refid="tuscany.jars"/> + <lib refid="3rdparty.jars"/> + <classes dir="target/classes"/> + </war> + </target> + + <target name="package" depends="compile"/> + + <target name="clean"> + <delete includeemptydirs="true"> + <fileset dir="target"/> + </delete> + </target> + + <fileset id="tuscany.jars" dir="../../modules"> + <include name="tuscany-assembly-1.5-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-assembly-xsd-1.5-SNAPSHOT.jar"/> + <include name="tuscany-binding-dwr-1.5-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-1.5-SNAPSHOT.jar"/> + <include name="tuscany-binding-sca-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-impl-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-java-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-namespace-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-resource-1.5-SNAPSHOT.jar"/> + <include name="tuscany-contribution-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-core-1.5-SNAPSHOT.jar"/> + <include name="tuscany-core-databinding-1.5-SNAPSHOT.jar"/> + <include name="tuscany-core-spi-1.5-SNAPSHOT.jar"/> + <include name="tuscany-databinding-1.5-SNAPSHOT.jar"/> + <include name="tuscany-databinding-jaxb-1.5-SNAPSHOT.jar"/> + <include name="tuscany-definitions-1.5-SNAPSHOT.jar"/> + <include name="tuscany-definitions-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-domain-1.5-SNAPSHOT.jar"/> + <include name="tuscany-domain-api-1.5-SNAPSHOT.jar"/> + <include name="tuscany-extensibility-1.5-SNAPSHOT.jar"/> + <include name="tuscany-extension-helper-1.5-SNAPSHOT.jar"/> + <include name="tuscany-host-embedded-1.5-SNAPSHOT.jar"/> + <include name="tuscany-host-http-1.5-SNAPSHOT.jar"/> + <include name="tuscany-host-webapp-1.5-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-1.5-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-runtime-1.5-SNAPSHOT.jar"/> + <include name="tuscany-implementation-java-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-implementation-web-1.5-SNAPSHOT.jar"/> + <include name="tuscany-interface-1.5-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-1.5-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-jaxws-1.5-SNAPSHOT.jar"/> + <include name="tuscany-interface-java-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-node-1.5-SNAPSHOT.jar"/> + <include name="tuscany-node-api-1.5-SNAPSHOT.jar"/> + <include name="tuscany-policy-1.5-SNAPSHOT.jar"/> + <include name="tuscany-policy-xml-1.5-SNAPSHOT.jar"/> + <include name="tuscany-sca-api-1.5-SNAPSHOT.jar"/> + </fileset> + <fileset id="3rdparty.jars" dir="../../lib"> + <include name="activation-1.1.jar"/> + <include name="axiom-api-1.2.5.jar"/> + <include name="axiom-impl-1.2.5.jar"/> + <include name="cglib-nodep-2.1_3.jar"/> + <include name="commons-logging-1.1.jar"/> + <include name="dwr-2.0.1.jar"/> + <include name="geronimo-commonj_1.1_spec-1.0.jar"/> + <include name="jaxb-api-2.1.jar"/> + <include name="jaxb-impl-2.1.6.jar"/> + <include name="jaxb2-reflection-2.1.4.jar"/> + <include name="jaxen-1.1-beta-9.jar"/> + <include name="jaxws-api-2.1.jar"/> + <include name="jsr181-api-1.0-MR1.jar"/> + <include name="jsr250-api-1.0.jar"/> + <include name="mail-1.4.jar"/> + <include name="neethi-2.0.2.jar"/> + <include name="saaj-api-1.3.jar"/> + <include name="stax-api-1.0-2.jar"/> + <include name="wstx-asl-3.2.1.jar"/> + <include name="xalan-2.7.0.jar"/> + <include name="xercesImpl-2.8.1.jar"/> + <include name="xml-apis-1.3.03.jar"/> + </fileset> + +</project> diff --git a/branches/sca-java-1.5/samples/chat2-webapp/pom.xml b/branches/sca-java-1.5/samples/chat2-webapp/pom.xml new file mode 100644 index 0000000000..9376a9694d --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/pom.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-sca</artifactId> + <version>1.5-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>sample-chat2-webapp</artifactId> + <packaging>war</packaging> + <name>Apache Tuscany SCA Chat Sample WebApp using callbacks</name> + + <repositories> + <repository> + <id>apache.incubator</id> + <url>http://people.apache.org/repo/m2-incubating-repository</url> + </repository> + </repositories> + + <dependencies> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-host-webapp</artifactId> + <version>1.5-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-binding-dwr</artifactId> + <version>1.5-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-web</artifactId> + <version>1.5-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-implementation-java-runtime</artifactId> + <version>1.5-SNAPSHOT</version> + <scope>runtime</scope> + </dependency> + + <!-- exclude stax 1.0.1 as we're also pulling in javax\xml\stream\stax-api\1.0-2 --> + <dependency> + <groupId>stax</groupId> + <artifactId>stax-api</artifactId> + <version>1.0.1</version> + <scope>provided</scope> + </dependency> + + <!-- marking dependency as provided to exclude from war file --> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.3</version> + <scope>provided</scope> + </dependency> + + </dependencies> + + <build> + <finalName>${artifactId}</finalName> + <plugins> + <plugin> + <groupId>org.apache.tuscany.sca</groupId> + <artifactId>tuscany-maven-ant-generator</artifactId> + <version>1.5-SNAPSHOT</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/branches/sca-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatCallback.java b/branches/sca-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatCallback.java new file mode 100644 index 0000000000..7d668052b2 --- /dev/null +++ b/branches/sca-java-1.5/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-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatService.java b/branches/sca-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..cc9d00ca4a --- /dev/null +++ b/branches/sca-java-1.5/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-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java b/branches/sca-java-1.5/samples/chat2-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..d714ff82ed --- /dev/null +++ b/branches/sca-java-1.5/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-java-1.5/samples/chat2-webapp/src/main/resources/chat.composite b/branches/sca-java-1.5/samples/chat2-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..93a10d0fdf --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Chat">
+
+ <component name="webapp">
+ <t:implementation.web war="." />
+ <reference name="ChatService" target="ChatService">
+ <t:binding.dwr/>
+ </reference>
+ </component>
+
+ <component name="ChatService">
+ <implementation.java class="sample.ChatServiceImpl"/>
+ <service name="ChatService">
+ <t:binding.dwr/>
+ </service>
+ </component>
+
+</composite>
diff --git a/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..897849ff8d --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://sample" + xmlns:sample="http://sample"> + <deployable composite="sample:Chat"/> +</contribution>
\ No newline at end of file diff --git a/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..6919372e87 --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + Copyright (c) 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. + --> + +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web +Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> +<web-app> + <display-name>Apache Tuscany AJAX/DWR Chat Sample</display-name> + + <filter> + <filter-name>tuscany</filter-name> + <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class> + </filter> + + <filter-mapping> + <filter-name>tuscany</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <welcome-file-list> + <welcome-file>chat.jsp</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/chat.html b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..a063e27f8e --- /dev/null +++ b/branches/sca-java-1.5/samples/chat2-webapp/src/main/webapp/chat.html @@ -0,0 +1,73 @@ +<!-- + * 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. +--> +<html> + <head> + <title>Apache Tuscany Ajax/DWR Chat Sample</TITLE> + + <script type="text/javascript" src="org.apache.tuscany.sca.componentContext.js" /> + + <script language="JavaScript"> + + var chatService = componentContext.getService("ChatService"); + + chatService.callbacks.chatResponse = function(msg) { + var chatLog = document.getElementById('chatLog'); + chatLog.innerHTML = msg + '<br>' + chatLog.innerHTML; + } + + function sendChat() { + var chatText = document.getElementById("chatText"); + var nickName = document.getElementById("nickName").value; + var msg = nickName + ": " + chatText.value + chatText.value = ""; + chatText.focus(); + ChatService.addMsg(msg); + } + + function clickButton(e, buttonid){ + var evt = e ? e : window.event; + var bt = document.getElementById(buttonid); + if (bt){ + if (evt.keyCode == 13){ + bt.click(); + return false; + } + } + } + + </script> + + </head> + <body > + + <h2>Apache Tuscany Ajax/DWR Chat Sample</h2> + + A simple client to chat between multiple web browsers:<br><br> + + Nickname: <input type="text" id="nickName" size="10"/> + <br><br> + + Enter text: <input type="text" id="chatText" size="80" onkeypress="return clickButton(event,'Send')"/> + <input type="button" name="Send" value="Send" id="Send" onclick="sendChat()" /> + + <br><br> + <div id="chatLog" style="overflow:auto; height:400px; border:1px solid"></div> + + </body> +</html> |