Class AbstractIntegrationServiceCache<T extends Serializable>
java.lang.Object
se.idsec.signservice.integration.core.impl.AbstractIntegrationServiceCache<T>
- Type Parameters:
T
- the cachec object type
- All Implemented Interfaces:
IntegrationServiceCache<T>
- Direct Known Subclasses:
AbstractInMemoryIntegrationServiceCache
public abstract class AbstractIntegrationServiceCache<T extends Serializable>
extends Object
implements IntegrationServiceCache<T>
Base class for an implementation of the
IntegrationServiceCache
interface.- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Representation of a cache entry. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
The default max age (in millis) to keep an object in the cache. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets an object from the cache.Gets an object from the cache.protected abstract AbstractIntegrationServiceCache.CacheEntry
<T> getCacheEntry
(String id) Gets the cache entry identified byid
.void
Adds an object to the cache.protected abstract void
putCacheObject
(String id, T object, String ownerId, long expirationTime) Adds the supplied entry identified byid
to the cache.void
Deletes an object having the given ID from the cache.protected abstract void
Removes the object identified byid
.void
setMaxAge
(long maxAge) Assigns the maximum time (in millis) to keep an object in the cache.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface se.idsec.signservice.integration.core.IntegrationServiceCache
clearExpired
-
Field Details
-
MAX_AGE
public static final long MAX_AGEThe default max age (in millis) to keep an object in the cache.- See Also:
-
-
Constructor Details
-
AbstractIntegrationServiceCache
public AbstractIntegrationServiceCache()
-
-
Method Details
-
get
public T get(String id, String requesterId) throws se.idsec.signservice.integration.core.error.NoAccessException Gets an object from the cache.Corresponds to
get(id, false)
.- Specified by:
get
in interfaceIntegrationServiceCache<T extends Serializable>
- Parameters:
id
- the object ifrequesterId
- optional ID of the requesting actor- Returns:
- the object, or null if it does not exist
- Throws:
se.idsec.signservice.integration.core.error.NoAccessException
- if the owner of the cached object does not match the requester ID
-
get
public T get(String id, boolean remove, String requesterId) throws se.idsec.signservice.integration.core.error.NoAccessException Gets an object from the cache.If the
remove
flag is set, the cached object is removed from the cache.- Specified by:
get
in interfaceIntegrationServiceCache<T extends Serializable>
- Parameters:
id
- the object IDremove
- if set, the returned object is removed from the cacherequesterId
- optional ID of the requesting actor- Returns:
- the object, or null if it does not exist
- Throws:
se.idsec.signservice.integration.core.error.NoAccessException
- if the owner of the cached object does not match the requester ID
-
getCacheEntry
Gets the cache entry identified byid
.- Parameters:
id
- the ID- Returns:
- the entry or null
-
put
Adds an object to the cache.- Specified by:
put
in interfaceIntegrationServiceCache<T extends Serializable>
- Parameters:
id
- the object IDobject
- the object to addownerId
- the owner identity (may be null)
-
putCacheObject
Adds the supplied entry identified byid
to the cache.- Parameters:
id
- the IDobject
- the object to addownerId
- the owner of the object (may be null)expirationTime
- expiration time (in millis)
-
remove
Deletes an object having the given ID from the cache.- Specified by:
remove
in interfaceIntegrationServiceCache<T extends Serializable>
- Parameters:
id
- the object ID
-
removeCacheObject
Removes the object identified byid
.- Parameters:
id
- the ID
-
setMaxAge
public void setMaxAge(long maxAge) Assigns the maximum time (in millis) to keep an object in the cache. Default is 3600000L<T extends Serializable>.- Parameters:
maxAge
- age in millis
-