tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r830270 - in /tuscany/java/sca/samples/webapps/helloworld-servlet: pom.xml src/main/java/sample/HelloworldServlet.java src/main/webapp/WEB-INF/web.xml
Date Tue, 27 Oct 2009 17:59:46 GMT
Author: antelder
Date: Tue Oct 27 17:59:45 2009
New Revision: 830270

URL: http://svn.apache.org/viewvc?rev=830270&view=rev
Log:
Update servlet sample to use ComponentContext look up in non-SCA enabled runtimes where injection
doesn't work. And add the jetty plugin to the pom.xml so the sample can be tried with mvn
jetty:run

Modified:
    tuscany/java/sca/samples/webapps/helloworld-servlet/pom.xml
    tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
    tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml

Modified: tuscany/java/sca/samples/webapps/helloworld-servlet/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-servlet/pom.xml?rev=830270&r1=830269&r2=830270&view=diff
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-servlet/pom.xml (original)
+++ tuscany/java/sca/samples/webapps/helloworld-servlet/pom.xml Tue Oct 27 17:59:45 2009
@@ -34,21 +34,21 @@
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-sca-api</artifactId>
+            <artifactId>tuscany-implementation-web-runtime</artifactId>
             <version>2.0-SNAPSHOT</version>
-            <scope>provided</scope>
         </dependency>
 
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>
     </dependencies>
 
     <build>
        <finalName>${artifactId}</finalName>
+       <plugins>
+          <plugin>
+             <groupId>org.mortbay.jetty</groupId>
+             <artifactId>maven-jetty-plugin</artifactId>
+             <version>6.1.18</version>
+          </plugin>
+       </plugins>
     </build>
 </project>
 

Modified: tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java?rev=830270&r1=830269&r2=830270&view=diff
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
(original)
+++ tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
Tue Oct 27 17:59:45 2009
@@ -21,10 +21,13 @@
 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,8 +38,13 @@
     @Reference
     protected HelloworldService service;
 
-    public HelloworldServlet() {
-        System.out.println("HelloworldServlet");
+    @Override
+    public void init(ServletConfig servletConfig) throws ServletException {
+        if (service == null) {
+            System.out.println("HelloworldServlet reference injection failed, using ComponentContext");
+            ComponentContext cc = (ComponentContext)servletConfig.getServletContext().getAttribute("org.oasisopen.sca.ComponentContext");
+            service = cc.getService(HelloworldService.class, "service");
+        }
     }
 
     @Override

Modified: tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml?rev=830270&r1=830269&r2=830270&view=diff
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml (original)
+++ tuscany/java/sca/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml Tue
Oct 27 17:59:45 2009
@@ -24,6 +24,8 @@
 
     <display-name>Apache Tuscany Helloworld Servlet Sample</display-name>
 
+	<listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
     <servlet>
         <servlet-name>HelloworldServlet</servlet-name>
         <servlet-class>sample.HelloworldServlet</servlet-class>



Mime
View raw message