Class ReadonlyNamedCache<K,V>

Type Parameters:
K - the type of the cache entry keys
V - the type of the cache entry values
All Implemented Interfaces:
CacheMap<K,V>, NamedCache<K,V>, NamedCollection, NamedMap<K,V>, Releasable, ConcurrentMap<K,V>, InvocableMap<K,V>, ObservableMap<K,V>, QueryMap<K,V>, AutoCloseable, Map<K,V>

public class ReadonlyNamedCache<K,V> extends WrapperNamedCache<K,V>
A simple extension of the WrapperNamedCache implementation that shields all content mutating operations such as put(), remove(), lock() etc.
Author:
gg 2006.08.06
  • Field Details

    • m_fStrict

      protected boolean m_fStrict
      Specifies whether or not the "read-only" nature of this NamedCache is strictly enforced.
  • Constructor Details

    • ReadonlyNamedCache

      public ReadonlyNamedCache(NamedCache<K,V> cache, boolean fStrict)
      Construct a NamedCache wrapper based on the specified map.
      Parameters:
      cache - the NamedCache object that will be wrapped by this read-only wrapper
      fStrict - if true, calls to mutating operations will throw the UnsupportedOperationException; otherwise those calls will have no effect whatsoever
    • ReadonlyNamedCache

      public ReadonlyNamedCache(Map<K,V> map, String sName, boolean fStrict)
      Construct a NamedCache wrapper based on the specified map.
      Parameters:
      map - the Map that will be wrapped by this read-only wrapper
      sName - the cache name
      fStrict - if true, calls to mutating operations will throw the UnsupportedOperationException; otherwise those calls will have no effect whatsoever
  • Method Details

    • destroy

      public void destroy()
      Should not be called.
      Specified by:
      destroy in interface NamedCollection
      Overrides:
      destroy in class WrapperNamedCache<K,V>
    • truncate

      public void truncate()
      Should not be called.
      Specified by:
      truncate in interface NamedMap<K,V>
      Overrides:
      truncate in class WrapperNamedCache<K,V>
    • invoke

      public <R> R invoke(K key, InvocableMap.EntryProcessor<K,V,R> agent)
      Should not be called.
      Specified by:
      invoke in interface InvocableMap<K,V>
      Overrides:
      invoke in class WrapperNamedCache<K,V>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      key - the key to process; it is not required to exist within the Map
      agent - the EntryProcessor to use to process the specified key
      Returns:
      the result of the invocation as returned from the EntryProcessor
    • invokeAll

      public <R> Map<K,R> invokeAll(Collection<? extends K> collKeys, InvocableMap.EntryProcessor<K,V,R> agent)
      Should not be called.
      Specified by:
      invokeAll in interface InvocableMap<K,V>
      Overrides:
      invokeAll in class WrapperNamedCache<K,V>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      collKeys - the keys to process; these keys are not required to exist within the Map
      agent - the EntryProcessor to use to process the specified keys
      Returns:
      a Map containing the results of invoking the EntryProcessor against each of the specified keys
    • invokeAll

      public <R> Map<K,R> invokeAll(Filter filter, InvocableMap.EntryProcessor<K,V,R> agent)
      Should not be called.
      Specified by:
      invokeAll in interface InvocableMap<K,V>
      Overrides:
      invokeAll in class WrapperNamedCache<K,V>
      Type Parameters:
      R - the type of value returned by the EntryProcessor
      Parameters:
      filter - a Filter that results in the set of keys to be processed
      agent - the EntryProcessor to use to process the specified keys
      Returns:
      a Map containing the results of invoking the EntryProcessor against the keys that are selected by the given Filter
    • put

      public V put(K oKey, V oValue)
      Should not be called.
      Specified by:
      put in interface CacheMap<K,V>
      Specified by:
      put in interface ConcurrentMap<K,V>
      Specified by:
      put in interface Map<K,V>
      Overrides:
      put in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key with which the specified value is to be associated
      oValue - value to be associated with the specified key
      Returns:
      previous value associated with specified key, or null if there was no mapping for key
    • putAll

      public void putAll(Map<? extends K,? extends V> map)
      Should not be called.
      Specified by:
      putAll in interface ConcurrentMap<K,V>
      Specified by:
      putAll in interface Map<K,V>
      Overrides:
      putAll in class WrapperConcurrentMap<K,V>
      Parameters:
      map - the Map containing the key/value pairings to put into this Map
    • remove

      public V remove(Object oKey)
      Should not be called.
      Specified by:
      remove in interface ConcurrentMap<K,V>
      Specified by:
      remove in interface Map<K,V>
      Overrides:
      remove in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key whose mapping is to be removed from the map
      Returns:
      previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
    • clear

      public void clear()
      Should not be called.
      Specified by:
      clear in interface ConcurrentMap<K,V>
      Specified by:
      clear in interface Map<K,V>
      Specified by:
      clear in interface NamedMap<K,V>
      Overrides:
      clear in class WrapperConcurrentMap<K,V>
    • lock

      public boolean lock(Object oKey, long cWait)
      Should not be called.
      Specified by:
      lock in interface ConcurrentMap<K,V>
      Overrides:
      lock in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key being locked
      cWait - the number of milliseconds to continue trying to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtained
      Returns:
      true if the item was successfully locked within the specified time; false otherwise
    • lock

      public boolean lock(Object oKey)
      Should not be called.
      Specified by:
      lock in interface ConcurrentMap<K,V>
      Overrides:
      lock in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key being locked
      Returns:
      true if the item was successfully locked; false otherwise
    • unlock

      public boolean unlock(Object oKey)
      Should not be called.
      Specified by:
      unlock in interface ConcurrentMap<K,V>
      Overrides:
      unlock in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key being unlocked
      Returns:
      true if the item was successfully unlocked; false otherwise
    • removeBlind

      protected boolean removeBlind(Object oKey)
      Should not be called.
      Overrides:
      removeBlind in class WrapperConcurrentMap<K,V>
      Parameters:
      oKey - key whose mapping is to be removed from the map
      Returns:
      true iff the Map changed as the result of this operation
    • checkStrict

      protected void checkStrict()
      Enforce the "strict" read-only policy.