Package org.opensaml.core.xml.persist
Class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>
- java.lang.Object
-
- org.opensaml.core.xml.persist.AbstractConditionalLoadXMLObjectLoadSaveManager<T>
-
- Type Parameters:
T- the base type of XML objects being managed
- All Implemented Interfaces:
ConditionalLoadXMLObjectLoadSaveManager<T>,XMLObjectLoadSaveManager<T>
- Direct Known Subclasses:
FilesystemLoadSaveManager,MapLoadSaveManager
public abstract class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject> extends Object implements ConditionalLoadXMLObjectLoadSaveManager<T>
Abstract base class forXMLObjectLoadSaveManagerimplementations which track the modify times of requested data such thatXMLObjectLoadSaveManager.load(String)returns data only if the data associated with the key has been modified since the last request.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanloadConditionallyConfiguration flag for whetherXMLObjectLoadSaveManager.load(String)will check and return data only if modified since the last request for that data.private Map<String,Instant>loadLastModifiedStorage for last modified time of requested data.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractConditionalLoadXMLObjectLoadSaveManager(boolean conditionalLoad)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclearAllLoadLastModified()Clear the cached modified times for the last load for all keys.InstantclearLoadLastModified(String key)Clear the cached modified time for the last load of the specified key.InstantgetLoadLastModified(String key)Retrieve the cached modified time for the last load of the specified key.booleanisLoadConditionally()Get whetherXMLObjectLoadSaveManager.load(String)will check and return data only if modified since the last request for that data.protected abstract booleanisUnmodifiedSinceLastLoad(String key)Check whether the data corresponding to the specified key has been modified since the last timeXMLObjectLoadSaveManager.load(String)was called for that key.protected InstantupdateLoadLastModified(String key)Update the cached modified time for the specified key with the current time.protected InstantupdateLoadLastModified(String key, Instant modified)Update the cached modified time for the specified key with the specified time.
-
-
-
Field Detail
-
loadConditionally
private boolean loadConditionally
Configuration flag for whetherXMLObjectLoadSaveManager.load(String)will check and return data only if modified since the last request for that data.
-
-
Constructor Detail
-
AbstractConditionalLoadXMLObjectLoadSaveManager
protected AbstractConditionalLoadXMLObjectLoadSaveManager(@ParameterName(name="conditionalLoad") boolean conditionalLoad)
Constructor.- Parameters:
conditionalLoad- whetherXMLObjectLoadSaveManager.load(String)should behave as defined inConditionalLoadXMLObjectLoadSaveManager
-
-
Method Detail
-
isLoadConditionally
public boolean isLoadConditionally()
Get whetherXMLObjectLoadSaveManager.load(String)will check and return data only if modified since the last request for that data.- Specified by:
isLoadConditionallyin interfaceConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>- Returns:
- true if data modify time check is enabled, false if not
-
getLoadLastModified
@Nullable public Instant getLoadLastModified(@Nonnull String key)
Retrieve the cached modified time for the last load of the specified key.Note that this will be null if
XMLObjectLoadSaveManager.load(String)has not been called for the specified key since construction or since the last call toConditionalLoadXMLObjectLoadSaveManager.clearLoadLastModified(String)orConditionalLoadXMLObjectLoadSaveManager.clearAllLoadLastModified().- Specified by:
getLoadLastModifiedin interfaceConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>- Parameters:
key- the target key- Returns:
- the current cached modified time, may be null
-
clearLoadLastModified
@Nullable public Instant clearLoadLastModified(@Nonnull String key)
Clear the cached modified time for the last load of the specified key.- Specified by:
clearLoadLastModifiedin interfaceConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>- Parameters:
key- the target key- Returns:
- the previously cached modified time, or null if did not exist
-
clearAllLoadLastModified
public void clearAllLoadLastModified()
Clear the cached modified times for the last load for all keys.- Specified by:
clearAllLoadLastModifiedin interfaceConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>
-
updateLoadLastModified
protected Instant updateLoadLastModified(@Nonnull String key)
Update the cached modified time for the specified key with the current time.- Parameters:
key- the target key- Returns:
- the previously cached modified time, or null if did not exist
-
updateLoadLastModified
@Nullable protected Instant updateLoadLastModified(@Nonnull String key, @Nullable Instant modified)
Update the cached modified time for the specified key with the specified time.- Parameters:
key- the target keymodified- the new cached modified time- Returns:
- the previously cached modified time, or null if did not exist
-
isUnmodifiedSinceLastLoad
protected abstract boolean isUnmodifiedSinceLastLoad(@Nonnull String key) throws IOExceptionCheck whether the data corresponding to the specified key has been modified since the last timeXMLObjectLoadSaveManager.load(String)was called for that key.- Parameters:
key- the data key- Returns:
- true if the corresponding data has been modified since the last load, false otherwise
- Throws:
IOException- if there is a fatal error evaluating the last modified status
-
-