public abstract class AbstractStorageService extends net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent implements StorageService, StorageCapabilities
StorageService implementations.
The base class handles support for a background cleanup task, and handles calling of custom object serializers.
| Modifier and Type | Field and Description |
|---|---|
private long |
cleanupInterval
Number of seconds between cleanup checks.
|
private TimerTask |
cleanupTask
Task that cleans up expired records.
|
private Timer |
cleanupTaskTimer
Timer used to schedule cleanup tasks.
|
private int |
contextSize
Configurable context size limit.
|
private Timer |
internalTaskTimer
Timer used to schedule cleanup tasks if no external one set.
|
private int |
keySize
Configurable key size limit.
|
private int |
valueSize
Configurable value size limit.
|
| Constructor and Description |
|---|
AbstractStorageService() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
create(Object value)
Creates a new record in the store using an annotated object as the source.
|
boolean |
create(String context,
String key,
Object value,
StorageSerializer serializer,
Long expiration)
Creates a new record in the store with an expiration, using a custom serialization
process for an arbitrary object.
|
boolean |
delete(Object value)
Deletes an existing record from the store, using an annotated object as the source.
|
boolean |
deleteWithVersion(long version,
Object value)
Deletes an existing record from the store, using an annotated object as the source, if it
currently has a specified version.
|
protected void |
doDestroy() |
protected void |
doInitialize() |
StorageCapabilities |
getCapabilities()
Returns the capabilities of the underlying store.
|
long |
getCleanupInterval()
Gets the number of milliseconds between one cleanup and another.
|
protected TimerTask |
getCleanupTask()
Returns a cleanup task function to schedule for background cleanup.
|
Timer |
getCleanupTaskTimer()
Gets the timer used to schedule cleanup tasks.
|
int |
getContextSize()
Gets max size of context labels in characters.
|
int |
getKeySize()
Gets max size of keys in characters.
|
long |
getValueSize()
Gets max size of values in characters.
|
Object |
read(Object value)
Returns an existing record from the store, if one exists, and uses it to
update the annotated fields of a target object.
|
void |
setCleanupInterval(long interval)
Sets the number of milliseconds between one cleanup and another.
|
void |
setCleanupTaskTimer(Timer timer)
Sets the timer used to schedule cleanup tasks.
|
void |
setContextSize(int size)
Set the context size limit.
|
void |
setKeySize(int size)
Set the key size limit.
|
void |
setValueSize(int size)
Set the value size limit.
|
boolean |
update(Object value)
Updates an existing record in the store, using an annotated object as the source.
|
boolean |
update(String context,
String key,
Object value,
StorageSerializer serializer,
Long expiration)
Updates an existing record in the store using a custom serialization strategy.
|
boolean |
updateExpiration(Object value)
Updates expiration of an existing record in the store, using an annotated object as the source.
|
Long |
updateWithVersion(long version,
Object value)
Updates an existing record in the store, if a version matches, using an annotated object as the source.
|
Long |
updateWithVersion(long version,
String context,
String key,
Object value,
StorageSerializer serializer,
Long expiration)
Updates an existing record in the store, if a version matches, using a custom serialization strategy.
|
setIdgetIddestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, delete, deleteContext, deleteWithVersion, read, read, reap, update, updateContextExpiration, updateExpiration, updateWithVersion@Duration @NonNegative private long cleanupInterval
private Timer cleanupTaskTimer
private Timer internalTaskTimer
private TimerTask cleanupTask
@Positive private int contextSize
@Positive private int keySize
@Positive private int valueSize
@NonNegative @Duration public long getCleanupInterval()
@Duration
public void setCleanupInterval(@Duration@NonNegative
long interval)
interval - number of milliseconds between one cleanup and another@Nullable public Timer getCleanupTaskTimer()
public void setCleanupTaskTimer(@Nullable Timer timer)
timer - timer used to schedule configuration reload tasks@Nullable protected TimerTask getCleanupTask()
The default implementation does not supply one.
public void setContextSize(@Positive
int size)
size - limit on context size in characterspublic void setKeySize(@Positive
int size)
size - size limit on key size in characterspublic void setValueSize(@Positive
int size)
size - size limit on value size in charactersprotected void doInitialize()
throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
doInitialize in class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponentnet.shibboleth.utilities.java.support.component.ComponentInitializationExceptionprotected void doDestroy()
doDestroy in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent@Nonnull public StorageCapabilities getCapabilities()
getCapabilities in interface StorageServicepublic int getContextSize()
getContextSize in interface StorageCapabilitiespublic int getKeySize()
getKeySize in interface StorageCapabilitiespublic long getValueSize()
getValueSize in interface StorageCapabilitiespublic boolean create(@Nonnull@NotEmpty String context, @Nonnull@NotEmpty String key, @Nonnull Object value, @Nonnull StorageSerializer serializer, @Nullable@Positive Long expiration) throws IOException
create in interface StorageServicecontext - a storage context labelkey - a key unique to contextvalue - object to storeserializer - custom serializer for the objectexpiration - expiration for record, or nullIOException - if fatal errors occur in the insertion processpublic boolean create(@Nonnull Object value) throws IOException
The individual parameters for the creation are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
create in interface StorageServicevalue - object to storeIOException - if fatal errors occur in the insertion process@Nullable public Object read(@Nonnull Object value) throws IOException
The context and key to look up are obtained from the target object, and the value and expiration are written back, using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
read in interface StorageServicevalue - object to look up and populateIOException - if errors occur in the read processpublic boolean update(@Nonnull@NotEmpty String context, @Nonnull@NotEmpty String key, @Nonnull Object value, @Nonnull StorageSerializer serializer, @Nullable@Positive Long expiration) throws IOException
update in interface StorageServicecontext - a storage context labelkey - a key unique to contextvalue - updated valueserializer - custom serializerexpiration - expiration for record, or nullIOException - if errors occur in the update process@Nullable public Long updateWithVersion(@Positive long version, @Nonnull@NotEmpty String context, @Nonnull@NotEmpty String key, @Nonnull Object value, @Nonnull StorageSerializer serializer, @Nullable@Positive Long expiration) throws IOException, VersionMismatchException
updateWithVersion in interface StorageServiceversion - only update if the current version matches this valuecontext - a storage context labelkey - a key unique to contextvalue - updated valueserializer - custom serializerexpiration - expiration for record, or nullIOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionpublic boolean update(@Nonnull Object value) throws IOException
The individual parameters for the update are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
update in interface StorageServicevalue - object to update fromIOException - if errors occur in the update process@Nullable public Long updateWithVersion(@Positive long version, @Nonnull Object value) throws IOException, VersionMismatchException
The individual parameters for the update are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
updateWithVersion in interface StorageServiceversion - only update if the current version matches this valuevalue - object to update fromIOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionpublic boolean updateExpiration(@Nonnull Object value) throws IOException
The individual parameters for the update are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
updateExpiration in interface StorageServicevalue - object to update fromIOException - if errors occur in the update processpublic boolean delete(@Nonnull Object value) throws IOException
The individual parameters for the deletion are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
delete in interface StorageServicevalue - object to deleteIOException - if errors occur in the deletion processpublic boolean deleteWithVersion(@Positive
long version,
@Nonnull
Object value)
throws IOException,
VersionMismatchException
The individual parameters for the deletion are extracted from the object using the annotations in the org.opensaml.storage.annotation package. If any are missing, or a field inaccessible, a runtime exception of some kind will occur.
deleteWithVersion in interface StorageServiceversion - record version to deletevalue - object to deleteIOException - if errors occur in the deletion processVersionMismatchException - if the record has already been updated to a newer versionCopyright © 1999–2016 Shibboleth Consortium. All rights reserved.