cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1166227 - in /cxf/branches/2.4.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
Date Wed, 07 Sep 2011 15:29:34 GMT
Author: dkulp
Date: Wed Sep  7 15:29:33 2011
New Revision: 1166227

URL: http://svn.apache.org/viewvc?rev=1166227&view=rev
Log:
Merged revisions 1166226 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1166226 | dkulp | 2011-09-07 11:28:20 -0400 (Wed, 07 Sep 2011) | 2 lines
  
  When running in OSGi, you could create a non-osgi associated bus.
  Don't NPE in that case.
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java?rev=1166227&r1=1166226&r2=1166227&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/osgi/OSGiExtensionLocator.java
Wed Sep  7 15:29:33 2011
@@ -142,7 +142,6 @@ public class OSGiExtensionLocator implem
         public static final String CONTEXT_NAME_PROPERTY = "cxf.bus.id";
         
         Bus bus;
-        BundleContext context;
         ServiceRegistration service;
  
         public OSGIBusListener(Bus b) {
@@ -156,19 +155,23 @@ public class OSGiExtensionLocator implem
         }
  
         public void initComplete() {
-            context = bus.getExtension(BundleContext.class);
-            Properties props = new Properties();
-            props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, context.getBundle().getSymbolicName());
-            props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(context.getBundle()));
-            props.put(CONTEXT_NAME_PROPERTY, bus.getId());
-
-            service = context.registerService(Bus.class.getName(), bus, props);
+            BundleContext context = bus.getExtension(BundleContext.class);
+            if (context != null) {
+                Properties props = new Properties();
+                props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, context.getBundle().getSymbolicName());
+                props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(context.getBundle()));
+                props.put(CONTEXT_NAME_PROPERTY, bus.getId());
+    
+                service = context.registerService(Bus.class.getName(), bus, props);
+            }
         }
         public void preShutdown() {
         }
         public void postShutdown() {
-            service.unregister();
-            service = null;
+            if (service != null) {
+                service.unregister();
+                service = null;
+            }
         }
     }
     



Mime
View raw message