felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1421783 - /felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Date Fri, 14 Dec 2012 10:24:10 GMT
Author: fmeschbe
Date: Fri Dec 14 10:24:10 2012
New Revision: 1421783

URL: http://svn.apache.org/viewvc?rev=1421783&view=rev
Log:
FELIX-3823 Make sure the default FilePersistenceManager is properly unregistered by the bundle
itself

Modified:
    felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java

Modified: felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1421783&r1=1421782&r2=1421783&view=diff
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
(original)
+++ felix/trunk/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Fri Dec 14 10:24:10 2012
@@ -127,6 +127,9 @@ public class ConfigurationManager implem
     // the BundleContext of the Configuration Admin Service bundle
     BundleContext bundleContext;
 
+    // the service registration of the default file persistence manager
+    private volatile ServiceRegistration filepmRegistration;
+
     // the service registration of the configuration admin
     private volatile ServiceRegistration configurationAdminRegistration;
 
@@ -245,7 +248,7 @@ public class ConfigurationManager implem
             props.put( Constants.SERVICE_DESCRIPTION, "Platform Filesystem Persistence Manager"
);
             props.put( Constants.SERVICE_VENDOR, "Apache Software Foundation" );
             props.put( Constants.SERVICE_RANKING, new Integer( Integer.MIN_VALUE ) );
-            bundleContext.registerService( PersistenceManager.class.getName(), fpm, props
);
+            filepmRegistration = bundleContext.registerService( PersistenceManager.class.getName(),
fpm, props );
 
             // setup dynamic configuration bindings
             dynamicBindings = new DynamicBindings( bundleContext, fpm );
@@ -316,10 +319,11 @@ public class ConfigurationManager implem
         // clearing the field before actually unregistering the service
         // prevents IllegalStateException in getServiceReference() if
         // the field is not null but the service already unregistered
-        if (configurationAdminRegistration != null) {
-            ServiceRegistration reg = configurationAdminRegistration;
-            configurationAdminRegistration = null;
-            reg.unregister();
+        final ServiceRegistration caReg = configurationAdminRegistration;
+        configurationAdminRegistration = null;
+        if ( caReg != null )
+        {
+            caReg.unregister();
         }
 
         // consider inactive after unregistering such that during
@@ -329,6 +333,14 @@ public class ConfigurationManager implem
         // don't care for PersistenceManagers any more
         persistenceManagerTracker.close();
 
+        // shutdown the file persistence manager
+        final ServiceRegistration filePmReg = filepmRegistration;
+        filepmRegistration = null;
+        if ( filePmReg != null )
+        {
+            filePmReg.unregister();
+        }
+
         // stop listening for events
         bundleContext.removeBundleListener( this );
 



Mime
View raw message