Class CachingPersistenceManagerProxy
java.lang.Object
org.apache.felix.cm.impl.persistence.CachingPersistenceManagerProxy
- All Implemented Interfaces:
ExtPersistenceManager,PersistenceManager
The
CachingPersistenceManagerProxy adds a caching layer to the
underlying actual PersistenceManager implementation. All API calls
are also (or primarily) routed through a local cache of dictionaries indexed
by the service.pid.-
Field Summary
Fields inherited from interface org.apache.felix.cm.PersistenceManager
PROPERTY_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRemove the configuration with the given PID.booleanChecks whether a dictionary with the given pid exists.Returns anEnumerationofDictionaryobjects representing the configurations stored in the underlying persistence managers.getDictionaries(org.apache.felix.cm.impl.SimpleFilter filter) getFactoryConfigurationPids(List<String> targetedFactoryPids) Returns the dictionary for the given PID ornullif no such dictionary is stored by the underlying persistence manager.voidstore(String pid, Dictionary properties) Stores the dictionary in the cache and in the underlying persistence manager.
-
Constructor Details
-
CachingPersistenceManagerProxy
Creates a new caching layer for the given actualPersistenceManager.- Parameters:
pm- The actualPersistenceManager
-
-
Method Details
-
getDelegatee
- Specified by:
getDelegateein interfaceExtPersistenceManager
-
delete
Remove the configuration with the given PID. This implementation removes the entry from the cache before calling the underlying persistence manager.- Specified by:
deletein interfacePersistenceManager- Parameters:
pid- The identifier of the dictionary to delete.- Throws:
IOException- If an error occurs deleting the dictionary. This exception must not be thrown if no dictionary with the given identifier exists.
-
exists
Checks whether a dictionary with the given pid exists. First checks for the existence in the cache. If not in the cache the underlying persistence manager is asked.- Specified by:
existsin interfacePersistenceManager- Parameters:
pid- The identifier for the dictionary to test.- Returns:
trueif a persisted dictionary exists for the pid.
-
getDictionaries
Returns anEnumerationofDictionaryobjects representing the configurations stored in the underlying persistence managers. The dictionaries returned are guaranteed to contain theservice.pidproperty.Note, that each call to this method will return new dictionary objects. That is modifying the contents of a dictionary returned from this method has no influence on the dictionaries stored in the cache.
- Specified by:
getDictionariesin interfacePersistenceManager- Returns:
- A possibly empty Enumeration of all dictionaries.
- Throws:
IOException- If an error occurs getting the dictionaries.
-
getDictionaries
public Collection<Dictionary> getDictionaries(org.apache.felix.cm.impl.SimpleFilter filter) throws IOException - Specified by:
getDictionariesin interfaceExtPersistenceManager- Throws:
IOException
-
load
Returns the dictionary for the given PID ornullif no such dictionary is stored by the underlying persistence manager. This method caches the returned dictionary for future use after retrieving if from the persistence manager.Note, that each call to this method will return new dictionary instance. That is modifying the contents of a dictionary returned from this method has no influence on the dictionaries stored in the cache.
- Specified by:
loadin interfacePersistenceManager- Parameters:
pid- The identifier for the dictionary to load.- Returns:
- The dictionary for the identifier. This must not be
nullbut may be empty. - Throws:
IOException- If an error occurs loading the dictionary. AnIOExceptionmust also be thrown if no dictionary exists for the given identifier.
-
store
Stores the dictionary in the cache and in the underlying persistence manager. This method first calls the underlying persistence manager before updating the dictionary in the cache.Note, that actually a copy of the dictionary is stored in the cache. That is subsequent modification to the given dictionary has no influence on the cached data.
- Specified by:
storein interfacePersistenceManager- Parameters:
pid- The identifier of the dictionary.properties- TheDictionaryto store.- Throws:
IOException- If an error occurs storing the dictionary. If this exception is thrown, it is expected, thatexists(pidreturnsfalse.
-
getFactoryConfigurationPids
- Specified by:
getFactoryConfigurationPidsin interfaceExtPersistenceManager- Throws:
IOException
-