[FELIX-4855] ConfigAdmin does not update ManagedServiceFactory on framework restart
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1674069 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java b/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
index 997ddd7..9a09ffe 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/CachingPersistenceManagerProxy.java
@@ -76,11 +76,14 @@
public void delete( String pid ) throws IOException
{
Lock lock = globalLock.writeLock();
- try {
+ try
+ {
lock.lock();
cache.remove( pid );
pm.delete(pid);
- } finally {
+ }
+ finally
+ {
lock.unlock();
}
}
@@ -94,10 +97,13 @@
public boolean exists( String pid )
{
Lock lock = globalLock.readLock();
- try {
+ try
+ {
lock.lock();
return cache.containsKey( pid ) || ( !fullyLoaded && pm.exists( pid ) );
- } finally {
+ }
+ finally
+ {
lock.unlock();
}
}
@@ -121,7 +127,8 @@
public Enumeration getDictionaries( SimpleFilter filter ) throws IOException
{
Lock lock = globalLock.readLock();
- try {
+ try
+ {
lock.lock();
// if not fully loaded, call back to the underlying persistence
// manager and cach all dictionaries whose service.pid is set
@@ -133,13 +140,22 @@
if ( !fullyLoaded )
{
Enumeration fromPm = pm.getDictionaries();
- while (fromPm.hasMoreElements())
+ while ( fromPm.hasMoreElements() )
{
Dictionary next = (Dictionary) fromPm.nextElement();
- String pid = (String) next.get(Constants.SERVICE_PID);
- if (pid != null)
+ String pid = (String) next.get( Constants.SERVICE_PID );
+ if ( pid != null )
{
- cache.put(pid, copy( next ) );
+ cache.put( pid, copy( next ) );
+ }
+ else
+ {
+ pid = (String) next.get( Factory.FACTORY_PID );
+ if ( pid != null )
+ {
+ pid = Factory.factoryPidToIdentifier( pid );
+ cache.put( pid, copy( next ) );
+ }
}
}
fullyLoaded = true;
@@ -148,16 +164,17 @@
// Deep copy the configuration to avoid any threading issue
Vector<Dictionary> configs = new Vector<Dictionary>();
- for (Object o : cache.values())
+ for (Dictionary d : cache.values())
{
- Dictionary d = (Dictionary) o;
- if ( filter == null || filter.matches( d ) )
+ if ( d.get( Constants.SERVICE_PID ) != null && ( filter == null || filter.matches( d ) ) )
{
configs.add( copy( d ) );
}
}
return configs.elements();
- } finally {
+ }
+ finally
+ {
lock.unlock();
}
}
@@ -176,7 +193,8 @@
public Dictionary load( String pid ) throws IOException
{
Lock lock = globalLock.readLock();
- try {
+ try
+ {
lock.lock();
Dictionary loaded = cache.get( pid );
if ( loaded == null && !fullyLoaded )
@@ -187,12 +205,14 @@
loaded = cache.get( pid );
if ( loaded == null )
{
- loaded = pm.load(pid);
- cache.put(pid, copy( loaded ) );
+ loaded = pm.load( pid );
+ cache.put( pid, copy( loaded ) );
}
}
return copy( loaded );
- } finally {
+ }
+ finally
+ {
lock.unlock();
}
}
@@ -210,11 +230,14 @@
public void store( String pid, Dictionary properties ) throws IOException
{
Lock lock = globalLock.writeLock();
- try {
+ try
+ {
lock.lock();
pm.store( pid, properties );
cache.put( pid, copy( properties ) );
- } finally {
+ }
+ finally
+ {
lock.unlock();
}
}
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java b/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java
index 77b3c99..5b5217f 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/Factory.java
@@ -58,7 +58,7 @@
}
- private static String factoryPidToIdentifier( String factoryPid )
+ static String factoryPidToIdentifier( String factoryPid )
{
return factoryPid + ".factory";
}