public abstract class SuperKeyedRegistry<K,V> extends Object
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.Modifier and Type | Field and Description |
---|---|
protected ConcurrentMap<K,Object> |
lookup
the cache map used for lookups.
|
protected Map<K,V> |
registry |
Constructor and Description |
---|
SuperKeyedRegistry() |
Modifier and Type | Method and Description |
---|---|
void |
flushCache() |
V |
get(K key) |
protected abstract List<K> |
getSuperKeys(K key) |
protected boolean |
isCachingEnabled(K key)
Override this in order to disable caching some specific keys.
|
protected abstract boolean |
isRoot(K key) |
void |
put(K key,
V value) |
V |
remove(K key) |
protected volatile ConcurrentMap<K,Object> lookup
public SuperKeyedRegistry()
public void flushCache()
protected abstract List<K> getSuperKeys(K key)
protected boolean isCachingEnabled(K key)
Copyright © 2018 Nuxeo. All rights reserved.