diff options
author | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-28 17:09:17 +0000 |
---|---|---|
committer | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-28 17:09:17 +0000 |
commit | 8cb254f0230364886b17b63caffd5ab4a8d77652 (patch) | |
tree | 52e9fcea1e4eeed5790693f8c1a0f1f895fc86ef /sca-java-2.x/contrib/samples/async-servlet-sca/src | |
parent | 8a11488e89b9c86e99f561c67236577dcb5c7929 (diff) |
Removed async-servlet-sca sample.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@980128 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/contrib/samples/async-servlet-sca/src')
12 files changed, 0 insertions, 582 deletions
diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockService.java b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockService.java deleted file mode 100644 index d0c387a5f1..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockService.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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; - -public interface StockService { - - String getSymbol(); - Double getValue(); - -} diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServiceImpl.java b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServiceImpl.java deleted file mode 100644 index 237f63c950..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServiceImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 java.text.DecimalFormat; -import java.util.Date; -import java.util.Random; - -import org.apache.log4j.Logger; - -public class StockServiceImpl implements StockService { - - public static final int MAX_VALUE = 1000; - private Random random = new Random(new Date().getTime()); - private Logger logger = Logger.getLogger(StockServiceImpl.class); - - @Override - public String getSymbol() { - logger.debug("Getting symbol..."); - return "ASF"; - } - - @Override - public Double getValue() { - logger.debug("Getting value..."); - Double value = Math.abs(random.nextDouble() * random.nextInt(MAX_VALUE)); - return Double.valueOf(new DecimalFormat("#.##").format(value)); - } - -} diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServlet.java b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServlet.java deleted file mode 100644 index 5471d9a3c8..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServlet.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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 java.io.IOException; -import java.io.Writer; - -import javax.servlet.AsyncContext; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.log4j.Logger; -import org.oasisopen.sca.ComponentContext; -import org.oasisopen.sca.annotation.Reference; - -@WebServlet(asyncSupported = true, urlPatterns = "/stock") -public class StockServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - private static final long MILLIS_PER_SECOND = 1000L; - private static final long DEFAULT_UPDATE_INTERVAL = 1L; // default 1 sec - - @Reference - protected StockService service; - private Logger logger = Logger.getLogger(StockServlet.class); - - public void init(ServletConfig servletConfig) throws ServletException { - if (service == null) { - logger.debug("Service reference injection failed, using ComponentContext..."); - ComponentContext cc = - (ComponentContext)servletConfig.getServletContext().getAttribute("org.oasisopen.sca.ComponentContext"); - service = cc.getService(StockService.class, "service"); - } else { - logger.debug("Service reference succesfully injected."); - } - } - - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException { - logger.debug("Received request."); - logger.debug("Starting async context..."); - - AsyncContext asyncContext = req.startAsync(); - resp.setContentType("text/html"); - - logger.debug("Sending initial response..."); - try { - Writer writer = asyncContext.getResponse().getWriter(); - writer.write("<html>\n"); - writer.write("<head>\n"); - writer.write("<title>Stock Monitor</title>\n"); - - writer.write("<script type=\"text/javascript\">\n"); - writer.write("function updateData(data) {\n"); - writer.write("var aux = data.split('#');\n"); - writer.write("document.getElementById('symbol').textContent = aux[0];\n"); - writer.write("document.getElementById('price').textContent = aux[1];\n"); - writer.write("}\n"); - writer.write("</script>\n"); - writer.write("</head>\n"); - writer.write("<body>\n"); - writer.write("<h2>Apache Tuscany Asynchronous Servlet Sample</h2>\n"); - writer.write("<h3>Stock Monitor</h3>\n"); - writer.write("<b><label>Company Symbol: </label></b>\n"); - writer.write("<span id=\"symbol\"></span>\n"); - writer.write("<b><label>Price: </label></b>\n"); - writer.write("<span id=\"price\"></span>\n"); - writer.write("</body>\n"); - writer.write("</html>\n"); - resp.flushBuffer(); - } catch (IOException e) { - e.printStackTrace(); - } - - logger.debug("Service reference: " + service); - - logger.debug("Starting updates..."); - if (req.getParameter("interval") != null) { - logger.debug("Using custom update interval value..."); - long updateInterval = Long.parseLong(req.getParameter("interval")); - new Thread(new StockTask(asyncContext, updateInterval * MILLIS_PER_SECOND)).start(); - } else { - logger.debug("Using default update interval value..."); - new Thread(new StockTask(asyncContext, DEFAULT_UPDATE_INTERVAL * MILLIS_PER_SECOND)).start(); - } - - logger.debug("Exiting doGet method..."); - } - - // ----------------------------------------------------------- - - public class StockTask implements Runnable { - - private AsyncContext asyncContext; - private long updateInterval; - - public StockTask(AsyncContext asyncContext, long updateInterval) { - super(); - this.asyncContext = asyncContext; - this.updateInterval = updateInterval; - } - - public void setAsyncContext(AsyncContext asyncContext) { - this.asyncContext = asyncContext; - } - - public void setUpdateInterval(long updateInterval) { - this.updateInterval = updateInterval; - } - - @Override - public void run() { - try { - while (true) { - logger.debug("Updating response..."); - Writer writer = asyncContext.getResponse().getWriter(); - writer.write("<script type=\"text/javascript\">\n"); - writer.write("updateData('" + service.getSymbol() + "#" + service.getValue() + "');\n"); - writer.write("</script>\n"); - writer.flush(); - asyncContext.getResponse().flushBuffer(); - logger.debug("Flushed response."); - Thread.sleep(updateInterval); - } - } catch (IOException e) { - logger.debug(e.getMessage(), e); - asyncContext.complete(); - } catch (InterruptedException e) { - logger.debug(e.getMessage(), e); - asyncContext.complete(); - } - } - } - -} diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/TestServlet.java b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/TestServlet.java deleted file mode 100644 index bc4d16dd27..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/TestServlet.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 java.io.IOException; -import java.io.Writer; - -import javax.servlet.AsyncContext; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.log4j.Logger; - -@WebServlet(asyncSupported = true, urlPatterns = "/test") -public class TestServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - - private AsyncContext asyncContext; - private Logger logger = Logger.getLogger(TestServlet.class); - - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException { - logger.debug("Received test request."); - logger.debug("Gathering async context..."); - asyncContext = req.startAsync(); - resp.setContentType("text/plain"); - - logger.debug("Gathering writer..."); - Writer writer; - try { - writer = asyncContext.getResponse().getWriter(); - for (int i = 0; i < 10; i++) { - Thread.sleep(1000); - logger.debug("Sending " + i + "..."); - writer.write("" + i + "\n"); - writer.flush(); - resp.flushBuffer(); - } - - logger.debug("Completing response..."); - asyncContext.complete(); - writer.close(); - } catch (IOException e1) { - asyncContext.complete(); - e1.printStackTrace(); - } catch (InterruptedException e) { - asyncContext.complete(); - e.printStackTrace(); - } - } - -} diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/log4j.properties b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/log4j.properties deleted file mode 100644 index aa524fcfa8..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/log4j.properties +++ /dev/null @@ -1,5 +0,0 @@ -log4j.rootLogger=DEBUG, CA -#Console Appender -log4j.appender.CA=org.apache.log4j.ConsoleAppender -log4j.appender.CA.layout=org.apache.log4j.PatternLayout -log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/proposals.txt b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/proposals.txt deleted file mode 100644 index de0d1bb26d..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/proposals.txt +++ /dev/null @@ -1,52 +0,0 @@ -web.composite -~~~~~~~~~~~~~ - -<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="WebPage"> - <implementation.?/> - <callback> - <binding.? url="/stock/**" method="callbackJsMethod"/> - </callback> - </component> - - <component name="Servlet"> - <implementation.web web-uri=""/> - <reference name="service" target="StockComponent"/> - </component> - - <component name="StockComponent"> - <implementation.java class="sample.StockServiceImpl"/> - </component> - -</composite> - - -stock.html -~~~~~~~~~~ - -<html> - -<head> - <title>Apache Tuscany Asynchronous Servlet Sample</title> - <script type="text/javascript" src="org.apache.tuscany.callbackListener.js"></script> - - <script language="JavaScript"> - function callbackJsMethod(response) { - // process received response - } - </script> -</head> - -<body> - <h2>Apache Tuscany Asynchronous Servlet Sample</h2> - - <h3>Stock Monitor</h3> - - <input type="button" value="Start monitoring" onclick=""> -</body> - -</html>
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/proposal_web.composite b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/proposal_web.composite deleted file mode 100644 index 7dc8aabea6..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/proposal_web.composite +++ /dev/null @@ -1,41 +0,0 @@ -<?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="WebPage"> - <implementation.?/> - <callback> - <binding.? url="/stock/**" method="callbackJsMethod"/> - </callback> - </component> - - <component name="Servlet"> - <implementation.web web-uri=""/> - <reference name="service" target="StockComponent"/> - </component> - - <component name="StockComponent"> - <implementation.java class="sample.StockServiceImpl"/> - </component> - -</composite> diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.composite b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.composite deleted file mode 100644 index 738a79e450..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.composite +++ /dev/null @@ -1,34 +0,0 @@ -<?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="StockServlet"> - <implementation.web web-uri=""/> - <reference name="service" target="StockService"/> - </component> - - <component name="StockService"> - <implementation.java class="sample.StockServiceImpl"/> - </component> - -</composite> diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index fee71f3bcf..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?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. ---> -<web-app xmlns="http://java.sun.com/xml/ns/javaee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee - http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" - version="3.0" - metadata-complete="false"> - - <display-name>Apache Tuscany Asynchronous Servlet Sample</display-name> - - <listener> - <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class> - </listener> - - <context-param> - <param-name>log4jConfigLocation</param-name> - <param-value>WEB-INF/classes/log4j.properties</param-value> - </context-param> - - <listener> - <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> - </listener> - - <welcome-file-list id="WelcomeFileList"> - <welcome-file>stock.html</welcome-file> - </welcome-file-list> - -</web-app> - diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/monitor.html b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/monitor.html deleted file mode 100644 index 631ad1909b..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/monitor.html +++ /dev/null @@ -1,29 +0,0 @@ -<html> -<head> -<title>Stock Monitor</title> - -<script type="text/javascript"> -function updateData(data) { - var aux = data.split('#'); - document.getElementById('symbol').textContent = aux[0]; - document.getElementById('price').textContent = aux[1]; -} -</script> - -</head> -<body> -<h2>Apache Tuscany Asynchronous Servlet Sample</h2> - -<h3>Stock Monitor</h3> - -<b><label>Company Symbol: </label></b> -<span id="symbol">a</span> -<b><label>Price: </label></b> -<span id="price">1</span> - -</body> -</html> - -<script type="text/javascript"> - updateData('Apache#1234'); -</script> diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/proposal_stock.html b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/proposal_stock.html deleted file mode 100644 index 975ed0ed57..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/proposal_stock.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- - * 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="org.apache.tuscany.callbackListener.js"></script> - - <script language="JavaScript"> - function callbackJsMethod(response) { - // process received response - } - </script> -</head> - -<body> - <h2>Apache Tuscany Asynchronous Servlet Sample</h2> - - <h3>Stock Monitor</h3> - - <input type="button" value="Start monitoring" onclick=""> -</body> - -</html>
\ No newline at end of file diff --git a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/stock.html b/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/stock.html deleted file mode 100644 index 3910434d33..0000000000 --- a/sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/stock.html +++ /dev/null @@ -1,39 +0,0 @@ -<!-- - * 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> -</head> - -<body> - -<h2>Apache Tuscany Asynchronous Servlet Sample</h2> - -<h3>Stock Monitor</h3> - -<form action="stock" method="GET"> - <label>Enter the update interval (seconds): </label> - <input type="text" name="interval" size="2"/> - <br/> - <button type="submit">Start monitoring</button> -</form> - -</body> -</html>
\ No newline at end of file |