felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1299663 - in /felix/trunk/prefs/src/main/java/org/apache/felix/prefs: BackingStoreManager.java impl/PreferencesManager.java
Date Mon, 12 Mar 2012 13:10:25 GMT
Author: marrs
Date: Mon Mar 12 13:10:24 2012
New Revision: 1299663

URL: http://svn.apache.org/viewvc?rev=1299663&view=rev
Log:
FELIX-3334 applied the patch with a slight change

Modified:
    felix/trunk/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java
    felix/trunk/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java

Modified: felix/trunk/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java?rev=1299663&r1=1299662&r2=1299663&view=diff
==============================================================================
--- felix/trunk/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java (original)
+++ felix/trunk/prefs/src/main/java/org/apache/felix/prefs/BackingStoreManager.java Mon Mar
12 13:10:24 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.prefs;
 
+import org.osgi.service.prefs.BackingStoreException;
+
 
 /**
  * Get the backing store.
@@ -27,5 +29,5 @@ public interface BackingStoreManager {
     /**
      * Return the current backing store.
      */
-    BackingStore getStore();
+    BackingStore getStore() throws BackingStoreException;
 }

Modified: felix/trunk/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java?rev=1299663&r1=1299662&r2=1299663&view=diff
==============================================================================
--- felix/trunk/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java (original)
+++ felix/trunk/prefs/src/main/java/org/apache/felix/prefs/impl/PreferencesManager.java Mon
Mar 12 13:10:24 2012
@@ -193,30 +193,36 @@ public class PreferencesManager
     /**
      * @see org.apache.felix.prefs.BackingStoreManager#getStore()
      */
-    public BackingStore getStore() {
-        if (this.storeTracker == null) {
-            // We're being stopped already...
-            return null;
-        }
+    public BackingStore getStore() throws BackingStoreException {
+        BackingStore service = null;
+        ServiceTracker storeTracker = this.storeTracker;
 
-        // has the service changed?
-        int currentCount = this.storeTracker.getTrackingCount();
-        BackingStore service = (BackingStore) this.storeTracker.getService();
-        if (service != null && this.storeTrackingCount < currentCount) {
-            this.storeTrackingCount = currentCount;
-            this.cleanupStore(service);
+        // Only possible if we're not stopped already...
+        if (storeTracker != null) {
+	        // has the service changed?
+	        int currentCount = storeTracker.getTrackingCount();
+	        service = (BackingStore) storeTracker.getService();
+	        if (service != null && this.storeTrackingCount < currentCount) {
+	            this.storeTrackingCount = currentCount;
+	            this.cleanupStore(service);
+	        }
+	        if (service == null) {
+	            // no service available use default store
+	            if (this.defaultStore == null) {
+	                synchronized (this) {
+	                    if (this.defaultStore == null) {
+	                        this.defaultStore = new DataFileBackingStoreImpl(this.context);
+	                        this.cleanupStore(this.defaultStore);
+	                    }
+	                }
+	            }
+	            service = this.defaultStore;
+	        }
         }
+
         if (service == null) {
-            // no service available use default store
-            if (this.defaultStore == null) {
-                synchronized (this) {
-                    if (this.defaultStore == null) {
-                        this.defaultStore = new DataFileBackingStoreImpl(this.context);
-                        this.cleanupStore(this.defaultStore);
-                    }
-                }
-            }
-            service = this.defaultStore;
+            // (still) no service available; cannot fulfill this request...
+            throw new BackingStoreException("No backing store!");
         }
 
         return service;



Mime
View raw message