cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1374091 - in /cxf/trunk: rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
Date Thu, 16 Aug 2012 22:33:17 GMT
Author: dkulp
Date: Thu Aug 16 22:33:17 2012
New Revision: 1374091

URL: http://svn.apache.org/viewvc?rev=1374091&view=rev
Log:
Mina can handle multicast fine, it was the one-way that was causing the issue

Modified:
    cxf/trunk/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java

Modified: cxf/trunk/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java?rev=1374091&r1=1374090&r2=1374091&view=diff
==============================================================================
--- cxf/trunk/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
(original)
+++ cxf/trunk/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPConduit.java
Thu Aug 16 22:33:17 2012
@@ -27,7 +27,6 @@ import java.net.DatagramSocket;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.InterfaceAddress;
-import java.net.MulticastSocket;
 import java.net.NetworkInterface;
 import java.net.URI;
 import java.util.Enumeration;
@@ -163,17 +162,13 @@ public class UDPConduit extends Abstract
                     s = s.substring(0, s.indexOf('/'));
                 }
                 int port = Integer.parseInt(s);
-                sendViaBroadcast(message, null, port);
+                sendViaBroadcast(message, port);
             } else {
                 InetSocketAddress isa = null;
                 String hp = ""; 
 
                 isa = new InetSocketAddress(uri.getHost(), uri.getPort());
                 hp = uri.getHost() + ":" + uri.getPort();
-                if (isa.getAddress().isMulticastAddress()) {
-                    sendViaBroadcast(message, isa, uri.getPort());
-                    return;
-                }
                 
                 Queue<ConnectFuture> q = connections.get(hp);
                 ConnectFuture connFuture = null;
@@ -183,10 +178,10 @@ public class UDPConduit extends Abstract
                 if (connFuture == null) {
                     connFuture = connector.connect(isa);
                     connFuture.await();
+                    ((DatagramSessionConfig)connFuture.getSession().getConfig()).setSendBufferSize(64
* 1024);
+                    ((DatagramSessionConfig)connFuture.getSession().getConfig()).setReceiveBufferSize(64
* 1024);
                 }
                 connFuture.getSession().setAttribute(CXF_MESSAGE_ATTR, message);
-                ((DatagramSessionConfig)connFuture.getSession().getConfig()).setSendBufferSize(64
* 1024);
-                ((DatagramSessionConfig)connFuture.getSession().getConfig()).setReceiveBufferSize(64
* 1024);
                 message.setContent(OutputStream.class, new UDPConduitOutputStream(connector,
connFuture, message));
                 message.getExchange().put(ConnectFuture.class, connFuture);
                 message.getExchange().put(HOST_PORT, uri.getHost() + ":" + uri.getPort());
@@ -196,74 +191,51 @@ public class UDPConduit extends Abstract
         }
     }
 
-    private void sendViaBroadcast(Message message, InetSocketAddress isa, int port) {
+    private void sendViaBroadcast(Message message, int port) {
         message.setContent(OutputStream.class, 
-                           new UDPBroadcastOutputStream(port, isa, message));
+                           new UDPBroadcastOutputStream(port, message));
 
     }
 
     private final class UDPBroadcastOutputStream extends LoadingByteArrayOutputStream {
         private final int port;
         private final Message message;
-        private final InetSocketAddress broadcastAddress;
 
-        private UDPBroadcastOutputStream(int port, InetSocketAddress isa, Message message)
{
+        private UDPBroadcastOutputStream(int port, Message message) {
             this.port = port;
             this.message = message;
-            this.broadcastAddress = isa;
         }
 
         public void close() throws IOException {
             super.close();
             DatagramSocket socket;
-            if (broadcastAddress == null) {
-                socket = new DatagramSocket();
-                socket.setSendBufferSize(this.size());
-                socket.setReceiveBufferSize(64 * 1024);
-                socket.setBroadcast(true);
-                Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
-                while (interfaces.hasMoreElements()) {
-                    NetworkInterface networkInterface = interfaces.nextElement();
-                    if (!networkInterface.isUp() || networkInterface.isLoopback()) {
-                        continue;  
+            socket = new DatagramSocket();
+            socket.setSendBufferSize(this.size());
+            socket.setReceiveBufferSize(64 * 1024);
+            socket.setBroadcast(true);
+            Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+            while (interfaces.hasMoreElements()) {
+                NetworkInterface networkInterface = interfaces.nextElement();
+                if (!networkInterface.isUp() || networkInterface.isLoopback()) {
+                    continue;  
+                }
+                for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
+                    InetAddress broadcast = interfaceAddress.getBroadcast();
+                    if (broadcast == null) {
+                        continue;
                     }
-                    for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
-                        InetAddress broadcast = interfaceAddress.getBroadcast();
-                        if (broadcast == null) {
-                            continue;
-                        }
-                        DatagramPacket sendPacket = new DatagramPacket(this.getRawBytes(),

-                                                                       0,
-                                                                       this.size(),
-                                                                       broadcast, 
-                                                                       port);
-                        
-                        try {
-                            socket.send(sendPacket);
-                        } catch (Exception e) {
-                            //ignore
-                        }
+                    DatagramPacket sendPacket = new DatagramPacket(this.getRawBytes(), 
+                                                                   0,
+                                                                   this.size(),
+                                                                   broadcast, 
+                                                                   port);
+                    
+                    try {
+                        socket.send(sendPacket);
+                    } catch (Exception e) {
+                        //ignore
                     }
                 }
-            } else {
-                socket = new MulticastSocket(null);
-                socket.setReuseAddress(true);
-                socket.setSendBufferSize(64 * 1024);
-                socket.setReceiveBufferSize(64 * 1024);
-                socket.bind(null);
-                ((MulticastSocket)socket).setTimeToLive(1);
-
-                DatagramPacket sendPacket = new DatagramPacket(this.getRawBytes(), 
-                                                               0,
-                                                               this.size(),
-                                                               broadcastAddress.getAddress(),
-                                                               port);
-                
-                try {
-                    socket.send(sendPacket);
-                } catch (Exception e) {
-                    //ignore
-                }
             }
             
             if (!message.getExchange().isOneWay()) {
@@ -330,9 +302,6 @@ public class UDPConduit extends Abstract
             }
             closed = true;
             send();
-            if (message.getExchange().isOneWay()) {
-                future.getSession().close(true);
-            }
         }
     }
     

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java?rev=1374091&r1=1374090&r2=1374091&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
Thu Aug 16 22:33:17 2012
@@ -23,7 +23,6 @@ import javax.jws.WebMethod;
 import javax.jws.WebService;
 import javax.xml.ws.Endpoint;
 
-import org.apache.cxf.ws.discovery.wsdl.HelloType;
 
 /**
  * 
@@ -38,11 +37,13 @@ public final class WSDiscoveryClientTest
     public static void main(String[] arg) throws Exception {
         Endpoint ep = Endpoint.publish("http://localhost:51919/Foo/Snarf", new FooImpl());
         WSDiscoveryClient c = new WSDiscoveryClient();
-        HelloType h = c.register(ep.getEndpointReference());
+        c.register(ep.getEndpointReference());
         
-        Thread.sleep(5000);
+        System.out.println("1");
+        Thread.sleep(1000);
         //c.unregister(h);
         c.unregister(ep.getEndpointReference());
+        System.out.println("2");
         c.close();
         
         System.exit(0);



Mime
View raw message