summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/applications/eightball-demo
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-12-02 19:11:25 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-12-02 19:11:25 +0000
commit6bf99eb5eba8927df4e06ca26d106b3ba4074f69 (patch)
treedaf80fec63166350585212ede4f6cb3d6a1a6bee /sca-java-2.x/trunk/samples/applications/eightball-demo
parent7dcd557051a188b97bcfbc998d2600f1c72fba0c (diff)
Get the eightball webapp running
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041540 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/applications/eightball-demo')
-rw-r--r--sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/pom.xml47
-rw-r--r--sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/java/demo/EightBallServlet.java11
-rw-r--r--sca-java-2.x/trunk/samples/applications/eightball-demo/eightball-webapp/src/main/webapp/WEB-INF/web.xml3
3 files changed, 51 insertions, 10 deletions
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 @@
<name>quickstart</name>
<dependencies>
- <!-- TUSCANY DEPENDENCIES -->
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-sca-api</artifactId>
+ <artifactId>tuscany-base-runtime</artifactId>
<version>${tuscany.version}</version>
- <scope>provided</scope>
</dependency>
- <!-- dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-implementation-web-runtime</artifactId>
- <version>${tuscany.version}</version>
- <scope>runtime</scope>
- </dependency -->
-
<!-- JUNIT DEPENDENCY FOR TESTING -->
<dependency>
<groupId>junit</groupId>
@@ -126,6 +117,42 @@
<downloadSources>true</downloadSources>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <!-- these should really go in the target folder but i can't get jetty:run to work using that -->
+ <artifactItem>
+ <groupId>demo</groupId>
+ <artifactId>eightball</artifactId>
+ <version>${pom.version}</version>
+ <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>demo</groupId>
+ <artifactId>eightball-process</artifactId>
+ <version>${pom.version}</version>
+ <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>demo</groupId>
+ <artifactId>translator</artifactId>
+ <version>${pom.version}</version>
+ <outputDirectory>src/main/webapp/WEB-INF/sca-contributions</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<properties>
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;
/**
@@ -35,6 +38,14 @@ public class EightBallServlet extends HttpServlet {
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");
String answer = eightball.askQuestion(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 @@
<display-name>eightball-webapp</display-name>
+ <listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
<servlet>
<servlet-name>EightBallServlet</servlet-name>
<servlet-class>demo.EightBallServlet</servlet-class>
@@ -39,3 +41,4 @@
</welcome-file-list>
</web-app>
+