You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fm...@apache.org on 2010/07/27 17:25:35 UTC
svn commit: r979748 [1/3] - in
/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sample/
src/main/j...
Author: fmoga
Date: Tue Jul 27 15:25:35 2010
New Revision: 979748
URL: http://svn.apache.org/viewvc?rev=979748&view=rev
Log:
- Added sources for stock-comet-jquery sample
Added:
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/pom.xml
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/CometBinding.java
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/EventsLogger.java
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/FileResource.java
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockService.java
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockServiceImpl.java
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/MANIFEST.MF
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/context.xml
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/lib/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.composite
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.xml
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/index.html
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/js/
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/js/jquery-1.4.2.js
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/js/jquery.atmosphere.js
Modified:
tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/ (props changed)
Propchange: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 27 15:25:35 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/pom.xml?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/pom.xml (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/pom.xml Tue Jul 27 15:25:35 2010
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-stock-comet-jquery-webapp</artifactId>
+ <packaging>war</packaging>
+ <version>1.0</version>
+ <name>stock-comet-jquery</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-jersey</artifactId>
+ <version>0.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <version>0.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>3.0-b73</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>7.1.1.v20100517</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.22</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>6.1.22</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-management</artifactId>
+ <version>6.1.22</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ning</groupId>
+ <artifactId>async-http-client</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>stock-comet-jquery</finalName>
+ </build>
+</project>
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/CometBinding.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/CometBinding.java?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/CometBinding.java (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/CometBinding.java Tue Jul 27 15:25:35 2010
@@ -0,0 +1,55 @@
+package org.apache.tuscany.sample.comet;
+
+import java.util.Date;
+import java.util.Random;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.atmosphere.annotation.Broadcast;
+import org.atmosphere.cpr.Broadcaster;
+import org.atmosphere.cpr.DefaultBroadcaster;
+import org.atmosphere.jersey.Broadcastable;
+import org.atmosphere.jersey.SuspendResponse;
+import org.oasisopen.sca.ComponentContext;
+import org.oasisopen.sca.annotation.Context;
+import org.oasisopen.sca.annotation.Reference;
+
+import com.sun.jersey.spi.container.servlet.PerSession;
+
+@Path("/tuscany-comet")
+@Produces("text/html;charset=ISO-8859-1")
+@PerSession
+public class CometBinding {
+
+ // TODO: fix Tuscany injection
+ @Reference
+ public StockService service;
+
+ @Context
+ public ComponentContext context;
+
+ private Broadcaster broadcaster = new DefaultBroadcaster();
+
+ @GET
+ public SuspendResponse<String> register() {
+ System.out.println("Service reference: " + service);
+ System.out.println("Context reference: " + context);
+ return new SuspendResponse.SuspendResponseBuilder<String>()
+ .broadcaster(broadcaster)
+ .outputComments(true)
+ .addListener(new EventsLogger())
+ .build();
+ }
+
+ @POST
+ @Broadcast
+ public Broadcastable publish() {
+ System.out.println("Service reference: " + service);
+ System.out.println("Context reference: " + context);
+ return new Broadcastable("ASF#" + new Random(new Date().getTime()).nextInt(1000), "", broadcaster);
+ }
+
+}
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/EventsLogger.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/EventsLogger.java?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/EventsLogger.java (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/EventsLogger.java Tue Jul 27 15:25:35 2010
@@ -0,0 +1,67 @@
+/*
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://jersey.dev.java.net/CDDL+GPL.html
+ * or jersey/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at jersey/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.apache.tuscany.sample.comet;
+
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.atmosphere.cpr.AtmosphereResourceEventListener;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class EventsLogger implements AtmosphereResourceEventListener {
+
+ public EventsLogger() {
+ }
+
+ public void onSuspend(final AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ System.out.println("onSuspend: " + event.getResource().getRequest().getRemoteAddr()
+ + event.getResource().getRequest().getRemotePort());
+ }
+
+ public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ System.out.println("onResume: " + event.getResource().getRequest().getRemoteAddr());
+ }
+
+ public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ System.out.println("onDisconnect: " + event.getResource().getRequest().getRemoteAddr()
+ + event.getResource().getRequest().getRemotePort());
+ }
+
+ public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ System.out.println("onBroadcast: " + event.getMessage());
+ }
+}
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/FileResource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/FileResource.java?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/FileResource.java (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/FileResource.java Tue Jul 27 15:25:35 2010
@@ -0,0 +1,66 @@
+/*
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://jersey.dev.java.net/CDDL+GPL.html
+ * or jersey/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at jersey/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package org.apache.tuscany.sample.comet;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.PathSegment;
+
+@Path("/")
+@Produces("text/html")
+public class FileResource {
+
+ @Context
+ private ServletContext sc;
+
+ @Path("/js/{id}")
+ @GET
+ public InputStream getJQuery(@PathParam("id") PathSegment ps) {
+ return sc.getResourceAsStream("/js/" + ps.getPath());
+ }
+
+ @GET
+ public InputStream getIndex() {
+ return sc.getResourceAsStream("/index.html");
+ }
+}
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockService.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockService.java?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockService.java (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockService.java Tue Jul 27 15:25:35 2010
@@ -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 org.apache.tuscany.sample.comet;
+
+public interface StockService {
+
+ String getSymbol();
+
+ Double getValue();
+
+}
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockServiceImpl.java?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockServiceImpl.java (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/java/org/apache/tuscany/sample/comet/StockServiceImpl.java Tue Jul 27 15:25:35 2010
@@ -0,0 +1,41 @@
+/*
+ * 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 org.apache.tuscany.sample.comet;
+
+import java.text.DecimalFormat;
+import java.util.Date;
+import java.util.Random;
+
+public class StockServiceImpl implements StockService {
+
+ public static final int MAX_VALUE = 1000;
+ private Random random = new Random(new Date().getTime());
+
+ @Override
+ public String getSymbol() {
+ return "ASF";
+ }
+
+ @Override
+ public Double getValue() {
+ Double value = Math.abs(random.nextDouble() * random.nextInt(MAX_VALUE));
+ return Double.valueOf(new DecimalFormat("#.##").format(value));
+ }
+
+}
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/MANIFEST.MF?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/MANIFEST.MF (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/META-INF/MANIFEST.MF Tue Jul 27 15:25:35 2010
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/context.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/context.xml?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/context.xml (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/context.xml Tue Jul 27 15:25:35 2010
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context>
+ <!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
+ <Loader delegate="true"/>
+</Context>
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.composite?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.composite (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.composite Tue Jul 27 15:25:35 2010
@@ -0,0 +1,34 @@
+<?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://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Stock">
+
+ <component name="AtmosphereServlet">
+ <implementation.web web-uri=""/>
+ <reference name="service" target="StockService"/>
+ </component>
+
+ <component name="StockService">
+ <implementation.java class="org.apache.tuscany.sample.comet.StockServiceImpl"/>
+ </component>
+
+</composite>
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.xml?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.xml (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/WEB-INF/web.xml Tue Jul 27 15:25:35 2010
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:j2ee="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3.0.xsd">
+ <description>Apache Tuscany Stock Comet jQuery Sample</description>
+ <display-name>Apache Tuscany Stock Comet jQuery Sample</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <servlet>
+ <description>AtmosphereServlet</description>
+ <servlet-name>AtmosphereServlet</servlet-name>
+ <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
+ <async-supported>true</async-supported>
+ <load-on-startup>0</load-on-startup>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.apache.tuscany.sample.comet</param-value>
+ </init-param>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>AtmosphereServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
+
Added: tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/index.html?rev=979748&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/index.html (added)
+++ tuscany/sca-java-2.x/contrib/samples/stock-comet-jquery/src/main/webapp/index.html Tue Jul 27 15:25:35 2010
@@ -0,0 +1,76 @@
+<!--
+ * 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 Asynchronous Servlet Sample</title>
+ <script type="text/javascript" src="stock-comet-jquery/js/jquery-1.4.2.js"></script>
+ <script type="text/javascript" src="stock-comet-jquery/js/jquery.atmosphere.js"></script>
+ <script type="text/javascript">
+ $(document).ready(function()
+ {
+ var connectedEndpoint;
+
+ function update(response) {
+ var data = response.responseBody;
+ var aux = data.toString().split('#');
+ document.getElementById('symbol').textContent = aux[0];
+ document.getElementById('price').textContent = aux[1];
+ }
+
+ document.getElementById('connect').onclick = function(event) {
+ /* transport can be : long-polling, streaming or websocket */
+ $.atmosphere.subscribe(document.location.toString() + '/tuscany-comet',
+ update,
+ $.atmosphere.request = {transport: document.getElementById('transport').value});
+ connectedEndpoint = $.atmosphere.response;
+
+ document.getElementById('connect').disabled = true;
+ document.getElementById('transport').disabled = true;
+ document.getElementById('get-values').disabled = false;
+ }
+
+ document.getElementById('get-values').disabled = true;
+ document.getElementById('get-values').onclick = function(event) {
+ connectedEndpoint.push(document.location.toString() + '/tuscany-comet',
+ null,
+ $.atmosphere.request = {method: 'POST'});
+ }
+ });
+ </script>
+ </head>
+ <body>
+ <h2>Apache Tuscany Asynchronous Servlet Sample</h2>
+ <label>Select transport</label>
+ <select id="transport">
+ <option id="streaming" value="streaming">http streaming</option>
+ <option id="long-polling" value="long-polling">long-polling</option>
+ <option id="websocket" value="websocket">websocket</option>
+ </select>
+ <input id='connect' type='submit' value='Connect'/>
+ <h3>Stock Monitor</h3>
+ <input id='get-values' type="submit" value='Get values'/>
+ <p/>
+ <div id='text'>
+ <b><label>Company Symbol: </label></b>
+ <span id="symbol">N/A</span>
+ <b><label>Price: </label></b>
+ <span id="price">N/A</span>
+ </div>
+ </body>
+</html>