cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1559222 - /cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
Date Fri, 17 Jan 2014 19:01:24 GMT
Author: dkulp
Date: Fri Jan 17 19:01:23 2014
New Revision: 1559222

URL: http://svn.apache.org/r1559222
Log:
Merged revisions 1559220 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1559220 | dkulp | 2014-01-17 13:53:56 -0500 (Fri, 17 Jan 2014) | 2 lines

  [CXF-5491] If the ws-discovery service fails to startup as part of th a normal listener
process, log the warning and continue so the real services won't block.

........

Modified:
    cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java

Modified: cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java?rev=1559222&r1=1559221&r2=1559222&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
Fri Jan 17 19:01:23 2014
@@ -28,6 +28,8 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
@@ -54,6 +56,7 @@ import org.w3c.dom.Document;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxws.spi.ProviderImpl;
@@ -82,6 +85,8 @@ import org.apache.cxf.ws.discovery.wsdl.
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
 
 public class WSDiscoveryServiceImpl implements WSDiscoveryService {
+    private static final Logger LOG = LogUtils.getL7dLogger(WSDiscoveryService.class);
+    
     Bus bus;
     Endpoint udpEndpoint;
     WSDiscoveryClient client;
@@ -121,13 +126,13 @@ public class WSDiscoveryServiceImpl impl
     }
     
     public HelloType register(EndpointReference ref) {
-        startup();
+        startup(false);
         HelloType ht = client.register(ref); 
         registered.add(ht);
         return ht;
     }
     public void register(HelloType ht) {
-        startup();
+        startup(false);
         client.register(ht); 
         registered.add(ht);
     }
@@ -145,7 +150,9 @@ public class WSDiscoveryServiceImpl impl
         if (o == Boolean.TRUE || Boolean.valueOf((String)o)) {
             return;
         }
-        startup();
+        if (!startup(true)) {
+            return;
+        }
         HelloType ht = new HelloType();
         ht.setScopes(new ScopesType());
         ht.setMetadataVersion(1);
@@ -226,8 +233,10 @@ public class WSDiscoveryServiceImpl impl
     }
     
     
-    
     public synchronized void startup() {
+        startup(false);
+    }    
+    public synchronized boolean startup(boolean optional) {
         if (!started && client.isAdHoc()) {
             Bus b = BusFactory.getAndSetThreadDefaultBus(bus);
             try {
@@ -237,12 +246,19 @@ public class WSDiscoveryServiceImpl impl
                 udpEndpoint.setProperties(props);
                 udpEndpoint.publish("soap.udp://239.255.255.250:3702");
                 started = true;
+            } catch (RuntimeException ex) {
+                if (!optional) {
+                    throw ex;
+                } else {
+                    LOG.log(Level.WARNING, "Could not start WS-Discovery Service.", ex);
+                }
             } finally {
                 if (b != bus) {
                     BusFactory.setThreadDefaultBus(b);
                 }
             }
         }
+        return true;
     }
     
     



Mime
View raw message