cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1379037 - in /cxf/trunk: rt/transports/http/src/main/java/org/apache/cxf/transport/http/ systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/
Date Thu, 30 Aug 2012 17:51:59 GMT
Author: dkulp
Date: Thu Aug 30 17:51:59 2012
New Revision: 1379037

URL: http://svn.apache.org/viewvc?rev=1379037&view=rev
Log:
More updates to make it easier to wire in the Async based conduit
With the async client, we HAVE to put the response on the workqueue or threads will block.

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
    cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1379037&r1=1379036&r2=1379037&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Thu Aug 30 17:51:59 2012
@@ -1109,7 +1109,7 @@ public abstract class HTTPConduit 
         protected abstract void updateCookiesBeforeRetransmit() throws IOException;
 
         
-        protected void handleResponseOnWorkqueue(boolean allowCurrentThread) throws IOException
{
+        protected void handleResponseOnWorkqueue(boolean allowCurrentThread, boolean forceWQ)
throws IOException {
             Runnable runnable = new Runnable() {
                 public void run() {
                     try {
@@ -1125,7 +1125,18 @@ public abstract class HTTPConduit 
             HTTPClientPolicy policy = getClient(outMessage);
             try {
                 Executor ex = outMessage.getExchange().get(Executor.class);
-                if (ex == null) {
+                if (forceWQ && ex != null) {
+                    final Executor ex2 = ex;
+                    final Runnable origRunnable = runnable;
+                    runnable = new Runnable() {
+                        public void run() {
+                            outMessage.getExchange().put(Executor.class.getName() 
+                                                         + ".USING_SPECIFIED", Boolean.TRUE);
+                            ex2.execute(origRunnable);
+                        }
+                    };
+                }
+                if (ex == null || forceWQ) {
                     WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
                         .getExtension(WorkQueueManager.class);
                     AutomaticWorkQueue qu = mgr.getNamedWorkQueue("http-conduit");

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java?rev=1379037&r1=1379036&r2=1379037&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPTransportFactory.java
Thu Aug 30 17:51:59 2012
@@ -62,6 +62,14 @@ public class HTTPTransportFactory 
     extends AbstractTransportFactory 
     implements WSDLEndpointFactory, ConduitInitiator, DestinationFactory {
     
+
+    public interface HTTPConduitFactory {
+        HTTPConduit createConduit(HTTPTransportFactory f,
+                                  EndpointInfo localInfo,
+                                  EndpointReferenceType target) throws IOException;
+    }
+        
+    
     public static final List<String> DEFAULT_NAMESPACES 
         = Arrays.asList(
             "http://cxf.apache.org/transports/http",
@@ -247,7 +255,16 @@ public class HTTPTransportFactory 
             EndpointInfo endpointInfo,
             EndpointReferenceType target
     ) throws IOException {
-        HTTPConduit conduit = new URLConnectionHTTPConduit(bus, endpointInfo, target);
+        
+        HTTPConduitFactory factory = findFactory(endpointInfo);
+        HTTPConduit conduit = null;
+        if (factory != null) {
+            conduit = factory.createConduit(this, endpointInfo, target);
+        }
+        if (conduit == null) {
+            conduit = new URLConnectionHTTPConduit(bus, endpointInfo, target);
+        }
+
         // Spring configure the conduit.  
         String address = conduit.getAddress();
         if (address != null && address.indexOf('?') != -1) {
@@ -262,6 +279,13 @@ public class HTTPTransportFactory 
         return conduit;
     }
     
+    protected HTTPConduitFactory findFactory(EndpointInfo endpointInfo) {
+        HTTPConduitFactory f = endpointInfo.getProperty(HTTPConduitFactory.class.getName(),
HTTPConduitFactory.class);
+        if (f == null) {
+            f = bus.getExtension(HTTPConduitFactory.class);
+        }
+        return f;
+    }
     public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
         if (endpointInfo == null) {
             throw new IllegalArgumentException("EndpointInfo cannot be null");

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java?rev=1379037&r1=1379036&r2=1379037&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/URLConnectionHTTPConduit.java
Thu Aug 30 17:51:59 2012
@@ -200,7 +200,7 @@ public class URLConnectionHTTPConduit ex
             cookies.readFromHeaders(h);
         }
         protected void handleResponseAsync() throws IOException {
-            handleResponseOnWorkqueue(true);
+            handleResponseOnWorkqueue(true, false);
         }
         protected void updateCookiesBeforeRetransmit() {
             Headers h = new Headers();

Modified: cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=1379037&r1=1379036&r2=1379037&view=diff
==============================================================================
--- cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Thu Aug 30 17:51:59 2012
@@ -36,6 +36,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
@@ -551,16 +552,16 @@ public class ClientServerTest extends Ab
         
         class TestExecutor implements Executor {
             
-            private int count;
+            private AtomicInteger count = new AtomicInteger();
             
             public void execute(Runnable command) {
-                count++;
-                LOG.info("asyn call time " + count);
+                int c = count.incrementAndGet();
+                LOG.info("asyn call time " + c);
                 command.run();
             }
             
             public int getCount() {
-                return count;
+                return count.get();
             }
         }
         Executor executor = new TestExecutor();



Mime
View raw message