cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1559220 - /cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
Date Fri, 17 Jan 2014 18:53:56 GMT
Author: dkulp
Date: Fri Jan 17 18:53:56 2014
New Revision: 1559220

URL: http://svn.apache.org/r1559220
Log:
[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/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java?rev=1559220&r1=1559219&r2=1559220&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
(original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/internal/WSDiscoveryServiceImpl.java
Fri Jan 17 18:53:56 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;
@@ -81,6 +84,8 @@ import org.apache.cxf.ws.discovery.wsdl.
 import org.apache.cxf.ws.discovery.wsdl.ScopesType;
 
 public class WSDiscoveryServiceImpl implements WSDiscoveryService {
+    private static final Logger LOG = LogUtils.getL7dLogger(WSDiscoveryService.class);
+    
     Bus bus;
     Endpoint udpEndpoint;
     WSDiscoveryClient client;
@@ -120,13 +125,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);
     }
@@ -144,7 +149,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);
@@ -225,8 +232,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 {
@@ -236,12 +245,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