Class SuperKeyedRegistry<K,V>

java.lang.Object
org.nuxeo.ecm.automation.core.impl.SuperKeyedRegistry<K,V>
Direct Known Subclasses:
AdapterKeyedRegistry, ClassKeyedRegistry

public abstract class SuperKeyedRegistry<K,V> extends Object
A registry which is inheriting values from super keys. The super key relation is defined by the derived classes by overriding getSuperKeys(Object) method. The registry is thread safe and is optimized for lookups. A concurrent cache is dynamically updated when a value is retrieved from a super entry. The cache is removed each time a modification is made on the registry using put(Object, Object) or remove(Object) methods. Thus, for maximum performance you need to avoid modifying the registry after lookups were done: at application startup build the registry, at runtime perform lookups, at shutdown remove entries. The root key is passed in the constructor and is used to stop looking in super entries.
Author:
Bogdan Stefanescu
  • Field Details

    • registry

      protected Map<K,V> registry
    • lookup

      protected volatile ConcurrentMap<K,Object> lookup
      the cache map used for lookups. Object is used for the value to be able to insert NULL values.
  • Constructor Details

    • SuperKeyedRegistry

      public SuperKeyedRegistry()
  • Method Details

    • put

      public void put(K key, V value)
    • remove

      public V remove(K key)
    • flushCache

      public void flushCache()
    • isRoot

      protected abstract boolean isRoot(K key)
    • getSuperKeys

      protected abstract List<K> getSuperKeys(K key)
    • isCachingEnabled

      protected boolean isCachingEnabled(K key)
      Override this in order to disable caching some specific keys. For example when using java classes as keys you may want to avoid caching proxy classes. The default is to return true. (cache is enabled)
    • get

      public V get(K key)