T - the specific base XML object type being managed@NotThreadSafe public class MapLoadSaveManager<T extends XMLObject> extends AbstractConditionalLoadXMLObjectLoadSaveManager<T>
XMLObjectLoadSaveManager which uses an in-memory map.| Modifier and Type | Field and Description |
|---|---|
private Map<String,T> |
backingMap
The backing map.
|
private Map<String,Long> |
dataLastModified
Storage to track last modified time of data.
|
private org.slf4j.Logger |
log
Logger.
|
| Modifier | Constructor and Description |
|---|---|
|
MapLoadSaveManager()
Constructor.
|
|
MapLoadSaveManager(boolean conditionalLoad)
Constructor.
|
|
MapLoadSaveManager(Map<String,T> map)
Constructor.
|
protected |
MapLoadSaveManager(Map<String,T> map,
Map<String,Long> lastModifiedMap,
boolean conditionalLoad)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
exists(String key)
Evaluate whether an object already exists indexed by the supplied key.
|
protected boolean |
isUnmodifiedSinceLastLoad(String key)
Check whether the data corresponding to the specified key has been modified since the last time
XMLObjectLoadSaveManager.load(String) was called for that key. |
Iterable<Pair<String,T>> |
listAll()
Return an iterable of all objects under management, along with their associated index key.
|
Set<String> |
listKeys()
Return a set of the index keys of all objects under management.
|
T |
load(String key)
Load a particular object based on the supplied key.
|
boolean |
remove(String key)
Remove the object indexed by the specified key.
|
void |
save(String key,
T xmlObject)
Save a particular object, indexed by the supplied key.
|
void |
save(String key,
T xmlObject,
boolean overwrite)
Save a particular object, indexed by the supplied key.
|
boolean |
updateKey(String currentKey,
String newKey)
Update the key under which a particular object is stored.
|
clearAllLoadLastModified, clearLoadLastModified, getLoadLastModified, isLoadConditionally, updateLoadLastModified, updateLoadLastModifiedpublic MapLoadSaveManager()
public MapLoadSaveManager(@ParameterName(name="conditionalLoad") boolean conditionalLoad)
conditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic MapLoadSaveManager(@ParameterName(name="map")@Nonnull Map<String,T> map)
Note: conditional load is not supported with this option, because of the need to track
modify times of items stored in the backing map.
Use instead MapLoadSaveManager(boolean).
map - the backing mapprotected MapLoadSaveManager(@ParameterName(name="map")@Nonnull Map<String,T> map, @ParameterName(name="dataLastModified")@Nonnull Map<String,Long> lastModifiedMap, @ParameterName(name="conditionalLoad") boolean conditionalLoad)
map - the backing maplastModifiedMap - the storage for data last modified timesconditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic Set<String> listKeys() throws IOException
IOException - if there is a fatal error obtaining the keyspublic Iterable<Pair<String,T>> listAll() throws IOException
IOException - if there is a fatal error loading the managed objectspublic boolean exists(String key) throws IOException
key - the key of the desired objectIOException - if there is a fatal error evaluating object existencepublic T load(String key) throws IOException
key - the key of the desired objectIOException - if there is a fatal error loading the objectpublic void save(String key, T xmlObject) throws IOException
An existing object indexed by the supplied key will not be overwritten.
Instead an IOException will be thrown.
For saving with the overwrite option, see XMLObjectLoadSaveManager.save(String, XMLObject, boolean).
key - the key under which to index the objectxmlObject - the object to saveIOException - if there is a fatal error saving the object, or if an object already exists
indexed by the supplied keypublic void save(String key, T xmlObject, boolean overwrite) throws IOException
key - the key under which to index the objectxmlObject - the object to saveoverwrite - whether or not to overwrite any existing object indexed by the supplied keyIOException - if there is a fatal error saving the object, or if overwrite=false,
if an object already exists indexed by the supplied keypublic boolean remove(String key) throws IOException
key - the key of the object to removeIOException - if there was a fatal error removing the objectpublic boolean updateKey(String currentKey, String newKey) throws IOException
currentKey - the current key under which the object is storednewKey - the new key under which the object should be storedIOException - if there was a fatal error updating the keyprotected boolean isUnmodifiedSinceLastLoad(@Nonnull String key) throws IOException
XMLObjectLoadSaveManager.load(String) was called for that key.isUnmodifiedSinceLastLoad in class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>key - the data keyIOException - if there is a fatal error evaluating the last modified statusCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.