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)
  • Field Details

    • MAX_AGE

      public static final long MAX_AGE
      The 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 interface IntegrationServiceCache<T extends Serializable>
      Parameters:
      id - the object if
      requesterId - 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 interface IntegrationServiceCache<T extends Serializable>
      Parameters:
      id - the object ID
      remove - if set, the returned object is removed from the cache
      requesterId - 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

      protected abstract AbstractIntegrationServiceCache.CacheEntry<T> getCacheEntry(String id)
      Gets the cache entry identified by id.
      Parameters:
      id - the ID
      Returns:
      the entry or null
    • put

      public void put(String id, T object, String ownerId)
      Adds an object to the cache.
      Specified by:
      put in interface IntegrationServiceCache<T extends Serializable>
      Parameters:
      id - the object ID
      object - the object to add
      ownerId - the owner identity (may be null)
    • putCacheObject

      protected abstract void putCacheObject(String id, T object, String ownerId, long expirationTime)
      Adds the supplied entry identified by id to the cache.
      Parameters:
      id - the ID
      object - the object to add
      ownerId - the owner of the object (may be null)
      expirationTime - expiration time (in millis)
    • remove

      public void remove(String id)
      Deletes an object having the given ID from the cache.
      Specified by:
      remove in interface IntegrationServiceCache<T extends Serializable>
      Parameters:
      id - the object ID
    • removeCacheObject

      protected abstract void removeCacheObject(String id)
      Removes the object identified by id.
      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