Class NameIdCache<T>

  • Type Parameters:
    T - the type of the identity value held by the cache
    All Implemented Interfaces:
    INameIdCache<T>

    public class NameIdCache<T>
    extends java.lang.Object
    implements INameIdCache<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      NameIdCache()
      Public constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntry​(java.lang.String resourceType, T resourceTypeId)
      Add the resource type to the local cache
      void clearLocalMaps()
      Clear anything cached in thread-local (after transaction rollback, for example)
      java.util.Collection<T> getAllIds()
      Get all resource type identifiers in the cache
      T getId​(java.lang.String key)
      Get the resource type identifier for the given resourceType name
      void prefill​(java.util.Map<java.lang.String,​T> content)
      Prefill the shared map with the given content (must come data already committed in the database)
      void reset()
      Clear both local shared caches - useful for unit tests
      void updateSharedMaps()
      Called after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NameIdCache

        public NameIdCache()
        Public constructor
    • Method Detail

      • updateSharedMaps

        public void updateSharedMaps()
        Description copied from interface: INameIdCache
        Called after a transaction commit() to transfer all the staged (thread-local) data over to the shared cache.
        Specified by:
        updateSharedMaps in interface INameIdCache<T>
      • getId

        public T getId​(java.lang.String key)
        Description copied from interface: INameIdCache
        Get the resource type identifier for the given resourceType name
        Specified by:
        getId in interface INameIdCache<T>
        Returns:
      • getAllIds

        public java.util.Collection<T> getAllIds()
        Description copied from interface: INameIdCache
        Get all resource type identifiers in the cache
        Specified by:
        getAllIds in interface INameIdCache<T>
        Returns:
      • addEntry

        public void addEntry​(java.lang.String resourceType,
                             T resourceTypeId)
        Description copied from interface: INameIdCache
        Add the resource type to the local cache
        Specified by:
        addEntry in interface INameIdCache<T>
      • reset

        public void reset()
        Description copied from interface: INameIdCache
        Clear both local shared caches - useful for unit tests
        Specified by:
        reset in interface INameIdCache<T>
      • clearLocalMaps

        public void clearLocalMaps()
        Description copied from interface: INameIdCache
        Clear anything cached in thread-local (after transaction rollback, for example)
        Specified by:
        clearLocalMaps in interface INameIdCache<T>
      • prefill

        public void prefill​(java.util.Map<java.lang.String,​T> content)
        Description copied from interface: INameIdCache
        Prefill the shared map with the given content (must come data already committed in the database)
        Specified by:
        prefill in interface INameIdCache<T>