cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1531026 - /cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
Date Thu, 10 Oct 2013 15:31:28 GMT
Author: dkulp
Date: Thu Oct 10 15:31:28 2013
New Revision: 1531026

URL: http://svn.apache.org/r1531026
Log:
[CXF-5329] Make sure the wsn bus gets registered as a service
Patch from Sebastian Ruhl applied

Modified:
    cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java

Modified: cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java?rev=1531026&r1=1531025&r2=1531026&view=diff
==============================================================================
--- cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
(original)
+++ cxf/trunk/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/services/OSGiJaxwsEndpointManager.java
Thu Oct 10 15:31:28 2013
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.wsn.services;
 
+import java.util.Dictionary;
+import java.util.Properties;
 import javax.management.MBeanServer;
 import javax.xml.ws.Endpoint;
 
@@ -26,9 +28,16 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.blueprint.BlueprintBus;
 import org.apache.cxf.wsn.EndpointRegistrationException;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
+import static org.apache.cxf.bus.osgi.OSGIBusListener.CONTEXT_NAME_PROPERTY;
+import static org.apache.cxf.bus.osgi.OSGIBusListener.CONTEXT_SYMBOLIC_NAME_PROPERTY;
+import static org.apache.cxf.bus.osgi.OSGIBusListener.CONTEXT_VERSION_PROPERTY;
+
 /**
  * 
  */
@@ -99,7 +108,19 @@ public class OSGiJaxwsEndpointManager ex
         bp.setBlueprintContainer(container);
         bp.setId("WS-Notification");
         bp.initialize();
+        if (null != bundleContext) {
+            Properties props = new Properties();
+            props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, bundleContext.getBundle().getSymbolicName());
+            props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(bundleContext.getBundle()));
+            props.put(CONTEXT_NAME_PROPERTY, bp.getId());
+            bundleContext.registerService(Bus.class.getName(), bp, props);
+        }
         cxfBus = bp;
     }
+    private Version getBundleVersion(Bundle bundle) {
+        Dictionary<?, ?> headers = bundle.getHeaders();
+        String version = (String) headers.get(Constants.BUNDLE_VERSION);
+        return (version != null) ? Version.parseVersion(version) : Version.emptyVersion;
+    }
     
 }



Mime
View raw message