@ThreadSafeAfterInit
public interface StorageService
extends net.shibboleth.utilities.java.support.component.IdentifiedComponent
StorageCapabilities
interface to describe storage limitations.
Storage is divided into "contexts" identified by a string label. Keys need to be unique only within a given context, so multiple components can share a single store safely as long as they use different labels.
The allowable sizes for contexts and keys can vary and be reported by the implementation to callers, but MUST be at least 255 characters.
Expiration is expressed in milliseconds since the beginning of the epoch, or a null can be used to signify no expiration.
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 |
create(String context,
String key,
String value,
Long expiration)
Creates a new record in the store with an expiration.
|
boolean |
delete(Object value)
Deletes an existing record from the store, using an annotated object as the source.
|
boolean |
delete(String context,
String key)
Deletes an existing record from the store.
|
void |
deleteContext(String context)
Forcibly removes all records in a given context along with any
associated resources devoted to maintaining the context.
|
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.
|
boolean |
deleteWithVersion(long version,
String context,
String key)
Deletes an existing record from the store if it currently has a specified version.
|
StorageCapabilities |
getCapabilities()
Returns the capabilities of the underlying store.
|
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.
|
StorageRecord |
read(String context,
String key)
Returns an existing record from the store, if one exists.
|
net.shibboleth.utilities.java.support.collection.Pair<Long,StorageRecord> |
read(String context,
String key,
long version)
Returns an existing record from the store, along with its version.
|
void |
reap(String context)
Manually trigger a cleanup of expired records.
|
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 |
update(String context,
String key,
String value,
Long expiration)
Updates an existing record in the store.
|
void |
updateContextExpiration(String context,
Long expiration)
Updates the expiration time of all records in the context.
|
boolean |
updateExpiration(Object value)
Updates expiration of an existing record in the store, using an annotated object as the source.
|
boolean |
updateExpiration(String context,
String key,
Long expiration)
Updates expiration of an existing record in the store.
|
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.
|
Long |
updateWithVersion(long version,
String context,
String key,
String value,
Long expiration)
Updates an existing record in the store, if a version matches.
|
@Nonnull StorageCapabilities getCapabilities()
boolean create(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextvalue
- value to storeexpiration
- expiration for record, or nullIOException
- if fatal errors occur in the insertion processboolean create(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull Object value, @Nonnull StorageSerializer serializer, @Nullable @Positive Long expiration) throws IOException
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 processboolean 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.
value
- object to storeIOException
- if fatal errors occur in the insertion process@Nullable StorageRecord read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
context
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the read process@Nullable 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.
value
- object to look up and populateIOException
- if errors occur in the read process@Nonnull net.shibboleth.utilities.java.support.collection.Pair<Long,StorageRecord> read(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Positive long version) throws IOException
The first member of the pair returned will contain the version of the record in the store, or will be null if no record exists. The second member will contain the record read back. If null, the record either didn't exist (if the first member was also null) or the record was the same version as that supplied by the caller.
context
- a storage context labelkey
- a key unique to contextversion
- only return record if newer than supplied versionIOException
- if errors occur in the read processboolean update(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextvalue
- updated valueexpiration
- expiration for record, or nullIOException
- if errors occur in the update process@Nullable Long updateWithVersion(@Positive long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull @NotEmpty String value, @Nullable @Positive Long expiration) throws IOException, VersionMismatchException
version
- only update if the current version matches this valuecontext
- a storage context labelkey
- a key unique to contextvalue
- updated valueexpiration
- expiration for record, or nullIOException
- if errors occur in the update processVersionMismatchException
- if the record has already been updated to a newer versionboolean update(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nonnull Object value, @Nonnull StorageSerializer serializer, @Nullable @Positive Long expiration) throws IOException
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 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
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 versionboolean 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.
value
- object to update fromIOException
- if errors occur in the update process@Nullable 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.
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 versionboolean updateExpiration(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key, @Nullable @Positive Long expiration) throws IOException
context
- a storage context labelkey
- a key unique to contextexpiration
- expiration for record, or nullIOException
- if errors occur in the update processboolean 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.
value
- object to update fromIOException
- if errors occur in the update processboolean delete(@Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException
context
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the deletion processboolean deleteWithVersion(@Positive long version, @Nonnull @NotEmpty String context, @Nonnull @NotEmpty String key) throws IOException, VersionMismatchException
version
- record version to deletecontext
- a storage context labelkey
- a key unique to contextIOException
- if errors occur in the deletion processVersionMismatchException
- if the record has already been updated to a newer versionboolean 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.
value
- object to deleteIOException
- if errors occur in the deletion processboolean 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.
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 versionvoid reap(@Nonnull @NotEmpty String context) throws IOException
context
- a storage context labelIOException
- if errors occur in the cleanup processvoid updateContextExpiration(@Nonnull @NotEmpty String context, @Nullable Long expiration) throws IOException
context
- a storage context labelexpiration
- a new expiration timestamp, or nullIOException
- if errors occur in the cleanup processvoid deleteContext(@Nonnull @NotEmpty String context) throws IOException
context
- a storage context labelIOException
- if errors occur in the cleanup processCopyright © 2017. All rights reserved.