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 2012/09/24 22:57:21 UTC

svn commit: r1389572 - in /cxf/trunk/services/ws-discovery: ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/ ws-discovery-service/ ws-discovery-service/src/main/resources/OSGI-INF/blueprint/

Author: dkulp
Date: Mon Sep 24 20:57:21 2012
New Revision: 1389572

URL: http://svn.apache.org/viewvc?rev=1389572&view=rev
Log:
Fix problems of an loop in loading the ws-discovery stuff in OSGi

Modified:
    cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
    cxf/trunk/services/ws-discovery/ws-discovery-service/pom.xml
    cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml

Modified: cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java?rev=1389572&r1=1389571&r2=1389572&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-api/src/main/java/org/apache/cxf/ws/discovery/listeners/WSDiscoveryServerListener.java Mon Sep 24 20:57:21 2012
@@ -33,17 +33,26 @@ import org.apache.cxf.ws.discovery.inter
 public class WSDiscoveryServerListener implements ServerLifeCycleListener {
     static WSDiscoveryServiceImpl staticService;
     
-    WSDiscoveryServiceImpl service;
+    final Bus bus;
+    volatile WSDiscoveryServiceImpl service;
+    
     
     public WSDiscoveryServerListener(Bus bus) {
-        service = bus.getExtension(WSDiscoveryServiceImpl.class);
+        this.bus = bus;
+    }
+    
+    private synchronized WSDiscoveryServiceImpl getService() {
         if (service == null) {
-            service = getStaticService();
-            bus.setExtension(service, WSDiscoveryServiceImpl.class);
+            service = bus.getExtension(WSDiscoveryServiceImpl.class);
+            if (service == null) {
+                service = getStaticService();
+                bus.setExtension(service, WSDiscoveryServiceImpl.class);
+            }
         }
+        return service;
     }
 
-    private WSDiscoveryServiceImpl getStaticService() {
+    private static WSDiscoveryServiceImpl getStaticService() {
         if (staticService == null) {
             Bus bus = BusFactory.newInstance().createBus();
             staticService = new WSDiscoveryServiceImpl(bus);
@@ -56,7 +65,7 @@ public class WSDiscoveryServerListener i
         if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01".equals(sn.getNamespaceURI())) {
             return;
         }
-        service.serverStarted(server);
+        getService().serverStarted(server);
     }
 
     public void stopServer(Server server) {
@@ -64,6 +73,6 @@ public class WSDiscoveryServerListener i
         if ("http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01".equals(sn.getNamespaceURI())) {
             return;
         }
-        service.serverStopped(server);
+        getService().serverStopped(server);
     }
 }

Modified: cxf/trunk/services/ws-discovery/ws-discovery-service/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-service/pom.xml?rev=1389572&r1=1389571&r2=1389572&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-service/pom.xml (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-service/pom.xml Mon Sep 24 20:57:21 2012
@@ -32,6 +32,10 @@
         <version>2.7.0-SNAPSHOT</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
+    
+    <properties>
+        <cxf.osgi.import>org.apache.cxf.ws.discovery.listeners</cxf.osgi.import>
+    </properties>
 
 	<dependencies>
         <dependency>

Modified: cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml?rev=1389572&r1=1389571&r2=1389572&view=diff
==============================================================================
--- cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml (original)
+++ cxf/trunk/services/ws-discovery/ws-discovery-service/src/main/resources/OSGI-INF/blueprint/cxf-wsdiscovery.xml Mon Sep 24 20:57:21 2012
@@ -18,10 +18,15 @@
 
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cxf="http://cxf.apache.org/blueprint/core"
            xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
 
+    <cxf:bus name="cxf"/>
+
     <!-- Single discovery service to avoid lots of UDP packets, particularly on probes -->
-    <bean id="discoveryService" class="org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl"/>
+    <bean id="discoveryService" class="org.apache.cxf.ws.discovery.internal.WSDiscoveryServiceImpl">
+        <argument ref="cxf" />
+    </bean>
 
     <service ref="discoveryService" interface="org.apache.cxf.ws.discovery.WSDiscoveryService" />