You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/10/21 22:17:25 UTC

[1/3] git commit: Try to find a more usable interface as the "default" may not support multicast

Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 1a96465f1 -> 43f6a421a


Try to find a more usable interface as the "default" may not support multicast


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/1c876942
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/1c876942
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/1c876942

Branch: refs/heads/3.0.x-fixes
Commit: 1c8769426d0f23d1f8c217c89a06d955d31ea286
Parents: 1a96465
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Oct 20 13:11:00 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Oct 21 16:16:09 2014 -0400

----------------------------------------------------------------------
 .../cxf/ws/discovery/WSDiscoveryClientTest.java | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1c876942/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
----------------------------------------------------------------------
diff --git a/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java b/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
index 2a548aa..e7f7bba 100644
--- a/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
+++ b/services/ws-discovery/ws-discovery-api/src/test/java/org/apache/cxf/ws/discovery/WSDiscoveryClientTest.java
@@ -22,10 +22,13 @@ package org.apache.cxf.ws.discovery;
 import java.io.InputStream;
 import java.net.DatagramPacket;
 import java.net.InetAddress;
+import java.net.InterfaceAddress;
 import java.net.MulticastSocket;
 import java.net.NetworkInterface;
 import java.net.SocketAddress;
+import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.List;
 
 import javax.jws.WebMethod;
 import javax.jws.WebService;
@@ -55,6 +58,24 @@ import org.junit.Test;
 public final class WSDiscoveryClientTest {
     public static final String PORT = TestUtil.getPortNumber(WSDiscoveryClientTest.class);
    
+    static NetworkInterface findIpv4Interface() throws Exception {
+        Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
+        List<NetworkInterface> possibles = new ArrayList<NetworkInterface>();
+        while (ifcs.hasMoreElements()) {
+            NetworkInterface ni = ifcs.nextElement();
+            if (ni.supportsMulticast()
+                && ni.isUp()) {
+                for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
+                    if (ia.getAddress() instanceof java.net.Inet4Address
+                        && !ia.getAddress().isLoopbackAddress()
+                        && !ni.getDisplayName().startsWith("vnic")) {
+                        possibles.add(ni);
+                    }
+                }
+            }
+        }
+        return possibles.isEmpty() ? null : possibles.get(possibles.size() - 1);
+    }
     
     @Test
     public void testMultiResponses() throws Exception {
@@ -87,6 +108,7 @@ public final class WSDiscoveryClientTest {
                     InetAddress address = InetAddress.getByName("239.255.255.250");
                     MulticastSocket s = new MulticastSocket(Integer.parseInt(PORT));
                     s.setBroadcast(true);
+                    s.setNetworkInterface(findIpv4Interface());
                     s.joinGroup(address);
                     s.setReceiveBufferSize(64 * 1024);
                     s.setSoTimeout(5000);


[2/3] git commit: Update UDPDestination to allow specifying the interface to use via a property Also, try to decect a usable interface if not specified

Posted by dk...@apache.org.
Update UDPDestination to allow specifying the interface to use via a property
Also, try to decect a usable interface if not specified


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fc59fb85
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fc59fb85
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fc59fb85

Branch: refs/heads/3.0.x-fixes
Commit: fc59fb85d895d8a21fdcf24b4c95a1fe830f3bdb
Parents: 1c87694
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Oct 20 13:21:25 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Oct 21 16:16:12 2014 -0400

----------------------------------------------------------------------
 .../cxf/transport/udp/UDPDestination.java       | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fc59fb85/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
index f06304d..aec65f6 100644
--- a/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
+++ b/rt/transports/udp/src/main/java/org/apache/cxf/transport/udp/UDPDestination.java
@@ -25,9 +25,15 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.DatagramPacket;
 import java.net.InetSocketAddress;
+import java.net.InterfaceAddress;
 import java.net.MulticastSocket;
+import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
 import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
@@ -56,6 +62,8 @@ import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
  * 
  */
 public class UDPDestination extends AbstractDestination {
+    public static final String NETWORK_INTERFACE = UDPDestination.class.getName() + ".NETWORK_INTERFACE";
+    
     private static final Logger LOG = LogUtils.getL7dLogger(UDPDestination.class); 
     private static final AttributeKey KEY_IN = new AttributeKey(StreamIoHandler.class, "in");
     private static final AttributeKey KEY_OUT = new AttributeKey(StreamIoHandler.class, "out");
@@ -165,6 +173,7 @@ public class UDPDestination extends AbstractDestination {
                 socket.setSendBufferSize(64 * 1024);
                 socket.setTimeToLive(1);
                 socket.bind(new InetSocketAddress(isa.getPort()));
+                socket.setNetworkInterface(findNetworkInterface());
                 socket.joinGroup(isa.getAddress());
                 mcast = socket;
                 queue.execute(new MCastListener());
@@ -185,6 +194,34 @@ public class UDPDestination extends AbstractDestination {
             throw new RuntimeException(ex);
         }
     }
+    private NetworkInterface findNetworkInterface() throws SocketException {
+        String name = (String)this.getEndpointInfo().getProperty(UDPDestination.NETWORK_INTERFACE);
+        NetworkInterface ret = null;
+        if (!StringUtils.isEmpty(name)) {
+            ret = NetworkInterface.getByName(name);
+        }
+        if (ret == null) {
+            Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
+            List<NetworkInterface> possibles = new ArrayList<NetworkInterface>();
+            while (ifcs.hasMoreElements()) {
+                NetworkInterface ni = ifcs.nextElement();
+                if (ni.supportsMulticast()
+                    && ni.isUp()) {
+                    for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
+                        if (ia.getAddress() instanceof java.net.Inet4Address
+                            && !ia.getAddress().isLoopbackAddress()
+                            && !ni.getDisplayName().startsWith("vnic")) {
+                            possibles.add(ni);
+                        }
+                    }
+                }
+            }
+            ret = possibles.isEmpty() ? null : possibles.get(possibles.size() - 1);
+
+        }
+        return ret;
+    }
+
     protected void deactivate() {
         if (acceptor != null) {
             acceptor.unbind();


[3/3] git commit: [CXF-6038] Only add the handler interceptors once This closes #26

Posted by dk...@apache.org.
[CXF-6038] Only add the handler interceptors once
This closes #26

Signed-off-by: Daniel Kulp <dk...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/43f6a421
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/43f6a421
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/43f6a421

Branch: refs/heads/3.0.x-fixes
Commit: 43f6a421a5ce4fc08c7a005760f5bdc6d855fbc2
Parents: fc59fb8
Author: Kyle Lape <ky...@redhat.com>
Authored: Fri Oct 10 14:34:07 2014 -0700
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Oct 21 16:17:15 2014 -0400

----------------------------------------------------------------------
 .../apache/cxf/jaxws/support/JaxWsEndpointImpl.java    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/43f6a421/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
index accc5f4..6f0be97 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
@@ -123,6 +123,7 @@ public class JaxWsEndpointImpl extends EndpointImpl {
     private SOAPHandlerFaultOutInterceptor soapFaultOutInterceptor;
     private LogicalHandlerFaultInInterceptor logicalFaultInInterceptor;
     private SOAPHandlerFaultInInterceptor soapFaultInInterceptor;
+    private boolean handlerInterceptorsAdded;
         
     public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei) throws EndpointException {
         this(bus, s, ei, null, null, null, true);
@@ -543,6 +544,12 @@ public class JaxWsEndpointImpl extends EndpointImpl {
     }
 
     public void addHandlerInterceptors() {
+        if (handlerInterceptorsAdded) {
+            return;
+        } 
+
+        handlerInterceptorsAdded = true;
+
         List<Interceptor<? extends Message>> in = super.getInInterceptors();       
         List<Interceptor<? extends Message>> out = super.getOutInterceptors();
         List<Interceptor<? extends Message>> outFault = super.getOutFaultInterceptors();    
@@ -564,6 +571,12 @@ public class JaxWsEndpointImpl extends EndpointImpl {
         }
     }
     public void removeHandlerInterceptors() {
+        if (!handlerInterceptorsAdded) {
+            return;
+        }
+
+        handlerInterceptorsAdded = false;
+
         List<Interceptor<? extends Message>> in = super.getInInterceptors();       
         List<Interceptor<? extends Message>> out = super.getOutInterceptors();
         List<Interceptor<? extends Message>> outFault = super.getOutFaultInterceptors();