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 java.util.TimerTask |
cleanupTask
Task that cleans up expired records.
|
private java.util.Timer |
cleanupTaskTimer
Timer used to schedule cleanup tasks.
|
private int |
contextSize
Configurable context size limit.
|
private java.util.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(java.lang.Object value)
Creates a new record in the store using an annotated object as the source.
|
boolean |
create(java.lang.String context,
java.lang.String key,
java.lang.Object value,
StorageSerializer serializer,
java.lang.Long expiration)
Creates a new record in the store with an expiration, using a custom serialization
process for an arbitrary object.
|
boolean |
delete(java.lang.Object value)
Deletes an existing record from the store, using an annotated object as the source.
|
boolean |
deleteWithVersion(long version,
java.lang.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 java.util.TimerTask |
getCleanupTask()
Returns a cleanup task function to schedule for background cleanup.
|
java.util.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.
|
java.lang.Object |
read(java.lang.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(java.util.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(java.lang.Object value)
Updates an existing record in the store, using an annotated object as the source.
|
boolean |
update(java.lang.String context,
java.lang.String key,
java.lang.Object value,
StorageSerializer serializer,
java.lang.Long expiration)
Updates an existing record in the store using a custom serialization strategy.
|
boolean |
updateExpiration(java.lang.Object value)
Updates expiration of an existing record in the store, using an annotated object as the source.
|
java.lang.Long |
updateWithVersion(long version,
java.lang.Object value)
Updates an existing record in the store, if a version matches, using an annotated object as the source.
|
java.lang.Long |
updateWithVersion(long version,
java.lang.String context,
java.lang.String key,
java.lang.Object value,
StorageSerializer serializer,
java.lang.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 java.util.Timer cleanupTaskTimer
private java.util.Timer internalTaskTimer
private java.util.TimerTask cleanupTask
@Positive private int contextSize
@Positive private int keySize
@Positive private int valueSize
@NonNegative public long getCleanupInterval()
public void setCleanupInterval(@Duration @NonNegative
long interval)
interval - number of milliseconds between one cleanup and another@Nullable public java.util.Timer getCleanupTaskTimer()
public void setCleanupTaskTimer(@Nullable
java.util.Timer timer)
timer - timer used to schedule configuration reload tasks@Nullable protected java.util.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
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull
java.lang.Object value,
@Nonnull
StorageSerializer serializer,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.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 nulljava.io.IOException - if fatal errors occur in the insertion processpublic boolean create(@Nonnull
java.lang.Object value)
throws java.io.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 storejava.io.IOException - if fatal errors occur in the insertion process@Nullable
public java.lang.Object read(@Nonnull
java.lang.Object value)
throws java.io.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 populatejava.io.IOException - if errors occur in the read processpublic boolean update(@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull
java.lang.Object value,
@Nonnull
StorageSerializer serializer,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.IOException
update in interface StorageServicecontext - a storage context labelkey - a key unique to contextvalue - updated valueserializer - custom serializerexpiration - expiration for record, or nulljava.io.IOException - if errors occur in the update process@Nullable
public java.lang.Long updateWithVersion(@Positive
long version,
@Nonnull @NotEmpty
java.lang.String context,
@Nonnull @NotEmpty
java.lang.String key,
@Nonnull
java.lang.Object value,
@Nonnull
StorageSerializer serializer,
@Nullable @Positive
java.lang.Long expiration)
throws java.io.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 nulljava.io.IOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionpublic boolean update(@Nonnull
java.lang.Object value)
throws java.io.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 fromjava.io.IOException - if errors occur in the update process@Nullable
public java.lang.Long updateWithVersion(@Positive
long version,
@Nonnull
java.lang.Object value)
throws java.io.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 fromjava.io.IOException - if errors occur in the update processVersionMismatchException - if the record has already been updated to a newer versionpublic boolean updateExpiration(@Nonnull
java.lang.Object value)
throws java.io.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 fromjava.io.IOException - if errors occur in the update processpublic boolean delete(@Nonnull
java.lang.Object value)
throws java.io.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 deletejava.io.IOException - if errors occur in the deletion processpublic boolean deleteWithVersion(@Positive
long version,
@Nonnull
java.lang.Object value)
throws java.io.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 deletejava.io.IOException - if errors occur in the deletion processVersionMismatchException - if the record has already been updated to a newer version