use of org.apache.felix.cm.NotCachablePersistenceManager in project felix by apache.
the class CachingPersistenceManagerProxy method getDictionaries.
public Enumeration getDictionaries(SimpleFilter filter) throws IOException {
Lock lock = globalLock.readLock();
try {
lock.lock();
boolean fullyLoaded = this.fullyLoaded;
if (pm instanceof NotCachablePersistenceManager) {
fullyLoaded = false;
}
// manager and cache all dictionaries whose service.pid is set
if (!fullyLoaded) {
lock.unlock();
lock = globalLock.writeLock();
lock.lock();
if (!fullyLoaded) {
Enumeration fromPm = pm.getDictionaries();
while (fromPm.hasMoreElements()) {
Dictionary next = (Dictionary) fromPm.nextElement();
this.cache(next);
}
this.fullyLoaded = true;
}
}
// Deep copy the configuration to avoid any threading issue
Vector<Dictionary> configs = new Vector<Dictionary>();
for (Dictionary d : cache.values()) {
if (d.get(Constants.SERVICE_PID) != null && (filter == null || filter.matches(d))) {
configs.add(copy(d));
}
}
return configs.elements();
} finally {
lock.unlock();
}
}
Aggregations