Class AbstractKeyBasedMap.DeferredCacheEvent<K,V>
- java.lang.Object
-
- java.util.EventObject
-
- com.tangosol.util.MapEvent<K,V>
-
- com.tangosol.net.cache.CacheEvent<K,V>
-
- com.tangosol.util.AbstractKeyBasedMap.DeferredCacheEvent<K,V>
-
- All Implemented Interfaces:
PortableObject
,Serializable
- Enclosing class:
- AbstractKeyBasedMap<K,V>
protected abstract static class AbstractKeyBasedMap.DeferredCacheEvent<K,V> extends CacheEvent<K,V>
A DeferredCacheEvent is aCacheEvent
object that defers the loading of theold value
.This event has two predominant states; active and inactive. The event is active from incarnation and can transition to inactive (via
deactivate()
) but not vice-versa. Being active allows the getOldValue implementation to load the value from underlying map, thus all consumers of this event must ensure they call getOldValue prior to returning control when this event is dispatched.Once inactive the correct value may no longer be available in the map thus in this state a getOldValue will return either null or the cached old value.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.net.cache.CacheEvent
CacheEvent.TransformationState
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_fActive
Whether the DeferredCacheEvent is in an active or inactive state.-
Fields inherited from class com.tangosol.net.cache.CacheEvent
EXPIRED, m_nFlags, m_transformState, PRIMING, SYNTHETIC
-
Fields inherited from class com.tangosol.util.MapEvent
ENTRY_DELETED, ENTRY_INSERTED, ENTRY_UPDATED, m_key, m_nId, m_nPartition, m_nVersion, m_valueNew, m_valueOld
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description DeferredCacheEvent(ObservableMap<K,V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic)
Constructs a new DeferredCacheEvent.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
deactivate()
Deactivate this DeferredCacheEvent instance.V
getOldValue()
Return an old value associated with this event.protected abstract V
readOldValue()
Perform a deferred read for the old value in a usage-specific way.-
Methods inherited from class com.tangosol.net.cache.CacheEvent
getDescription, getTransformationState, isExpired, isPriming, isSynthetic, isVersionUpdate, shouldDispatch, with
-
Methods inherited from class com.tangosol.util.MapEvent
dispatch, dispatch, dispatch, getDescription, getId, getKey, getMap, getNewEntry, getNewValue, getOldEntry, getPartition, getVersion, isDelete, isInsert, isUpdate, readExternal, toString, writeExternal
-
Methods inherited from class java.util.EventObject
getSource
-
-
-
-
Constructor Detail
-
DeferredCacheEvent
public DeferredCacheEvent(ObservableMap<K,V> map, int nId, K oKey, V oValueOld, V oValueNew, boolean fSynthetic)
Constructs a new DeferredCacheEvent.- Parameters:
map
- the ObservableMapnId
- this event's id, one ofMapEvent.ENTRY_INSERTED
,MapEvent.ENTRY_UPDATED
orMapEvent.ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)fSynthetic
- true iff the event is caused by the cache internal processing such as eviction or loading
-
-
Method Detail
-
getOldValue
public V getOldValue()
Return an old value associated with this event.The old value represents a value deleted from or updated in a map. It is always null for "insert" notifications.
- Overrides:
getOldValue
in classMapEvent<K,V>
- Returns:
- an old value
-
readOldValue
protected abstract V readOldValue()
Perform a deferred read for the old value in a usage-specific way.- Returns:
- the old value
-
deactivate
public void deactivate()
Deactivate this DeferredCacheEvent instance. This is used to prevent futuregetOldValue()
calls using the underlying map *after* the event dispatching code returned and the content of the map had been changed to a new value.The contract between the DeferredCacheEvent and consumers of the event states that consumers must call
getOldValue
prior to returning from event dispatching logic.
-
-