Permalink
Browse files

Resolves Spec Issue #104: Removed ReadListeners

  • Loading branch information...
1 parent 960a9d0 commit f7ef0c3019837459156ed84c1311051944f8f0a6 Brian Oliver committed Mar 25, 2013
@@ -35,7 +35,6 @@
import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryListenerException;
import javax.cache.event.CacheEntryListenerRegistration;
-import javax.cache.event.CacheEntryReadListener;
import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.event.CacheEntryUpdatedListener;
import javax.cache.event.CompletionListener;
@@ -479,8 +478,6 @@ public V getAndPut(K key, V value) {
} else {
V oldValue = valueConverter.fromInternal(cachedValue.getInternalValue(now));
- dispatcher.addEvent(CacheEntryReadListener.class, new RICacheEntryEvent<K, V>(this, key, oldValue));
-
Duration duration = expiryPolicy.getTTLForModifiedEntry(entry,
new Duration(now, cachedValue.getExpiryTime()));
long expiryTime = duration.getAdjustedTime(now);
@@ -798,7 +795,6 @@ public V getAndRemove(K key) {
CacheEntryEvent<K, V> event = new RICacheEntryEvent<K, V>(this, key, result);
RICacheEventEventDispatcher<K, V> dispatcher = new RICacheEventEventDispatcher<K, V>();
- dispatcher.addEvent(CacheEntryReadListener.class, event);
dispatcher.addEvent(CacheEntryRemovedListener.class, event);
dispatcher.dispatch(cacheEntryListenerRegistrations.values());
}
@@ -954,7 +950,6 @@ public V getAndReplace(K key, V value) {
cachedValue.setExpiryTime(expiryTime);
RICacheEventEventDispatcher<K, V> dispatcher = new RICacheEventEventDispatcher<K, V>();
- dispatcher.addEvent(CacheEntryReadListener.class, new RICacheEntryEvent<K, V>(this, key, result));
dispatcher.addEvent(CacheEntryUpdatedListener.class, new RICacheEntryEvent<K, V>(this, key, value, result));
dispatcher.dispatch(cacheEntryListenerRegistrations.values());
}
@@ -1495,13 +1490,9 @@ private V getValue(K key, RICacheEventEventDispatcher<K, V> dispatcher) {
if (cachedValue.isExpiredAt(now)) {
return null;
} else {
-
-
entries.put(internalKey, cachedValue);
dispatcher.addEvent(CacheEntryCreatedListener.class, new RICacheEntryEvent<K, V>(this, key, value));
-
- dispatcher.addEvent(CacheEntryReadListener.class, new RICacheEntryEvent<K, V>(this, key, value));
}
} else {
value = valueConverter.fromInternal(cachedValue.getInternalValue(now));
@@ -1511,8 +1502,6 @@ private V getValue(K key, RICacheEventEventDispatcher<K, V> dispatcher) {
long expiryTime = duration.getAdjustedTime(now);
cachedValue.setExpiryTime(expiryTime);
- dispatcher.addEvent(CacheEntryReadListener.class, new RICacheEntryEvent<K, V>(this, key, value));
-
if (statisticsEnabled()) {
statistics.increaseCacheHits(1);
}
@@ -1673,12 +1662,6 @@ public boolean hasNext() {
//remember the lastEntry (so that we call allow for removal)
lastEntry = nextEntry;
- //raise "read" event
- RICacheEventEventDispatcher<K, V> dispatcher = new RICacheEventEventDispatcher<K, V>();
- dispatcher.addEvent(CacheEntryReadListener.class,
- new RICacheEntryEvent<K, V>(RICache.this, lastEntry.getKey(), lastEntry.getValue()));
- dispatcher.dispatch(cacheEntryListenerRegistrations.values());
-
//reset nextEntry to force fetching the next available entry
nextEntry = null;
@@ -1927,10 +1910,6 @@ public V getValue() {
} else if (value == null) {
Object internalValue = cachedValue.getInternalValue(now);
value = internalValue == null ? null : (V)RICache.this.valueConverter.fromInternal(internalValue);
-
- if (value != null) {
- dispatcher.addEvent(CacheEntryReadListener.class, new RICacheEntryEvent<K, V>(RICache.this, key, value));
- }
}
}
@@ -22,7 +22,6 @@
import javax.cache.event.CacheEntryExpiredListener;
import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryListenerRegistration;
-import javax.cache.event.CacheEntryReadListener;
import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.event.CacheEntryUpdatedListener;
import java.util.ArrayList;
@@ -139,22 +138,7 @@ public void dispatch(Iterable<CacheEntryListenerRegistration<? super K, ? super
}
}
}
-
- //notify read listeners
- events = eventMap.get(CacheEntryReadListener.class);
- if (events != null) {
- for (CacheEntryListenerRegistration<? super K, ? super V> registration : registrations) {
- CacheEntryEventFilter<? super K, ? super V> filter = registration.getCacheEntryFilter();
- Iterable<CacheEntryEvent<K, V>> iterable =
- filter == null ? events : new RICacheEntryEventFilteringIterable<K, V>(events, filter);
- CacheEntryListener<? super K, ? super V> listener = registration.getCacheEntryListener();
- if (listener instanceof CacheEntryReadListener) {
- ((CacheEntryReadListener) listener).onRead(iterable);
- }
- }
- }
-
//notify update listeners
events = eventMap.get(CacheEntryUpdatedListener.class);
if (events != null) {

0 comments on commit f7ef0c3

Please sign in to comment.