From 8cb254f0230364886b17b63caffd5ab4a8d77652 Mon Sep 17 00:00:00 2001 From: fmoga Date: Wed, 28 Jul 2010 17:09:17 +0000 Subject: Removed async-servlet-sca sample. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@980128 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/sample/StockService.java | 26 ---- .../src/main/java/sample/StockServiceImpl.java | 46 ------- .../src/main/java/sample/StockServlet.java | 153 --------------------- .../src/main/java/sample/TestServlet.java | 70 ---------- .../src/main/resources/log4j.properties | 5 - .../src/main/resources/proposals.txt | 52 ------- .../src/main/webapp/WEB-INF/proposal_web.composite | 41 ------ .../src/main/webapp/WEB-INF/web.composite | 34 ----- .../src/main/webapp/WEB-INF/web.xml | 47 ------- .../async-servlet-sca/src/main/webapp/monitor.html | 29 ---- .../src/main/webapp/proposal_stock.html | 40 ------ .../async-servlet-sca/src/main/webapp/stock.html | 39 ------ 12 files changed, 582 deletions(-) delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockService.java delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServiceImpl.java delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/StockServlet.java delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/java/sample/TestServlet.java delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/log4j.properties delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/resources/proposals.txt delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/proposal_web.composite delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.composite delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/WEB-INF/web.xml delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/monitor.html delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/proposal_stock.html delete mode 100644 sca-java-2.x/contrib/samples/async-servlet-sca/src/main/webapp/stock.html (limited to 'sca-java-2.x/contrib/samples/async-servlet-sca/src') 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("\n"); - writer.write("\n"); - writer.write("Stock Monitor\n"); - - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("

Apache Tuscany Asynchronous Servlet Sample

\n"); - writer.write("

Stock Monitor

\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\n"); - writer.write("\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("\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 -~~~~~~~~~~~~~ - - - - - - - - - - - - - - - - - - - - - - -stock.html -~~~~~~~~~~ - - - - - Apache Tuscany Asynchronous Servlet Sample - - - - - - -

Apache Tuscany Asynchronous Servlet Sample

- -

Stock Monitor

- - - - - \ 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 @@ - - - - - - - - - - - - - - - - - - - - - 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 @@ - - - - - - - - - - - - - - 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 @@ - - - - - Apache Tuscany Asynchronous Servlet Sample - - - org.apache.tuscany.sca.host.webapp.TuscanyContextListener - - - - log4jConfigLocation - WEB-INF/classes/log4j.properties - - - - org.springframework.web.util.Log4jConfigListener - - - - stock.html - - - - 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 @@ - - -Stock Monitor - - - - - -

Apache Tuscany Asynchronous Servlet Sample

- -

Stock Monitor

- - -a - -1 - - - - - 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 @@ - - - - - Apache Tuscany Asynchronous Servlet Sample - - - - - - -

Apache Tuscany Asynchronous Servlet Sample

- -

Stock Monitor

- - - - - \ 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 @@ - - - - -Apache Tuscany Asynchronous Servlet Sample - - - - -

Apache Tuscany Asynchronous Servlet Sample

- -

Stock Monitor

- -
- - -
- -
- - - \ No newline at end of file -- cgit v1.2.3