Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 720D110BB1 for ; Fri, 2 Aug 2013 16:42:27 +0000 (UTC) Received: (qmail 75775 invoked by uid 500); 2 Aug 2013 16:42:26 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 75336 invoked by uid 500); 2 Aug 2013 16:42:26 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 74952 invoked by uid 99); 2 Aug 2013 16:42:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Aug 2013 16:42:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Aug 2013 16:42:22 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 630EE23888E2; Fri, 2 Aug 2013 16:42:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1509769 - in /cxf/branches/2.6.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 16:42:01 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130802164201.630EE23888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Fri Aug 2 16:42:00 2013 New Revision: 1509769 URL: http://svn.apache.org/r1509769 Log: Merged revisions 1509622 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes ................ r1509622 | sergeyb | 2013-08-02 12:03:35 +0100 (Fri, 02 Aug 2013) | 13 lines 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.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1509622 Merged /cxf/trunk:r1509445,1509613 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=1509769&r1=1509768&r2=1509769&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java (original) +++ cxf/branches/2.6.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java Fri Aug 2 16:42:00 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.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1509769&r1=1509768&r2=1509769&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java (original) +++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java Fri Aug 2 16:42:00 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()); }