felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1803786 - in /felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl: ConfigurationManager.java persistence/CachingPersistenceManagerProxy.java persistence/ExtPersistenceManager.java persistence/PersistenceManagerProxy.java
Date Wed, 02 Aug 2017 09:16:58 GMT
Author: cziegeler
Date: Wed Aug  2 09:16:58 2017
New Revision: 1803786

URL: http://svn.apache.org/viewvc?rev=1803786&view=rev
Log:
FELIX-5669 : Registering a PersistenceManager causes duplicate caches. Apply modified patch
from Brandan Jeter

Modified:
    felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
    felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/CachingPersistenceManagerProxy.java
    felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/ExtPersistenceManager.java
    felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerProxy.java

Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java?rev=1803786&r1=1803785&r2=1803786&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
Wed Aug  2 09:16:58 2017
@@ -763,13 +763,22 @@ public class ConfigurationManager implem
                     PersistenceManager service = persistenceManagerTracker.getService( refs[i]
);
                     if ( service != null )
                     {
-                        if ( service instanceof NotCachablePersistenceManager )
+                        // check for existing proxy
+                        final ExtPersistenceManager pmProxy = getProxyForPersistenceManager(service);
+                        if ( pmProxy != null )
                         {
-                            pmList.add( new PersistenceManagerProxy( service ) );
+                            pmList.add(pmProxy);
                         }
                         else
                         {
-                            pmList.add( new CachingPersistenceManagerProxy( service ) );
+                            if ( service instanceof NotCachablePersistenceManager )
+                            {
+                                pmList.add( new PersistenceManagerProxy( service ) );
+                            }
+                            else
+                            {
+                                pmList.add(new CachingPersistenceManagerProxy(service));
+                            }
                         }
                     }
                 }
@@ -784,6 +793,17 @@ public class ConfigurationManager implem
         return persistenceManagers;
     }
 
+    private ExtPersistenceManager getProxyForPersistenceManager(final PersistenceManager
pm)
+    {
+        if (persistenceManagers != null) {
+            for (final ExtPersistenceManager pmProxy : persistenceManagers) {
+                if (pmProxy.getDelegatee() == pm) {
+                    return pmProxy;
+                }
+            }
+        }
+        return null;
+    }
 
     private ServiceReference<ConfigurationAdmin> getServiceReference()
     {
@@ -959,7 +979,7 @@ public class ConfigurationManager implem
      *
      * @param factoryPid The PID of the {@link Factory} to return
      * @return The existing or newly created {@link Factory}
-     * @throws IOException If an error occurrs reading the factory from
+     * @throws IOException If an error occurs reading the factory from
      *      a {@link PersistenceManager}
      */
     Factory getOrCreateFactory( String factoryPid ) throws IOException
@@ -981,7 +1001,7 @@ public class ConfigurationManager implem
      *
      * @param factoryPid The PID of the {@link Factory} to return
      * @return The existing {@link Factory} or <code>null</code>
-     * @throws IOException If an error occurrs reading the factory from
+     * @throws IOException If an error occurs reading the factory from
      *      a {@link PersistenceManager}
      */
     Factory getFactory( String factoryPid ) throws IOException

Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/CachingPersistenceManagerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/CachingPersistenceManagerProxy.java?rev=1803786&r1=1803785&r2=1803786&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/CachingPersistenceManagerProxy.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/CachingPersistenceManagerProxy.java
Wed Aug  2 09:16:58 2017
@@ -73,6 +73,12 @@ public class CachingPersistenceManagerPr
         this.cache = new Hashtable<String, CaseInsensitiveDictionary>();
     }
 
+    @Override
+    public PersistenceManager getDelegatee()
+    {
+        return pm;
+    }
+
     /**
      * Remove the configuration with the given PID. This implementation removes
      * the entry from the cache before calling the underlying persistence

Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/ExtPersistenceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/ExtPersistenceManager.java?rev=1803786&r1=1803785&r2=1803786&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/ExtPersistenceManager.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/ExtPersistenceManager.java
Wed Aug  2 09:16:58 2017
@@ -31,4 +31,6 @@ import org.apache.felix.cm.impl.SimpleFi
 public interface ExtPersistenceManager extends PersistenceManager
 {
     Collection<Dictionary> getDictionaries( SimpleFilter filter ) throws IOException;
+
+    PersistenceManager getDelegatee();
 }

Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerProxy.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerProxy.java?rev=1803786&r1=1803785&r2=1803786&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerProxy.java
(original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/persistence/PersistenceManagerProxy.java
Wed Aug  2 09:16:58 2017
@@ -57,6 +57,12 @@ public class PersistenceManagerProxy imp
         this.pm = pm;
     }
 
+    @Override
+    public PersistenceManager getDelegatee()
+    {
+        return pm;
+    }
+
     /**
      * Remove the configuration with the given PID. This implementation removes
      * the entry from the cache before calling the underlying persistence



Mime
View raw message