cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r583885 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/transports/local/src/main/java/org/apache/cxf/transport/local/ rt/transports/local/src/test/java/org/apache/cxf/transport/local/ systests/src/test/java/org/apache/cxf/systest/local_tra...
Date Thu, 11 Oct 2007 17:11:23 GMT
Author: dkulp
Date: Thu Oct 11 10:11:22 2007
New Revision: 583885

URL: http://svn.apache.org/viewvc?rev=583885&view=rev
Log:
Merged revisions 583696 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r583696 | ningjiang | 2007-10-11 02:39:41 -0400 (Thu, 11 Oct 2007) | 1 line
  
  CXF-1107 Fixed LocalTransport DirectDispatch NPE issue 
........

Added:
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/local_transport/
      - copied from r583696, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/local_transport/
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/local_transport/DirectDispatchClientTest.java
      - copied unchanged from r583696, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/local_transport/DirectDispatchClientTest.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/local_transport/Server.java
      - copied unchanged from r583696, incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/local_transport/Server.java
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
    incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java

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

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=583885&r1=583884&r2=583885&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
Thu Oct 11 10:11:22 2007
@@ -58,6 +58,11 @@
     public void prepare(final Message message) throws IOException {
         if (!Boolean.TRUE.equals(message.get(DIRECT_DISPATCH))) {
             dispatchViaPipe(message);
+        } else {
+            // prepare the stream here
+            PipedInputStream stream = new PipedInputStream();
+            message.setContent(InputStream.class, stream);
+            message.setContent(OutputStream.class, new PipedOutputStream(stream));
         }
     }
 
@@ -87,6 +92,7 @@
         ExchangeImpl ex = new ExchangeImpl();
         ex.setInMessage(copy);
         ex.put(IN_EXCHANGE, message.getExchange());
+        ex.put(LocalConduit.DIRECT_DISPATCH, true);
         ex.setDestination(destination);
         
         destination.getMessageObserver().onMessage(copy);

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java?rev=583885&r1=583884&r2=583885&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
Thu Oct 11 10:11:22 2007
@@ -73,8 +73,8 @@
             this.conduit = conduit;
         }
 
-        public void prepare(final Message message) throws IOException {
-            if (!Boolean.TRUE.equals(message.get(LocalConduit.DIRECT_DISPATCH))) {
+        public void prepare(final Message message) throws IOException {            
+            if (!Boolean.TRUE.equals(message.getExchange().get(LocalConduit.DIRECT_DISPATCH)))
{
                 final Exchange exchange = (Exchange)message.getExchange().get(LocalConduit.IN_EXCHANGE);
                 
                 final PipedInputStream stream = new PipedInputStream();
@@ -90,24 +90,27 @@
                 };
     
                 PipedOutputStream outStream = new PipedOutputStream(stream);
-                message.setContent(OutputStream.class, outStream);
-    
+                message.setContent(OutputStream.class, outStream);    
                 new Thread(receiver).start();
+                
+            } else {
+                PipedInputStream stream = new PipedInputStream();
+                message.setContent(InputStream.class, stream);
+                message.setContent(OutputStream.class, new PipedOutputStream(stream));
             }
         }
 
         @Override
         public void close(Message message) throws IOException {
-            if (Boolean.TRUE.equals(message.get(LocalConduit.DIRECT_DISPATCH))) {
+            if (Boolean.TRUE.equals(message.getExchange().get(LocalConduit.DIRECT_DISPATCH)))
{
                 final Exchange exchange = (Exchange)message.getExchange().get(LocalConduit.IN_EXCHANGE);
                 MessageImpl copy = new MessageImpl();
                 copy.putAll(message);
                 MessageImpl.copyContent(message, copy);
                 
-                if (exchange.getInMessage() == null) {
+                if (exchange != null && exchange.getInMessage() == null) {
                     exchange.setInMessage(copy);
-                }
-                
+                }                
                 conduit.getMessageObserver().onMessage(copy);
                 return;
             }

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java?rev=583885&r1=583884&r2=583885&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
Thu Oct 11 10:11:22 2007
@@ -66,7 +66,7 @@
         setTransportIds(ids);
         
         messageFilterProperties = new HashSet<String>();
-        messageFilterProperties.add(Message.REQUESTOR_ROLE);
+        messageFilterProperties.add(Message.REQUESTOR_ROLE);        
     }
     
     @Resource(name = "bus")

Modified: incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java?rev=583885&r1=583884&r2=583885&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/transports/local/src/test/java/org/apache/cxf/transport/local/LocalTransportFactoryTest.java
Thu Oct 11 10:11:22 2007
@@ -19,18 +19,17 @@
 
 package org.apache.cxf.transport.local;
 
-import java.io.ByteArrayInputStream;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
-import org.apache.cxf.transport.Destination;
+
 import org.apache.cxf.transport.MessageObserver;
 import org.junit.Assert;
 import org.junit.Test;
@@ -38,35 +37,16 @@
 
 public class LocalTransportFactoryTest extends Assert {
     @Test
-    public void testTransportFactory() throws Exception {
-        LocalTransportFactory factory = new LocalTransportFactory();
-        
-        EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
-        AddressType a = new AddressType();
-        a.setLocation("http://localhost/test");
-        ei.addExtensor(a);
-
-        Destination d = factory.getDestination(ei);
-        d.setMessageObserver(new EchoObserver());
-        
-        
-        Conduit conduit = factory.getConduit(ei);
-        TestMessageObserver obs = new TestMessageObserver();
-        conduit.setMessageObserver(obs);
-        
-        Message m = new MessageImpl();
-        conduit.prepare(m);
-
-        OutputStream out = m.getContent(OutputStream.class);
-        out.write("hello".getBytes());
-        out.close();
-
-        
-        assertEquals("hello", obs.getResponseStream().toString());
+    public void testLocalTransportWithSeperateThread() throws Exception {
+        testInvocation(false);
     }
 
     @Test
-    public void testDirectInvocation() throws Exception {
+    public void testLocalTranpsortWithDirectDispatch() throws Exception {
+        testInvocation(true);
+    }
+    
+    private void testInvocation(boolean isDirectDispatch) throws Exception {
         LocalTransportFactory factory = new LocalTransportFactory();
         
         EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
@@ -83,10 +63,15 @@
         conduit.setMessageObserver(obs);
         
         MessageImpl m = new MessageImpl();
-        m.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
+        if (isDirectDispatch) {
+            m.put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
+        }    
         m.setDestination(d);
-        m.setContent(InputStream.class, new ByteArrayInputStream("hello".getBytes()));
         conduit.prepare(m);
+        
+        OutputStream out = m.getContent(OutputStream.class);
+        out.write("hello".getBytes());
+        out.close();
         conduit.close(m);
 
         assertEquals("hello", obs.getResponseStream().toString());
@@ -95,20 +80,19 @@
 
         public void onMessage(Message message) {
             try {
+                message.getExchange().setInMessage(message);
                 Conduit backChannel = message.getDestination().getBackChannel(message, null,
null);
-                message.remove(LocalConduit.DIRECT_DISPATCH);
                 
+                InputStream in = message.getContent(InputStream.class);
+                assertNotNull(in);   
                 backChannel.prepare(message);
-
                 OutputStream out = message.getContent(OutputStream.class);
-                assertNotNull(out);
-                InputStream in = message.getContent(InputStream.class);
-                assertNotNull(in);
-                
+                assertNotNull(out);                             
                 copy(in, out, 1024);
-
                 out.close();
-                in.close();
+                in.close();                
+                backChannel.close(message);
+                
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -135,6 +119,7 @@
     class TestMessageObserver implements MessageObserver {
         ByteArrayOutputStream response = new ByteArrayOutputStream();
         boolean written;
+        Message inMessage;
         
         public synchronized ByteArrayOutputStream getResponseStream() throws Exception {
             if (!written) {
@@ -148,6 +133,7 @@
             try {
                 message.remove(LocalConduit.DIRECT_DISPATCH);
                 copy(message.getContent(InputStream.class), response, 1024);
+                inMessage = message;
             } catch (IOException e) {
                 e.printStackTrace();
                 fail();



Mime
View raw message