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 04BF9105C5 for ; Thu, 1 Aug 2013 21:50:20 +0000 (UTC) Received: (qmail 34775 invoked by uid 500); 1 Aug 2013 21:50:19 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 34690 invoked by uid 500); 1 Aug 2013 21:50:19 -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 34677 invoked by uid 99); 1 Aug 2013 21:50:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2013 21:50:19 +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; Thu, 01 Aug 2013 21:50:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D7126238896F; Thu, 1 Aug 2013 21:49:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1509445 - in /cxf/trunk: 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: Thu, 01 Aug 2013 21:49:54 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130801214954.D7126238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Thu Aug 1 21:49:54 2013 New Revision: 1509445 URL: http://svn.apache.org/r1509445 Log: Get the localtransport working with requests that don't have a body. (example: GET) Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=1509445&r1=1509444&r2=1509445&view=diff ============================================================================== --- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java (original) +++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java Thu Aug 1 21:49:54 2013 @@ -41,6 +41,65 @@ 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.put(Bus.class, destination.getBus()); + 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(destination.getBus()); + 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,42 +183,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.put(Bus.class, destination.getBus()); - 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(destination.getBus()); - 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/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1509445&r1=1509444&r2=1509445&view=diff ============================================================================== --- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java (original) +++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java Thu Aug 1 21:49:54 2013 @@ -63,7 +63,7 @@ public class JAXRSLocalTransportTest ext BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class); - WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); + //WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); Book book = localProxy.getBook("123"); assertEquals(123L, book.getId());