From 6bf99eb5eba8927df4e06ca26d106b3ba4074f69 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 2 Dec 2010 19:11:25 +0000 Subject: Get the eightball webapp running git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041540 13f79535-47bb-0310-9956-ffa450edef68 --- .../eightball-demo/eightball-webapp/pom.xml | 47 +++++++++++++++++----- .../src/main/java/demo/EightBallServlet.java | 11 +++++ .../src/main/webapp/WEB-INF/web.xml | 3 ++ 3 files changed, 51 insertions(+), 10 deletions(-) (limited to 'sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp') diff --git a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/pom.xml b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/pom.xml index 6287de1a7e..eeabfc5fa4 100644 --- a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/pom.xml +++ b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/pom.xml @@ -28,21 +28,12 @@ quickstart - org.apache.tuscany.sca - tuscany-sca-api + tuscany-base-runtime ${tuscany.version} - provided - - junit @@ -126,6 +117,42 @@ true + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + compile + + copy + + + + + + demo + eightball + ${pom.version} + src/main/webapp/WEB-INF/sca-contributions + + + demo + eightball-process + ${pom.version} + src/main/webapp/WEB-INF/sca-contributions + + + demo + translator + ${pom.version} + src/main/webapp/WEB-INF/sca-contributions + + + + + + diff --git a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/java/demo/EightBallServlet.java b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/java/demo/EightBallServlet.java index d6c3103281..6728d44e61 100644 --- a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/java/demo/EightBallServlet.java +++ b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/java/demo/EightBallServlet.java @@ -21,10 +21,13 @@ package demo; import java.io.IOException; import java.io.Writer; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.oasisopen.sca.ComponentContext; import org.oasisopen.sca.annotation.Reference; /** @@ -34,6 +37,14 @@ public class EightBallServlet extends HttpServlet { @Reference protected EightBall eightball; + @Override + public void init(ServletConfig servletConfig) throws ServletException { + if (eightball == null) { + ComponentContext cc = (ComponentContext)servletConfig.getServletContext().getAttribute("org.oasisopen.sca.ComponentContext"); + eightball = cc.getService(EightBall .class, "eightball"); + } + } + @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException { String question = request.getParameter("question"); diff --git a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/webapp/WEB-INF/web.xml index f828db7a81..ddfcc666ad 100644 --- a/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/webapp/WEB-INF/web.xml +++ b/sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/webapp/WEB-INF/web.xml @@ -24,6 +24,8 @@ eightball-webapp + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + EightBallServlet demo.EightBallServlet @@ -39,3 +41,4 @@ + -- cgit v1.2.3