Permalink
Browse files

Change listener to use a streaming approach with Iterable

  • Loading branch information...
1 parent 21c8044 commit 65640f761df40ada8953153e8434909293330e3b @gregrluck gregrluck committed Oct 31, 2012
Showing with 22 additions and 12 deletions.
  1. +22 −12 ehcache-jcache/src/main/java/net/sf/ehcache/jcache/JCacheListenerAdapter.java
View
34 ehcache-jcache/src/main/java/net/sf/ehcache/jcache/JCacheListenerAdapter.java
@@ -25,6 +25,7 @@
import javax.cache.event.CacheEntryListener;
import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.event.CacheEntryUpdatedListener;
+import java.util.ArrayList;
/**
@@ -94,11 +95,13 @@ private boolean implementsMethods(Class cls) {
@Override
public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException {
if (removedListener) {
+ ArrayList arrayList = new ArrayList();
+ arrayList.add(new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element));
if (element != null) {
((CacheEntryRemovedListener<? super K, ? super V>) cacheListener)
- .entryRemoved(
- new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element)
- );
+ .onRemoved(
+ arrayList
+ );
}
}
}
@@ -117,10 +120,12 @@ public void notifyElementRemoved(Ehcache cache, Element element) throws CacheExc
@Override
public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
if (createdListener) {
+ ArrayList arrayList = new ArrayList();
+ arrayList.add(new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element));
if (element != null) {
((CacheEntryCreatedListener<K, V>) cacheListener)
- .entryCreated(
- new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element)
+ .onCreated(
+ arrayList
);
}
}
@@ -142,10 +147,12 @@ public void notifyElementPut(Ehcache cache, Element element) throws CacheExcepti
@Override
public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
if (updatedListener) {
+ ArrayList arrayList = new ArrayList();
+ arrayList.add(new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element));
if (element != null) {
((CacheEntryCreatedListener<K, V>) cacheListener)
- .entryCreated(
- new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element)
+ .onCreated(
+ arrayList
);
}
}
@@ -172,10 +179,12 @@ public void notifyElementUpdated(Ehcache cache, Element element) throws CacheExc
@Override
public void notifyElementExpired(Ehcache cache, Element element) {
if (expiredListener) {
+ ArrayList arrayList = new ArrayList();
+ arrayList.add(new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element));
if (element != null) {
((CacheEntryExpiredListener<K, V>) cacheListener)
- .entryExpired(
- new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element)
+ .onExpired(
+ arrayList
);
}
}
@@ -194,10 +203,11 @@ public void notifyElementExpired(Ehcache cache, Element element) {
@Override
public void notifyElementEvicted(Ehcache cache, Element element) {
if (expiredListener) {
+ ArrayList arrayList = new ArrayList();
+ arrayList.add(new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element));
if (element != null) {
- ((CacheEntryExpiredListener<K, V>) cacheListener).entryExpired(
- new JCacheEntryEventAdapter<K, V>(fromEhcache(cache), element)
- );
+ ((CacheEntryExpiredListener<K, V>) cacheListener).onExpired(
+ arrayList);
}
}
}

0 comments on commit 65640f7

Please sign in to comment.