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/08/31 19:51:21 UTC
svn commit: r1379528 - in
/cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient:
AsyncHTTPConduit.java AsyncHTTPConduitFactory.java
Author: dkulp
Date: Fri Aug 31 17:51:21 2012
New Revision: 1379528
URL: http://svn.apache.org/viewvc?rev=1379528&view=rev
Log:
Make sure conduits degrade to URLConnection of if the async stuff is shutdown.
Allows systests/ws-rm tests to pass.
Modified:
cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
Modified: cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java?rev=1379528&r1=1379527&r2=1379528&view=diff
==============================================================================
--- cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java (original)
+++ cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java Fri Aug 31 17:51:21 2012
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Map;
import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.SystemPropertyAction;
import org.apache.cxf.helpers.HttpHeaderHelper;
import org.apache.cxf.io.CacheAndWriteOutputStream;
import org.apache.cxf.message.Message;
@@ -57,6 +58,17 @@ import org.apache.http.protocol.BasicHtt
*/
public class AsyncHTTPConduit extends URLConnectionHTTPConduit {
public static final String USE_ASYNC = "use.async.http.conduit";
+
+ private static final Boolean DEFAULT_FORCE_ASYNC;
+ static {
+ String s = SystemPropertyAction.getPropertyOrNull(USE_ASYNC);
+ Boolean force = null;
+ if (s != null) {
+ force = Boolean.parseBoolean(s);
+ }
+ DEFAULT_FORCE_ASYNC = force;
+ }
+
AsyncHTTPConduitFactory factory;
@@ -67,6 +79,11 @@ public class AsyncHTTPConduit extends UR
}
protected void setupConnection(Message message, URI uri, HTTPClientPolicy csPolicy) throws IOException {
+ if (factory.isShutdown()) {
+ message.put(USE_ASYNC, Boolean.FALSE);
+ super.setupConnection(message, uri, csPolicy);
+ return;
+ }
String s = uri.getScheme();
if (!"http".equals(s) && !"https".equals(s)) {
throw new MalformedURLException("unknown protocol: " + s);
@@ -74,9 +91,16 @@ public class AsyncHTTPConduit extends UR
Object o = message.getContextualProperty(USE_ASYNC);
if (o == null) {
+ o = DEFAULT_FORCE_ASYNC;
+ }
+ if (o == null) {
//o = !message.getExchange().isSynchronous();
o = "http".equals(s);
}
+ if ("https".equals(s)) {
+ //https doesn't work yet
+ o = Boolean.FALSE;
+ }
if (!MessageUtils.isTrue(o)) {
message.put(USE_ASYNC, Boolean.FALSE);
super.setupConnection(message, uri, csPolicy);
Modified: cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java?rev=1379528&r1=1379527&r2=1379528&view=diff
==============================================================================
--- cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java (original)
+++ cxf/sandbox/dkulp_async_clients/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java Fri Aug 31 17:51:21 2012
@@ -57,6 +57,7 @@ import org.apache.http.protocol.RequestT
public class AsyncHTTPConduitFactory implements BusLifeCycleListener, HTTPConduitFactory {
CXFAsyncRequester requester;
CXFConnectionManager connManager;
+ boolean isShutdown;
public AsyncHTTPConduitFactory() {
super();
@@ -65,9 +66,16 @@ public class AsyncHTTPConduitFactory imp
addListener(b);
}
+ public boolean isShutdown() {
+ return isShutdown;
+ }
+
@Override
public HTTPConduit createConduit(HTTPTransportFactory f, EndpointInfo localInfo,
EndpointReferenceType target) throws IOException {
+ if (isShutdown) {
+ return null;
+ }
return new AsyncHTTPConduit(f.getBus(), localInfo, target, this);
}
@@ -85,6 +93,8 @@ public class AsyncHTTPConduitFactory imp
e.printStackTrace();
}
}
+ connManager = null;
+ isShutdown = true;
}
public void postShutdown() {
}