cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r965643 - in /cxf/branches/servlet3jetty7: rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/ rt/transports/http-jetty/src/te...
Date Mon, 19 Jul 2010 21:25:52 GMT
Author: dkulp
Date: Mon Jul 19 21:25:51 2010
New Revision: 965643

URL: http://svn.apache.org/viewvc?rev=965643&view=rev
Log:
More work toward jetty 7

Added:
    cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
  (with props)
Removed:
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderTest.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapperTest.java
Modified:
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml
    cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
    cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
    cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/continuations/ClientServerWrappedContinuationTest.java
    cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
    cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
    cxf/branches/servlet3jetty7/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Mon Jul 19 21:25:51 2010
@@ -34,7 +34,6 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.security.CertificateConstraintsType;
-import org.apache.cxf.continuations.ContinuationInfo;
 import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.interceptor.Fault;
@@ -46,15 +45,12 @@ import org.apache.cxf.service.model.Endp
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.HTTPSession;
 import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
-import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationWrapper;
 import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
 import org.apache.cxf.transports.http.QueryHandler;
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
 import org.apache.cxf.transports.http.StemMatchingQueryHandler;
 import org.eclipse.jetty.server.HttpConnection;
 import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.continuation.Continuation;
-import org.eclipse.jetty.continuation.ContinuationSupport;
 
 public class JettyHTTPDestination extends AbstractHTTPDestination {
     
@@ -294,11 +290,6 @@ public class JettyHTTPDestination extend
         if (inMessage == null) {
             
             inMessage = new MessageImpl();
-            if (engine.getContinuationsEnabled()) {
-                inMessage.put(ContinuationProvider.class.getName(), 
-                          new JettyContinuationProvider(req, inMessage));
-            }
-            
             setupMessage(inMessage, context, req, resp);
             
             ((MessageImpl)inMessage).setDestination(this);
@@ -312,17 +303,8 @@ public class JettyHTTPDestination extend
             incomingObserver.onMessage(inMessage);
             resp.flushBuffer();
             baseRequest.setHandled(true);
-            JettyContinuationProvider p = (JettyContinuationProvider)inMessage
-                .get(ContinuationProvider.class.getName());
-            if (p != null) {
-                //make sure the continuation is stripped down 
-                JettyContinuationWrapper c = p.getContinuation(false);
-                if (c != null) {
-                    c.done();
-                }
-            }
         } catch (SuspendedInvocationException ex) {
-            throw ex.getRuntimeException();
+            //nothing - async case
         } catch (Fault ex) {
             Throwable cause = ex.getCause();
             if (cause instanceof RuntimeException) {
@@ -339,38 +321,6 @@ public class JettyHTTPDestination extend
         }
     }
 
-    protected Message retrieveFromContinuation(HttpServletRequest req) {
-        Message m = null;
-        
-        if (!engine.getContinuationsEnabled()) {
-            return null;
-        }
-        
-        Continuation cont = ContinuationSupport.getContinuation(req);
-        synchronized (cont) {
-            Object o = cont.getObject();
-            if (o instanceof ContinuationInfo) {
-                ContinuationInfo ci = (ContinuationInfo)o;
-                m = ci.getMessage();
-                
-                // now that we got the message we don't need ContinuationInfo
-                // as we don't know how continuation was suspended, by jetty wrapper
-                // or directly in which (latter) case we need to ensure that an original
user object
-                // if any, need to be restored
-                cont.setObject(ci.getUserObject());
-            }
-            if (m == null && (cont.isPending() || cont.isResumed())) {
-                String message = "No message for existing continuation, status : "
-                    + (cont.isPending() ? "Pending" : "Resumed");
-                if (!(o instanceof ContinuationInfo)) {
-                    message += ", ContinuationInfo object is unavailable";
-                }
-                LOG.warning(message);
-            }
-        }
-        return m;
-    }
-    
     @Override
     public void shutdown() {
         transportFactory.removeDestination(endpointInfo);
@@ -385,4 +335,16 @@ public class JettyHTTPDestination extend
     private String getStem(String baseURI) {    
         return baseURI.substring(0, baseURI.lastIndexOf("/"));
     }
+    
+    protected Message retrieveFromContinuation(HttpServletRequest req) {
+        return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
+    }
+    protected void setupContinuation(Message inMessage,
+                      final HttpServletRequest req, 
+                      final HttpServletResponse resp) {
+        if (engine.getContinuationsEnabled()) {
+            inMessage.put(ContinuationProvider.class.getName(), 
+                      new JettyContinuationProvider(req, resp, inMessage));
+        }
+    }
 }

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Mon Jul 19 21:25:51 2010
@@ -38,7 +38,6 @@ import org.apache.cxf.configuration.jsse
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.transport.HttpUriMapper;
 import org.apache.cxf.transport.https_jetty.JettySslConnectorFactory;
-import org.eclipse.jetty.util.component.Container;
 import org.eclipse.jetty.server.AbstractConnector;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
@@ -48,10 +47,11 @@ import org.eclipse.jetty.server.handler.
 import org.eclipse.jetty.server.handler.DefaultHandler;
 import org.eclipse.jetty.server.handler.HandlerList;
 import org.eclipse.jetty.server.nio.SelectChannelConnector;
-import org.eclipse.jetty.server.ssl.SslSocketConnector;
 import org.eclipse.jetty.server.session.HashSessionIdManager;
 import org.eclipse.jetty.server.session.HashSessionManager;
 import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.component.Container;
 import org.eclipse.jetty.util.thread.OldQueuedThreadPool;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
 

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProvider.java
Mon Jul 19 21:25:51 2010
@@ -20,6 +20,7 @@
 package org.apache.cxf.transport.http_jetty.continuations;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.continuations.Continuation;
 import org.apache.cxf.continuations.ContinuationProvider;
@@ -28,11 +29,15 @@ import org.apache.cxf.message.Message;
 public class JettyContinuationProvider implements ContinuationProvider {
 
     private HttpServletRequest request;
+    private HttpServletResponse response;
     private Message inMessage; 
     private JettyContinuationWrapper wrapper;
     
-    public JettyContinuationProvider(HttpServletRequest req, Message m) {
+    public JettyContinuationProvider(HttpServletRequest req,
+                                     HttpServletResponse resp, 
+                                     Message m) {
         request = req;
+        response = resp;
         this.inMessage = m;
     }
     public Continuation getContinuation() {
@@ -43,7 +48,7 @@ public class JettyContinuationProvider i
             return null;
         }
         if (wrapper == null && create) {
-            wrapper = new JettyContinuationWrapper(request, inMessage);
+            wrapper = new JettyContinuationWrapper(request, response, inMessage);
         }
         return wrapper;
     }

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
Mon Jul 19 21:25:51 2010
@@ -20,96 +20,75 @@
 package org.apache.cxf.transport.http_jetty.continuations;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.continuations.Continuation;
-import org.apache.cxf.continuations.ContinuationInfo;
-import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.message.Message;
-import org.eclipse.jetty.RetryRequest;
-import org.eclipse.jetty.continuation.ContinuationSupport;
-
-public class JettyContinuationWrapper implements Continuation {
-
-    private org.eclipse.jetty.continuation.Continuation continuation;
-    private Message message;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.eclipse.jetty.continuation.ContinuationListener;
+import org.eclipse.jetty.server.AsyncContext;
+import org.eclipse.jetty.server.Request;
+
+public class JettyContinuationWrapper implements Continuation, ContinuationListener {
+    boolean isNew;
+    boolean isResumed;
+    boolean isPending = true;
+    Object obj;
     
+    private Message message;
+    private AsyncContext context;
+    private final Request req;
     
-    public JettyContinuationWrapper(HttpServletRequest request, Message m) {
-        continuation = ContinuationSupport.getContinuation(request); 
+    public JettyContinuationWrapper(HttpServletRequest request, 
+                                    HttpServletResponse resp, 
+                                    Message m) {
+        req = (Request)request;
         message = m;
+        isNew = !req.isAsyncStarted();
+        if (isNew) {
+            req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
+                             message.getExchange().getInMessage());
+            context = req.startAsync(req, resp);
+            context.addContinuationListener(this);
+        } else {
+            context = req.getAsyncContext();
+        }
     }
 
     public Object getObject() {
-        Object o = continuation.getObject();
-        if (o instanceof ContinuationInfo) {
-            return ((ContinuationInfo)o).getUserObject();
-        }
-        return o;
+        return obj;
+    }
+    public void setObject(Object userObject) {
+        obj = userObject;
+    }
+
+    public void resume() {
+        isResumed = true;
+        context.dispatch();
     }
 
     public boolean isNew() {
-        return continuation.isNew() || (!continuation.isPending() && !continuation.isResumed());
+        return isNew;
     }
 
     public boolean isPending() {
-        return continuation.isPending();
+        return isPending;
     }
 
     public boolean isResumed() {
-        return continuation.isResumed();
+        return isResumed;
     }
 
     public void reset() {
-        continuation.reset();
     }
 
-    public void resume() {
-        continuation.resume();
-    }
-
-    public void setObject(Object userObject) {
-        
-        ContinuationInfo ci = null;
-        Message m = message;
-        if (m != null && m.getExchange() != null && m.getExchange().getInMessage()
!= null) {
-            m = m.getExchange().getInMessage();
-        }
-        Object obj = continuation.getObject();
-        if (obj instanceof ContinuationInfo) {
-            ci = (ContinuationInfo)obj;
-        } else {
-            ci = new ContinuationInfo(m);
-            ci.setUserObject(obj);
-        }
-        if (message != userObject) {
-            ci.setUserObject(userObject);
-        }
-        continuation.setObject(ci);
-    }
 
     public boolean suspend(long timeout) {
-        
-        Object obj = continuation.getObject();
-        if (obj == null) {
-            continuation.setObject(new ContinuationInfo(message));
-        }
-        try {
-            return continuation.suspend(timeout);
-        } catch (RetryRequest ex) {
-            throw new SuspendedInvocationException(ex);
-        }
+        context.setTimeout(timeout);
+        isNew = false;
+        throw new org.apache.cxf.continuations.SuspendedInvocationException();
     }
     
-    public void done() {
-        ContinuationInfo ci = null;
-        Object obj = continuation.getObject();
-        if (obj instanceof ContinuationInfo) {
-            ci = (ContinuationInfo)obj;
-            continuation.setObject(ci.getUserObject());
-        }
-        continuation.reset();
-    }
-
     protected Message getMessage() {
         Message m = message;
         if (m != null && m.getExchange().getInMessage() != null) {
@@ -118,9 +97,14 @@ public class JettyContinuationWrapper im
         return m;
     }
     
-    public org.eclipse.jetty.continuation.Continuation getContinuation() {
-        return continuation;
+
+    public void onComplete(org.eclipse.jetty.continuation.Continuation continuation) {
+        getMessage().remove(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE);
+        isPending = false;
+    }
+
+    public void onTimeout(org.eclipse.jetty.continuation.Continuation continuation) {
+        context.dispatch();
     }
-    
     
 }

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyContextInspectorTest.java
Mon Jul 19 21:25:51 2010
@@ -21,11 +21,13 @@ package org.apache.cxf.transport.http_je
 
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+
+import org.eclipse.jetty.server.handler.ContextHandler;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.eclipse.jetty.server.handler.ContextHandler;
 
 public class JettyContextInspectorTest extends Assert {
     private static final String CONTEXT_PATH = "/foo/bar";

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Mon Jul 19 21:25:51 2010
@@ -43,7 +43,6 @@ import org.apache.cxf.bus.CXFBusImpl;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
-import org.apache.cxf.continuations.ContinuationInfo;
 import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.endpoint.EndpointResolverRegistry;
 import org.apache.cxf.helpers.CastUtils;
@@ -69,13 +68,13 @@ import org.apache.cxf.ws.addressing.JAXW
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.easymock.classextension.EasyMock;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
+import org.eclipse.jetty.continuation.Continuation;
 import org.eclipse.jetty.http.HttpFields;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Response;
-import org.eclipse.jetty.continuation.Continuation;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
 
 public class JettyHTTPDestinationTest extends Assert {
     protected static final String AUTH_HEADER = "Authorization";
@@ -202,47 +201,6 @@ public class JettyHTTPDestinationTest ex
         }
     }
     
-    @Test
-    public void testRetrieveFromContinuation() throws Exception {
-        
-        Continuation continuation = EasyMock.createMock(Continuation.class);
-        
-        Message m = new MessageImpl();
-        ContinuationInfo ci = new ContinuationInfo(m);
-        Object userObject = new Object();
-        ci.setUserObject(userObject);
-        continuation.getObject();
-        EasyMock.expectLastCall().andReturn(ci);
-        continuation.setObject(ci.getUserObject());
-        EasyMock.expectLastCall();
-        EasyMock.replay(continuation);
-        
-        HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);
-        httpRequest.getAttribute("org.eclipse.jetty.ajax.Continuation");
-        EasyMock.expectLastCall().andReturn(continuation);
-        EasyMock.replay(httpRequest);
-        
-        ServiceInfo serviceInfo = new ServiceInfo();
-        serviceInfo.setName(new QName("bla", "Service"));
-        EndpointInfo ei = new EndpointInfo(serviceInfo, "");
-        ei.setName(new QName("bla", "Port"));
-        
-        transportFactory = new JettyHTTPTransportFactory();
-        transportFactory.setBus(new CXFBusImpl());
-        
-        TestJettyDestination testDestination = 
-            new TestJettyDestination(transportFactory.getBus(), 
-                                     transportFactory, ei);
-        testDestination.finalizeConfig();
-        Message mi = testDestination.retrieveFromContinuation(httpRequest);
-        assertSame("Message is lost", m, mi);
-        EasyMock.verify(continuation);
-        EasyMock.reset(httpRequest);
-        httpRequest.getAttribute("org.eclipse.jetty.ajax.Continuation");
-        EasyMock.expectLastCall().andReturn(null);
-        mi = testDestination.retrieveFromContinuation(httpRequest);
-        assertNotSame("New message expected", m, mi);
-    }
     
     @Test
     public void testContinuationsIgnored() throws Exception {

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineTest.java
Mon Jul 19 21:25:51 2010
@@ -42,15 +42,17 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.management.InstrumentationManager;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.handler.ContextHandler;
 import org.eclipse.jetty.server.nio.SelectChannelConnector;
 import org.eclipse.jetty.server.ssl.SslSocketConnector;
 
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
 public class JettyHTTPServerEngineTest extends Assert {
 
     private Bus bus;

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/invalid-engines.xml
Mon Jul 19 21:25:51 2010
@@ -40,7 +40,7 @@
 	         <sec:clientAuthentication want="true" required="true"/>
 	    </httpj:tlsServerParameters>
 	    <httpj:connector>
-	       <beans:bean class="org.eclipse.jetty.bio.SocketConnector">
+	       <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">
               <beans:property name = "port" value="1234" />
            </beans:bean>
 	    </httpj:connector> 

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
Mon Jul 19 21:25:51 2010
@@ -135,7 +135,7 @@ public class ApplicationContextTest exte
         assertTrue("The engine should support session manager", engine.isSessionSupport());
         assertNotNull("The handlers should not be null", engine.getHandlers());
         assertEquals(1, engine.getHandlers().size());
-        assertTrue("The connector should be instance of org.eclipse.jetty.bio.SocketConnector",
+        assertTrue("The connector should be instance of org.eclipse.jetty.server.bio.SocketConnector",
                    engine.getConnector() instanceof org.eclipse.jetty.server.bio.SocketConnector);
         
         JettyHTTPDestination jd3 = 

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans-props.xml
Mon Jul 19 21:25:51 2010
@@ -84,7 +84,7 @@
 	       <hj:threadingParameters minThreads="${engine.port.nine.one.minThreads}"
 	        maxThreads="${engine.port.nine.one.maxThreads}"/>	      
 	     <hj:connector>
-           <beans:bean class="org.eclipse.jetty.bio.SocketConnector">
+           <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">
               <beans:property name = "port" value="${engine.port.nine.one}" />
            </beans:bean>
          </hj:connector>

Modified: cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
Mon Jul 19 21:25:51 2010
@@ -68,7 +68,7 @@
 	   <hj:engine port="9001">
 	       <hj:threadingParameters minThreads="99" maxThreads="777"/>	      
 	     <hj:connector>
-           <beans:bean class="org.eclipse.jetty.bio.SocketConnector">
+           <beans:bean class="org.eclipse.jetty.server.bio.SocketConnector">
               <beans:property name = "port" value="9001" />
            </beans:bean>
          </hj:connector>

Modified: cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Mon Jul 19 21:25:51 2010
@@ -40,6 +40,7 @@ import java.util.logging.Logger;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.namespace.QName;
@@ -52,6 +53,7 @@ import org.apache.cxf.common.util.Base64
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.Configurable;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.continuations.ContinuationProvider;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.interceptor.Fault;
@@ -80,8 +82,9 @@ import org.apache.cxf.wsdl.EndpointRefer
 /**
  * Common base for HTTP Destination implementations.
  */
-public abstract class AbstractHTTPDestination extends AbstractMultiplexDestination implements
Configurable,
-    Assertor {
+public abstract class AbstractHTTPDestination 
+    extends AbstractMultiplexDestination 
+    implements Configurable, Assertor {
     
     public static final String HTTP_REQUEST = "HTTP.REQUEST";
     public static final String HTTP_RESPONSE = "HTTP.RESPONSE";
@@ -91,7 +94,7 @@ public abstract class AbstractHTTPDestin
         
     public static final String RESPONSE_COMMITED = "http.response.done";
     public static final String REQUEST_REDIRECTED = "http.request.redirected";
-    
+    public static final String CXF_CONTINUATION_MESSAGE = "cxf.continuation.message";
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractHTTPDestination.class);
     
     private static final long serialVersionUID = 1L;
@@ -104,6 +107,7 @@ public abstract class AbstractHTTPDestin
     protected boolean fixedParameterOrder;
     protected boolean multiplexWithAddress;
     protected CertConstraints certConstraints;
+    protected boolean isServlet3;
     
     /**
      * Constructor
@@ -121,6 +125,13 @@ public abstract class AbstractHTTPDestin
         super(b, getTargetReference(getAddressValue(ei, dp), b), ei);  
         bus = b;
         
+        try {
+            ServletRequest.class.getMethod("isAsyncSupported");
+            isServlet3 = true;
+        } catch (Throwable t) {
+            //servlet 2.5 or earlier, no async support
+        }
+        
         initConfig();
     }
     
@@ -271,7 +282,10 @@ public abstract class AbstractHTTPDestin
                                 final ServletContext context, 
                                 final HttpServletRequest req, 
                                 final HttpServletResponse resp) throws IOException {
-
+        setupContinuation(inMessage,
+                          req, 
+                          resp);
+        
         DelegatingInputStream in = new DelegatingInputStream(req.getInputStream());
         inMessage.setContent(DelegatingInputStream.class, in);
         inMessage.setContent(InputStream.class, in);
@@ -337,7 +351,26 @@ public abstract class AbstractHTTPDestin
                 Arrays.asList(new Interceptor[] {CertConstraintsInterceptor.INSTANCE}));
 
     }
-    
+    protected Message retrieveFromContinuation(HttpServletRequest req) {
+        if (!isServlet3) {
+            return null;
+        }
+        return retrieveFromServlet3Async(req);
+    }
+    protected Message retrieveFromServlet3Async(HttpServletRequest req) {
+        if (req.isAsyncStarted()) {
+            return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
+        }
+        return null;
+    }
+    protected void setupContinuation(Message inMessage,
+                      final HttpServletRequest req, 
+                      final HttpServletResponse resp) {
+        if (isServlet3) {
+            inMessage.put(ContinuationProvider.class.getName(), 
+                          new Servlet3ContinuationProvider(req, resp, inMessage));
+        }
+    }
     protected String getBasePath(String contextPath) throws IOException {
         if (StringUtils.isEmpty(endpointInfo.getAddress())) {
             return "";

Added: cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java?rev=965643&view=auto
==============================================================================
--- cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
(added)
+++ cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
Mon Jul 19 21:25:51 2010
@@ -0,0 +1,128 @@
+/**
+ * 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 org.apache.cxf.transport.http;
+
+import java.io.IOException;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncEvent;
+import javax.servlet.AsyncListener;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.continuations.Continuation;
+import org.apache.cxf.continuations.ContinuationProvider;
+import org.apache.cxf.message.Message;
+
+/**
+ * 
+ */
+public class Servlet3ContinuationProvider implements ContinuationProvider {
+    HttpServletRequest req;
+    HttpServletResponse resp; 
+    Message inMessage;
+    
+    public Servlet3ContinuationProvider(HttpServletRequest req,
+                                        HttpServletResponse resp, 
+                                        Message inMessage) {
+        this.inMessage = inMessage;
+        this.req = req;
+        this.resp = resp;
+    }
+
+    /** {@inheritDoc}*/
+    public Continuation getContinuation() {
+        if (inMessage.getExchange().isOneWay()) {
+            return null;
+        }
+
+        return new Servlet3Continuation();
+    }
+    
+    public class Servlet3Continuation implements Continuation, AsyncListener {
+        AsyncContext context;
+        boolean isNew;
+        boolean isResumed;
+        boolean isPending = true;
+        Object obj;
+        
+        public Servlet3Continuation() {
+            isNew = !req.isAsyncStarted();
+            if (isNew) {
+                req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
+                                 inMessage.getExchange().getInMessage());
+                context = req.startAsync(req, resp);
+                context.addListener(this);
+            } else {
+                context = req.getAsyncContext();
+            }
+        }
+        
+        public boolean suspend(long timeout) {
+            context.setTimeout(timeout);
+            isNew = false;
+            throw new org.apache.cxf.continuations.SuspendedInvocationException();
+        }
+        public void redispatch() {
+            context.dispatch();
+        }
+        public void resume() {
+            isResumed = true;
+            redispatch();
+        }
+
+        public void reset() {
+        }
+
+        public boolean isNew() {
+            return isNew;
+        }
+
+        public boolean isPending() {
+            return isPending;
+        }
+
+        public boolean isResumed() {
+            return isResumed;
+        }
+
+        public Object getObject() {
+            return obj;
+        }
+
+        public void setObject(Object o) {
+            obj = o;
+        }
+
+        public void onComplete(AsyncEvent event) throws IOException {
+            inMessage.getExchange().getInMessage()
+                .remove(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE);
+            isPending = false;
+        }
+        public void onError(AsyncEvent event) throws IOException {
+        }
+        public void onStartAsync(AsyncEvent event) throws IOException {
+        }
+        public void onTimeout(AsyncEvent event) throws IOException {
+            redispatch();
+        }
+        
+    }
+}

Propchange: cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/branches/servlet3jetty7/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
(original)
+++ cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
Mon Jul 19 21:25:51 2010
@@ -42,14 +42,15 @@ import org.apache.cxf.io.CachedOutputStr
 import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.webapp.WebAppContext;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-
-
 import org.junit.Test;
-import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.webapp.WebAppContext;
+
 import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.support.GenericApplicationContext;

Modified: cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/continuations/ClientServerWrappedContinuationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/continuations/ClientServerWrappedContinuationTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/continuations/ClientServerWrappedContinuationTest.java
(original)
+++ cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/continuations/ClientServerWrappedContinuationTest.java
Mon Jul 19 21:25:51 2010
@@ -93,7 +93,7 @@ public class ClientServerWrappedContinua
         CountDownLatch startSignal = new CountDownLatch(1);
         CountDownLatch controlDoneSignal = new CountDownLatch(5);
         CountDownLatch helloDoneSignal = new CountDownLatch(5);
-        
+
         executor.execute(new ControlWorker(helloPort, "Fred", startSignal, controlDoneSignal));
         executor.execute(new HelloWorker(helloPort, "Fred", "", startSignal, helloDoneSignal));
         
@@ -111,8 +111,8 @@ public class ClientServerWrappedContinua
         
         startSignal.countDown();
         
-        controlDoneSignal.await(10, TimeUnit.SECONDS);
-        helloDoneSignal.await(10, TimeUnit.SECONDS);
+        controlDoneSignal.await(100, TimeUnit.SECONDS);
+        helloDoneSignal.await(100, TimeUnit.SECONDS);
         executor.shutdownNow();
         assertEquals("Not all invocations have been resumed", 0, controlDoneSignal.getCount());
         assertEquals("Not all invocations have completed", 0, helloDoneSignal.getCount());

Modified: cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
(original)
+++ cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
Mon Jul 19 21:25:51 2010
@@ -37,7 +37,7 @@
  <httpj:engine-factory bus="cxf">
   <httpj:engine port='${testutil.ports.EngineLifecycleTest.1}'>
    <httpj:connector>
-    <bean class="org.eclipse.jetty.bio.SocketConnector">
+    <bean class="org.eclipse.jetty.server.bio.SocketConnector">
      <property name="port" value="${testutil.ports.EngineLifecycleTest.1}"/>
     </bean>
    </httpj:connector>

Modified: cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
(original)
+++ cxf/branches/servlet3jetty7/systests/transports/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
Mon Jul 19 21:25:51 2010
@@ -26,7 +26,6 @@ import org.apache.cxf.testutil.common.Ab
 import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 import org.apache.hello_world_soap_http.GreeterImpl;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.handler.ContextHandler.Context;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -46,7 +45,8 @@ public class NoSpringServletServer exten
             ContextHandlerCollection contexts = new ContextHandlerCollection();
             httpServer.setHandler(contexts);
 
-            ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
+            ServletContextHandler root = new ServletContextHandler(contexts, "/",
+                                                                   ServletContextHandler.SESSIONS);
 
             CXFNonSpringServlet cxf = new CXFNonSpringServlet();
             ServletHolder servlet = new ServletHolder(cxf);

Modified: cxf/branches/servlet3jetty7/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/servlet3jetty7/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=965643&r1=965642&r2=965643&view=diff
==============================================================================
--- cxf/branches/servlet3jetty7/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ cxf/branches/servlet3jetty7/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Mon Jul 19 21:25:51 2010
@@ -43,11 +43,12 @@ import org.apache.cxf.tools.wsdlto.WSDLT
 import org.apache.cxf.tools.wsdlto.frontend.jaxws.validator.UniqueBodyValidator;
 import org.apache.cxf.wsdl11.WSDLRuntimeException;
 
-import org.junit.Test;
-
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.ResourceHandler;
 
+import org.junit.Test;
+
+
 
 public class CodeGenBugTest extends AbstractCodeGenTest {
     



Mime
View raw message