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.
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.
|
setId
getId
destroy, initialize, isDestroyed, isInitialized
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create, delete, deleteContext, deleteWithVersion, read, read, reap, update, updateContextExpiration, updateExpiration, updateWithVersion
@NonNegative public long getCleanupInterval()
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.AbstractIdentifiedInitializableComponent
net.shibboleth.utilities.java.support.component.ComponentInitializationException
protected void doDestroy()
doDestroy
in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
@Nonnull public StorageCapabilities getCapabilities()
getCapabilities
in interface StorageService
public int getContextSize()
getContextSize
in interface StorageCapabilities
public int getKeySize()
getKeySize
in interface StorageCapabilities
public long getValueSize()
getValueSize
in interface StorageCapabilities
public 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 StorageService
context
- 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 StorageService
value
- 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 StorageService
value
- 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 StorageService
context
- 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 StorageService
version
- 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 StorageService
value
- 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 StorageService
version
- 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 StorageService
value
- 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 StorageService
value
- 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 StorageService
version
- 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 © 2016. All rights reserved.