You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/04/06 22:36:41 UTC
svn commit: r1310575 - in /cxf/trunk/rt/transports:
http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/
http-jetty/src/main/resources/OSGI-INF/blueprint/
http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/ http/src/mai...
Author: dkulp
Date: Fri Apr 6 20:36:41 2012
New Revision: 1310575
URL: http://svn.apache.org/viewvc?rev=1310575&view=rev
Log:
Allow supporting the HTTP Continuations when running with pax-web in
OSGi where it's servlet 2.5, but using the Jetty requests
Added:
cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java (with props)
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java (with props)
Modified:
cxf/trunk/rt/transports/http-jetty/src/main/resources/OSGI-INF/blueprint/httpj.xml
cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Added: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java?rev=1310575&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java (added)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java Fri Apr 6 20:36:41 2012
@@ -0,0 +1,49 @@
+/**
+ * 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_jetty.continuations;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.continuations.ContinuationProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.ContinuationProviderFactory;
+import org.eclipse.jetty.server.Request;
+
+/**
+ *
+ */
+public class JettyContinuationProviderFactory implements ContinuationProviderFactory {
+
+ public ContinuationProvider createContinuationProvider(Message inMessage,
+ HttpServletRequest req,
+ HttpServletResponse resp) {
+ if (req instanceof Request && ((Request)req).isAsyncSupported()) {
+ return new JettyContinuationProvider(req, resp, inMessage);
+ }
+ return null;
+ }
+
+ public Message retrieveFromContinuation(HttpServletRequest req) {
+ return (Message)req.getAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE);
+ }
+
+}
Propchange: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/trunk/rt/transports/http-jetty/src/main/resources/OSGI-INF/blueprint/httpj.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/resources/OSGI-INF/blueprint/httpj.xml?rev=1310575&r1=1310574&r2=1310575&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/resources/OSGI-INF/blueprint/httpj.xml (original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/resources/OSGI-INF/blueprint/httpj.xml Fri Apr 6 20:36:41 2012
@@ -26,4 +26,8 @@
</service-properties>
<bean class="org.apache.cxf.transport.http_jetty.blueprint.HTTPJettyTransportNamespaceHandler"/>
</service>
+
+ <service interface="org.apache.cxf.transport.http.ContinuationProviderFactory">
+ <bean class="org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory"/>
+ </service>
</blueprint>
\ No newline at end of file
Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=1310575&r1=1310574&r2=1310575&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java (original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java Fri Apr 6 20:36:41 2012
@@ -61,6 +61,7 @@ import org.apache.cxf.transport.ConduitI
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.ContinuationProviderFactory;
import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http.HTTPTransportFactory;
import org.apache.cxf.transports.http.QueryHandler;
@@ -571,6 +572,8 @@ public class JettyHTTPDestinationTest ex
bus = EasyMock.createMock(Bus.class);
bus.getExtension(EndpointResolverRegistry.class);
EasyMock.expectLastCall().andReturn(null);
+ bus.getExtension(ContinuationProviderFactory.class);
+ EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.getExtension(PolicyDataEngine.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.hasExtensionByName("org.apache.cxf.ws.policy.PolicyEngine");
Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1310575&r1=1310574&r2=1310575&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Fri Apr 6 20:36:41 2012
@@ -114,6 +114,7 @@ public abstract class AbstractHTTPDestin
protected boolean multiplexWithAddress;
protected CertConstraints certConstraints;
protected boolean isServlet3;
+ protected ContinuationProviderFactory cproviderFactory;
/**
* Constructor
@@ -373,6 +374,9 @@ public abstract class AbstractHTTPDestin
}
protected Message retrieveFromContinuation(HttpServletRequest req) {
if (!isServlet3) {
+ if (cproviderFactory != null) {
+ return cproviderFactory.retrieveFromContinuation(req);
+ }
return null;
}
return retrieveFromServlet3Async(req);
@@ -387,12 +391,18 @@ public abstract class AbstractHTTPDestin
return null;
}
- protected void setupContinuation(Message inMessage, final HttpServletRequest req,
+ protected void setupContinuation(Message inMessage,
+ final HttpServletRequest req,
final HttpServletResponse resp) {
try {
if (isServlet3 && req.isAsyncSupported()) {
inMessage.put(ContinuationProvider.class.getName(),
new Servlet3ContinuationProvider(req, resp, inMessage));
+ } else if (cproviderFactory != null) {
+ ContinuationProvider p = cproviderFactory.createContinuationProvider(inMessage, req, resp);
+ if (p != null) {
+ inMessage.put(ContinuationProvider.class.getName(), p);
+ }
}
} catch (Throwable ex) {
// the request may not implement the Servlet3 API
@@ -451,6 +461,8 @@ public abstract class AbstractHTTPDestin
server = endpointInfo.getTraversedExtensor(
new HTTPServerPolicy(), HTTPServerPolicy.class);
}
+
+ cproviderFactory = bus.getExtension(ContinuationProviderFactory.class);
}
/**
Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java?rev=1310575&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java (added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java Fri Apr 6 20:36:41 2012
@@ -0,0 +1,50 @@
+/**
+ * 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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.continuations.ContinuationProvider;
+import org.apache.cxf.message.Message;
+
+public interface ContinuationProviderFactory {
+
+ /**
+ * If this factory can support the given req/resp and
+ * provide a ContinuationProvider, it should create one
+ * and return it.
+ *
+ * @param inMessage
+ * @param req
+ * @param resp
+ * @return
+ */
+ ContinuationProvider createContinuationProvider(Message inMessage,
+ HttpServletRequest req,
+ HttpServletResponse resp);
+
+ /**
+ * If the request already has a message associated with it, return it
+ * @param req
+ * @return
+ */
+ Message retrieveFromContinuation(HttpServletRequest req);
+
+}
Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ContinuationProviderFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date