|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.util.Maps.CacheStrategy<K,V>
public abstract static class Maps.CacheStrategy<K,V>
An abstract caching strategy for a cache map
.
Implementations override one or more methods of this class to configure the cache map, to track its contents, and to evict stale values.
Implementations can configure the following immutable properties of the cache map:
Two methods that are of particular use in implementing an eviction strategy are Maps.CacheMap.getEldestEntry()
and Maps.CacheMap.evictEntry(oracle.javatools.util.Maps.LinkedEntry<K, V>)
.
Field Summary | |
---|---|
static Maps.CacheMap.Canonicity |
CANONICAL |
static int |
DEFAULT_INITIAL_CAPACITY |
static float |
DEFAULT_LOAD_FACTOR |
static Maps.CacheMap.Strength |
HARD Deprecated. Use STRONG . |
static Maps.CacheMap.Canonicity |
NONCANONICAL Deprecated. Use NOT_CANONICAL . |
static Maps.CacheMap.Canonicity |
NOT_CANONICAL |
static Maps.CacheMap.Strength |
SOFT |
static Maps.CacheMap.Strength |
STRONG |
static Maps.CacheMap.Strength |
WEAK |
Constructor Summary | |
---|---|
protected |
Maps.CacheStrategy(int initialCapacity, float loadFactor, Maps.CacheMap.Canonicity canonicity, Maps.CacheMap.Strength defaultStrength) Constructs a cache strategy. |
Method Summary | |
---|---|
protected Maps.LinkedEntry<K,V> |
createDefaultEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next) |
protected Maps.LinkedEntry<K,V> |
createEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue) |
protected Maps.LinkedEntry<K,V> |
createEvictedEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue) |
protected Maps.LinkedEntry<K,V> |
createSoftEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue) |
protected Maps.LinkedEntry<K,V> |
createWeakEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue) |
protected void |
entryAccessed(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry) Invoked when the value of an existing entry is accessed by Maps.AbstractHashMap.get(java.lang.Object) . |
protected void |
entryAdded(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry) Invoked when a new entry is added to this map, when entries are added by Maps.AbstractHashMap.put(K, V) . |
protected void |
entryChanged(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> oldEntry, V oldValue, Maps.LinkedEntry<K,V> newEntry) Invoked when the value of an existing entry is changed or when entries are changed by Maps.AbstractHashMap.put(K, V) . |
protected void |
entryEvicted(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry) Invoked when an existing entry is evicted by Maps.AbstractLinkedHashMap.evictEntry(E) . |
protected void |
entryPurged(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry) Invoked when an existing entry is purged after its value has been garbage collected. |
protected void |
entryRemoved(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry) Invoked when an existing entry is removed by a remove method of this map, of a view collection of this map, or of an iterator of a view collection of this map The |
Maps.CacheMap.Canonicity |
getCanonicity() Gets whether the cache maps canonically. |
Maps.CacheMap.Strength |
getDefaultStrength() Gets the value reference type of the cache map. |
int |
getInitialCapacity() Gets the initial capacity of the cache map. |
float |
getLoadFactor() Gets the load factor of the cache map. |
protected void |
mapChanged(Maps.CacheMap<K,V> map) Invoked when the map has changed, when entries are added, removed, or accessed. |
protected void |
mapConstructed(Maps.CacheMap<K,V> map) Invoked when the map has constructed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_INITIAL_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
public static final Maps.CacheMap.Strength STRONG
public static final Maps.CacheMap.Strength SOFT
public static final Maps.CacheMap.Strength WEAK
public static final Maps.CacheMap.Strength HARD
STRONG
.public static final Maps.CacheMap.Canonicity CANONICAL
public static final Maps.CacheMap.Canonicity NOT_CANONICAL
public static final Maps.CacheMap.Canonicity NONCANONICAL
NOT_CANONICAL
.Constructor Detail |
---|
protected Maps.CacheStrategy(int initialCapacity, float loadFactor, Maps.CacheMap.Canonicity canonicity, Maps.CacheMap.Strength defaultStrength)
Method Detail |
---|
public int getInitialCapacity()
public float getLoadFactor()
public Maps.CacheMap.Canonicity getCanonicity()
public Maps.CacheMap.Strength getDefaultStrength()
protected Maps.LinkedEntry<K,V> createEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue)
The Maps.CacheMap
implementation delegates to createDefaultEntry(int, K, V, oracle.javatools.util.Maps.LinkedEntry<K, V>)
, createSoftEntry(int, K, V, oracle.javatools.util.Maps.LinkedEntry<K, V>, java.lang.ref.ReferenceQueue<V>)
, or createWeakEntry(int, K, V, oracle.javatools.util.Maps.LinkedEntry<K, V>, java.lang.ref.ReferenceQueue<V>)
as indicated by getDefaultStrength()
.
protected Maps.LinkedEntry<K,V> createDefaultEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next)
protected Maps.LinkedEntry<K,V> createSoftEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue)
protected Maps.LinkedEntry<K,V> createWeakEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue)
protected Maps.LinkedEntry<K,V> createEvictedEntry(int hashCode, K key, V value, Maps.LinkedEntry<K,V> next, java.lang.ref.ReferenceQueue<V> queue)
protected void mapConstructed(Maps.CacheMap<K,V> map)
The Maps.CacheStrategy
implementation does nothing.
protected void mapChanged(Maps.CacheMap<K,V> map)
entryAdded(oracle.javatools.util.Maps.CacheMap<K, V>, oracle.javatools.util.Maps.LinkedEntry<K, V>)
, entryRemoved(oracle.javatools.util.Maps.CacheMap<K, V>, oracle.javatools.util.Maps.LinkedEntry<K, V>)
, or entryAccessed(oracle.javatools.util.Maps.CacheMap<K, V>, oracle.javatools.util.Maps.LinkedEntry<K, V>)
method is invoked.
The Maps.CacheStrategy
implementation does nothing.
protected void entryAdded(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry)
Maps.AbstractHashMap.put(K, V)
.
The Maps.CacheStrategy
implementation does nothing.
protected void entryChanged(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> oldEntry, V oldValue, Maps.LinkedEntry<K,V> newEntry)
Maps.AbstractHashMap.put(K, V)
.
If the entry to change was mutable, its value is changed with Map.Entry#setValue
and oldEntry and newEntry are the same object. If the entry to change was not mutable, a new entry must be created and oldEntry and newEntry are different objects.
When a client directly invokes the Map.Entry#setValue
method of any of the Map.Entry
implementations provided in this class, this method is not invoked (while this could be addressed, it would require each entry instance to hold a reference to its map).
The Maps.CacheStrategy
implementation does nothing.
oldEntry
- The existing entry that changed.oldValue
- The old value of the entry.newEntry
- The new entry, which may be the same as the old.protected void entryAccessed(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry)
Maps.AbstractHashMap.get(java.lang.Object)
. Access to an entry by iterating a view collection of this map does not cause this method to be invoked.
The Maps.CacheStrategy
implementation does nothing.
protected void entryRemoved(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry)
The Maps.CacheMap
implementation never invokes entryRemoved(oracle.javatools.util.Maps.CacheMap<K, V>, oracle.javatools.util.Maps.LinkedEntry<K, V>)
when entries are removed by the Maps.CacheMap.clear()
method of this map, or of a view collection of this map.
The Maps.CacheStrategy
implementation does nothing.
protected void entryPurged(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry)
The Maps.CacheMap
implementation only ever invokes entryPurged(oracle.javatools.util.Maps.CacheMap<K, V>, oracle.javatools.util.Maps.LinkedEntry<K, V>)
for entries which extend SoftReference
or WeakReference
and which register themselves with the ReferenceQueue
returned by Maps.AbstractHashMap.getQueue()
. Maps
provides four such classes: Maps.SoftEntry
, Maps.WeakEntry
, Maps.SoftLinkedEntry
, and Maps.WeakLinkedEntry
.
The Maps.CacheStrategy
implementation does nothing.
protected void entryEvicted(Maps.CacheMap<K,V> map, Maps.LinkedEntry<K,V> entry)
Maps.AbstractLinkedHashMap.evictEntry(E)
.
If this map is canonical, eviction means the entry was converted to a weak reference and mapChanged(oracle.javatools.util.Maps.CacheMap<K, V>)
was not invoked. If the map is not canonical, eviction means the entry was removed and mapChanged(oracle.javatools.util.Maps.CacheMap<K, V>)
was invoked.
The Maps.CacheStrategy
implementation does nothing.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |