tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r493687 - in /incubator/tuscany/java/sca/services/transports/http.jetty: pom.xml src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
Date Sun, 07 Jan 2007 09:39:43 GMT
Author: antelder
Date: Sun Jan  7 01:39:42 2007
New Revision: 493687

URL: http://svn.apache.org/viewvc?view=rev&rev=493687
Log:
Get the Jetty service going with the new standalone server stuff and the Axis2 WS binding
- update the pom and code to build with current trunk, move up to Jetty 6.1.0, add a session
handler as Axis2 requires sessions, clean up a few warnings. 

Modified:
    incubator/tuscany/java/sca/services/transports/http.jetty/pom.xml
    incubator/tuscany/java/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
    incubator/tuscany/java/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java

Modified: incubator/tuscany/java/sca/services/transports/http.jetty/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/transports/http.jetty/pom.xml?view=diff&rev=493687&r1=493686&r2=493687
==============================================================================
--- incubator/tuscany/java/sca/services/transports/http.jetty/pom.xml (original)
+++ incubator/tuscany/java/sca/services/transports/http.jetty/pom.xml Sun Jan  7 01:39:42
2007
@@ -19,8 +19,8 @@
 -->
 <project>
     <parent>
-        <groupId>org.apache.tuscany.services</groupId>
-        <artifactId>services</artifactId>
+        <groupId>org.apache.tuscany.sca.services</groupId>
+        <artifactId>parent</artifactId>
         <version>1.0-incubator-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
@@ -36,15 +36,15 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
-            <groupId>jetty</groupId>
+            <groupId>org.mortbay.jetty</groupId>
             <artifactId>jetty</artifactId>
-            <version>6.0.0beta17</version>
+            <version>6.1.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
-            <groupId>jetty</groupId>
+            <groupId>org.mortbay.jetty</groupId>
             <artifactId>jetty-util</artifactId>
-            <version>6.0.0beta16</version>
+            <version>6.1.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>

Modified: incubator/tuscany/java/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java?view=diff&rev=493687&r1=493686&r2=493687
==============================================================================
--- incubator/tuscany/java/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/services/transports/http.jetty/src/main/java/org/apache/tuscany/service/jetty/JettyServiceImpl.java
Sun Jan  7 01:39:42 2007
@@ -20,20 +20,14 @@
 
 import java.io.File;
 import java.io.IOException;
+
 import javax.resource.spi.work.Work;
 import javax.servlet.Servlet;
 
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Init;
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Service;
-
-import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.api.annotation.Monitor;
+import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.host.ServletHost;
 import org.apache.tuscany.spi.services.work.WorkScheduler;
-
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.ContextHandler;
@@ -42,10 +36,16 @@
 import org.mortbay.jetty.servlet.ServletHandler;
 import org.mortbay.jetty.servlet.ServletHolder;
 import org.mortbay.jetty.servlet.ServletMapping;
+import org.mortbay.jetty.servlet.SessionHandler;
 import org.mortbay.log.Log;
 import org.mortbay.log.Logger;
 import org.mortbay.thread.BoundedThreadPool;
 import org.mortbay.thread.ThreadPool;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
 
 /**
  * Implements an HTTP transport service using Jetty.
@@ -182,11 +182,17 @@
                 connector.setPort(httpPort);
                 server.setConnectors(new Connector[]{connector});
             }
+
             ContextHandler contextHandler = new ContextHandler();
             contextHandler.setContextPath(ROOT);
             server.setHandler(contextHandler);
+
+            SessionHandler sessionHandler = new SessionHandler();
             servletHandler = new ServletHandler();
-            contextHandler.setHandler(servletHandler);
+            sessionHandler.addHandler(servletHandler);
+
+            contextHandler.setHandler(sessionHandler);
+
             server.setStopAtShutdown(true);
             server.setSendServerVersion(sendServerVersion);
             monitor.started();
@@ -213,12 +219,17 @@
         ServletHolder holder = new ServletHolder(servlet);
         servletHandler.addServlet(holder);
         ServletMapping mapping = new ServletMapping();
-        mapping.setServletName(holder.getClassName());
+        mapping.setServletName(holder.getName());
         mapping.setPathSpec(path);
         servletHandler.addServletMapping(mapping);
     }
 
-    public void unregisterMapping(String string) {
+    public Servlet unregisterMapping(String string) {
+//        throw new UnsupportedOperationException();
+        return null;
+    }
+
+    public boolean isMappingRegistered(String path) {
         throw new UnsupportedOperationException();
     }
 

Modified: incubator/tuscany/java/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java?view=diff&rev=493687&r1=493686&r2=493687
==============================================================================
--- incubator/tuscany/java/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
(original)
+++ incubator/tuscany/java/sca/services/transports/http.jetty/src/test/java/org/apache/tuscany/service/jetty/JettyServiceImplTestCase.java
Sun Jan  7 01:39:42 2007
@@ -80,6 +80,23 @@
         assertTrue(servlet.invoked);
     }
 
+    public void testRequestSession() throws Exception {
+        JettyServiceImpl service = new JettyServiceImpl(monitor, scheduler);
+        service.setDebug(true);
+        service.setHttpPort(HTTP_PORT);
+        service.init();
+        TestServlet servlet = new TestServlet();
+        service.registerMapping("/", servlet);
+        Socket client = new Socket("127.0.0.1", HTTP_PORT);
+        OutputStream os = client.getOutputStream();
+        os.write(REQUEST1.getBytes());
+        os.flush();
+        read(client);
+        service.destroy();
+        assertTrue(servlet.invoked);
+        assertNotNull(servlet.sessionId);
+    }
+
     public void testUseWorkScheduler() throws Exception {
         JettyServiceImpl service = new JettyServiceImpl(monitor, scheduler);
         service.setDebug(true);
@@ -122,6 +139,7 @@
         //executor.submit();
     }
 
+    @SuppressWarnings("unchecked")
     protected void setUp() throws Exception {
         super.setUp();
         monitor = createMock(TransportMonitor.class);
@@ -156,10 +174,13 @@
     }
 
     private class TestServlet extends HttpServlet {
+        private static final long serialVersionUID = 1L;
         boolean invoked;
+        String sessionId;
 
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
             invoked = true;
+            sessionId = req.getSession().getId();
             OutputStream writer = resp.getOutputStream();
             try {
                 writer.write("result".getBytes());



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message