Skip to content
Permalink
Browse files
[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.

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1559220 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Jan 17, 2014
1 parent 46fbc96 commit a3b3e7015b68d0247c4ab7c3c3e5d7457f464186
Showing 1 changed file with 20 additions and 4 deletions.
@@ -28,6 +28,8 @@
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.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.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 WSDiscoveryClient getClient() {
}

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 void serverStarted(Server server) {
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 void unregister(HelloType ht) {
}



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 synchronized void startup() {
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;
}


0 comments on commit a3b3e70

Please sign in to comment.