You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/08/02 18:42:01 UTC
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
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());
}