Class 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 Detail

      • 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.
    • Method Detail

      • put

        public void put​(K key,
                        V value)
      • isRoot

        protected abstract boolean isRoot​(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)