cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1509622 - in /cxf/branches/2.7.x-fixes: ./ rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Date Fri, 02 Aug 2013 11:03:36 GMT
Author: sergeyb
Date: Fri Aug  2 11:03:35 2013
New Revision: 1509622

URL: http://svn.apache.org/r1509622
Log:
Merged revisions 1509445,1509613 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1509445 | dkulp | 2013-08-01 22:49:54 +0100 (Thu, 01 Aug 2013) | 1 line
  
  Get the localtransport working with requests that don't have a body. (example: GET)
........
  r1509613 | sergeyb | 2013-08-02 11:47:40 +0100 (Fri, 02 Aug 2013) | 1 line
  
  Renaming one of JAXRSLocatorTransport tests, now both piped and dispact modes are tested
for GET
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1509445,1509613

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=1509622&r1=1509621&r2=1509622&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
Fri Aug  2 11:03:35 2013
@@ -40,6 +40,64 @@ import org.apache.cxf.workqueue.Synchron
 
 public class LocalConduit extends AbstractConduit {
 
+    private final class LocalConduitOutputStream extends AbstractWrappedOutputStream {
+        private final LocalConduit conduit;
+        private final Exchange exchange;
+        private final Message message;
+
+        private LocalConduitOutputStream(LocalConduit conduit, Exchange exchange, Message
message) {
+            this.conduit = conduit;
+            this.exchange = exchange;
+            this.message = message;
+        }
+
+        public void close() throws IOException {
+            if (!written) {
+                dispatchToService(true);
+            }
+            super.close();
+        }
+
+        protected void onFirstWrite() throws IOException {
+            dispatchToService(false);
+        }
+        protected void dispatchToService(boolean empty) throws IOException {
+            final MessageImpl inMsg = new MessageImpl();
+            transportFactory.copy(message, inMsg);
+            
+            if (!empty) {
+                final PipedInputStream stream = new PipedInputStream();
+                wrappedStream = new PipedOutputStream(stream);
+
+                inMsg.setContent(InputStream.class, stream);
+            }
+            inMsg.setDestination(destination);
+            inMsg.put(IN_CONDUIT, conduit);
+
+            final Runnable receiver = new Runnable() {
+                public void run() {                            
+                    ExchangeImpl ex = new ExchangeImpl();
+                    ex.setInMessage(inMsg);
+                    inMsg.setExchange(ex);
+                    ex.put(IN_EXCHANGE, exchange);
+                    destination.getMessageObserver().onMessage(inMsg);
+                }
+            };
+            Executor ex = message.getExchange() != null
+                ? message.getExchange().get(Executor.class) : null;
+            if (ex == null || SynchronousExecutor.isA(ex)) {
+                ex = transportFactory.getExecutor();
+                if (ex != null) {
+                    ex.execute(receiver);
+                } else {
+                    new Thread(receiver).start();
+                }
+            } else {
+                ex.execute(receiver);
+            }
+        }
+    }
+
     public static final String IN_CONDUIT = LocalConduit.class.getName() + ".inConduit";
     public static final String RESPONSE_CONDUIT = LocalConduit.class.getName() + ".inConduit";
     public static final String IN_EXCHANGE = LocalConduit.class.getName() + ".inExchange";
@@ -124,40 +182,7 @@ public class LocalConduit extends Abstra
         
         
         AbstractWrappedOutputStream cout 
-            = new AbstractWrappedOutputStream() {
-                protected void onFirstWrite() throws IOException {
-                    final PipedInputStream stream = new PipedInputStream();
-                    wrappedStream = new PipedOutputStream(stream);
-
-                    final MessageImpl inMsg = new MessageImpl();
-                    transportFactory.copy(message, inMsg); 
-
-                    inMsg.setContent(InputStream.class, stream);
-                    inMsg.setDestination(destination);
-                    inMsg.put(IN_CONDUIT, conduit);
-
-                    final Runnable receiver = new Runnable() {
-                        public void run() {                            
-                            ExchangeImpl ex = new ExchangeImpl();
-                            ex.setInMessage(inMsg);
-                            ex.put(IN_EXCHANGE, exchange);
-                            destination.getMessageObserver().onMessage(inMsg);
-                        }
-                    };
-                    Executor ex = message.getExchange() != null
-                        ? message.getExchange().get(Executor.class) : null;
-                    if (ex == null || SynchronousExecutor.isA(ex)) {
-                        ex = transportFactory.getExecutor();
-                        if (ex != null) {
-                            ex.execute(receiver);
-                        } else {
-                            new Thread(receiver).start();
-                        }
-                    } else {
-                        ex.execute(receiver);
-                    }
-                }
-            };
+            = new LocalConduitOutputStream(conduit, exchange, message);
         message.setContent(OutputStream.class, cout);
     }
     

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1509622&r1=1509621&r2=1509622&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Fri Aug  2 11:03:35 2013
@@ -59,12 +59,9 @@ public class JAXRSLocalTransportTest ext
     }
     
     @Test
-    public void testProxyDirectDispatchGet() throws Exception {
+    public void testProxyPipedDispatchGet() throws Exception {
         BookStore localProxy = 
             JAXRSClientFactory.create("local://books", BookStore.class);
-        
-        WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,
Boolean.TRUE);
-        
         Book book = localProxy.getBook("123");
         assertEquals(123L, book.getId());
     }



Mime
View raw message