cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] cxf git commit: [CXF-6172]:WS-Discovery should work also in IPv6 only environment
Date Thu, 05 Nov 2015 09:40:00 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes d3901813b -> 86b169b16


[CXF-6172]:WS-Discovery should work also in IPv6 only environment


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

Branch: refs/heads/2.7.x-fixes
Commit: 82c7115053f51667684869e4a39bb9e82765113a
Parents: d390181
Author: Jim Ma <ema@apache.org>
Authored: Thu Nov 5 16:51:31 2015 +0800
Committer: Jim Ma <ema@apache.org>
Committed: Thu Nov 5 17:27:18 2015 +0800

----------------------------------------------------------------------
 .../apache/cxf/ws/discovery/WSDiscoveryClient.java | 14 +++++++++++---
 .../discovery/internal/WSDiscoveryServiceImpl.java | 17 ++++++++++++++---
 2 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/82c71150/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
----------------------------------------------------------------------
diff --git a/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
b/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
index 65c9e5b..e6e2723 100644
--- a/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
+++ b/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/WSDiscoveryClient.java
@@ -78,10 +78,8 @@ import org.apache.cxf.wsdl.EndpointReferenceUtils;
 public class WSDiscoveryClient implements Closeable {
     
     public static final QName SERVICE_QNAME = new QName(WSDVersion.NS_1_1, "DiscoveryProxy");
-    
-    
-    
     String address = "soap.udp://239.255.255.250:3702";
+    String ipv6Address = "soap.udp://[FF02::C]:3702";
     boolean adHoc = true;
     AtomicInteger msgId = new AtomicInteger(1);
     long instanceId = System.currentTimeMillis();
@@ -96,9 +94,11 @@ public class WSDiscoveryClient implements Closeable {
 
     public WSDiscoveryClient() {
         this((Bus)null);
+        setIpV6Address();
     }
     public WSDiscoveryClient(Bus b) {
         this.bus = b == null ? BusFactory.getThreadDefaultBus() : b;
+        setIpV6Address();
     }
     public WSDiscoveryClient(String address) {
         this((Bus)null);
@@ -161,6 +161,14 @@ public class WSDiscoveryClient implements Closeable {
             uncache();
         }
     }
+
+    private void setIpV6Address() {
+        String preferIPv4StackValue = System.getProperty("java.net.preferIPv4Stack");
+        String preferIPv6AddressesValue = System.getProperty("java.net.preferIPv6Addresses");
+        if ("true".equals(preferIPv6AddressesValue) && "false".equals(preferIPv4StackValue))
{
+            address = "soap.udp://[FF02::C]:3702";
+        }
+    }
     private void uncache() {
         if (dispatch instanceof Closeable) {
             try {

http://git-wip-us.apache.org/repos/asf/cxf/blob/82c71150/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
b/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
index fde081a..89c65e5 100644
--- a/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
+++ b/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
@@ -238,15 +238,26 @@ public class WSDiscoveryServiceImpl implements WSDiscoveryService {
         startup(false);
     }    
     public synchronized boolean startup(boolean optional) {
+        String preferIPv4StackValue = System.getProperty("java.net.preferIPv4Stack");
+        String preferIPv6AddressesValue = System.getProperty("java.net.preferIPv6Addresses");
         if (!started && client.isAdHoc()) {
             Bus b = BusFactory.getAndSetThreadDefaultBus(bus);
             try {
                 udpEndpoint = new EndpointImpl(bus, new WSDiscoveryProvider());
                 Map<String, Object> props = new HashMap<String, Object>();
                 props.put("jaxws.provider.interpretNullAsOneway", "true");
-                udpEndpoint.setProperties(props);
-                udpEndpoint.publish("soap.udp://239.255.255.250:3702");
-                started = true;
+                if ("true".equals(preferIPv6AddressesValue) && "false".equals(preferIPv4StackValue))
{
+                    try {
+                        udpEndpoint.publish("soap.udp://[FF02::C]:3702");
+                        started = true;
+                    } catch (Exception e) {
+                        LOG.log(Level.WARNING, "Could not start WS-Discovery Service with
ipv6 address", e);
+                    }
+                }
+                if (!started) {
+                    udpEndpoint.publish("soap.udp://239.255.255.250:3702");
+                    started = true;
+                }
             } catch (RuntimeException ex) {
                 if (!optional) {
                     throw ex;


Mime
View raw message