[jbosscache-commits] JBoss Cache SVN: r5884 - in core/trunk/src: test/java/org/jboss/cache/notifications and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri May 23 10:30:16 EDT 2008
Author: mircea.markus
Date: 2008-05-23 10:30:16 -0400 (Fri, 23 May 2008)
New Revision: 5884
Modified:
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
Log:
JBCACHE-1338 - NotifierImpl performance refactoring
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-05-23 10:34:25 UTC (rev 5883)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-05-23 14:30:16 UTC (rev 5884)
@@ -24,7 +24,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
/**
@@ -51,8 +50,25 @@
NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedEvent.class
};
+ private final List<ListenerInvocation> cacheStartedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> cacheStoppedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> cacheBlockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> cacheUnblockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeCreatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeRemovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeVisitedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeModifiedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeMovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeActivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodePassivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeLoadedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> nodeEvictedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> transactionRegisteredListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> transactionCompletedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> viewChangedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ private final List<ListenerInvocation> buddyGroupChangedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
+ // final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
private Cache cache;
private boolean useMarshalledValueMaps;
private Configuration config;
@@ -76,7 +92,7 @@
@Destroy
protected void destroy()
{
- listenerInvocations.clear();
+ removeAllCacheListeners();
}
@Start
@@ -133,16 +149,8 @@
private void addListenerInvocation(Class annotation, ListenerInvocation li)
{
- synchronized (listenerInvocations)
- {
- List<ListenerInvocation> l = listenerInvocations.get(annotation);
- if (l == null)
- {
- l = new CopyOnWriteArrayList<ListenerInvocation>();
- listenerInvocations.put(annotation, l);
- }
- l.add(li);
- }
+ List<ListenerInvocation> result = getListenersForAnnotation(annotation);
+ result.add(li);
}
/**
@@ -162,29 +170,19 @@
*/
public void removeCacheListener(Object listener)
{
- synchronized (listenerInvocations)
- {
- for (Class annotation : allowedMethodAnnotations) removeListenerInvocation(annotation, listener);
- }
+ for (Class annotation : allowedMethodAnnotations) removeListenerInvocation(annotation, listener);
}
private void removeListenerInvocation(Class annotation, Object listener)
{
if (listener == null) return;
-
- List<ListenerInvocation> l = listenerInvocations.get(annotation);
+ List<ListenerInvocation> l = getListenersForAnnotation(annotation);
Set<Object> markedForRemoval = new HashSet<Object>();
- if (l != null)
+ for (ListenerInvocation li : l)
{
- for (ListenerInvocation li : l)
- {
- if (listener.equals(li.target)) markedForRemoval.add(li);
- }
-
- l.removeAll(markedForRemoval);
-
- if (l.isEmpty()) listenerInvocations.remove(annotation);
+ if (listener.equals(li.target)) markedForRemoval.add(li);
}
+ l.removeAll(markedForRemoval);
}
/**
@@ -193,10 +191,23 @@
@Stop(priority = 99)
public void removeAllCacheListeners()
{
- synchronized (listenerInvocations)
- {
- listenerInvocations.clear();
- }
+ cacheStartedListeners.clear();
+ cacheStoppedListeners.clear();
+ cacheBlockedListeners.clear();
+ cacheUnblockedListeners.clear();
+ nodeCreatedListeners.clear();
+ nodeRemovedListeners.clear();
+ nodeVisitedListeners.clear();
+ nodeModifiedListeners.clear();
+ nodeMovedListeners.clear();
+ nodeActivatedListeners.clear();
+ nodePassivatedListeners.clear();
+ nodeLoadedListeners.clear();
+ nodeEvictedListeners.clear();
+ transactionRegisteredListeners.clear();
+ transactionCompletedListeners.clear();
+ viewChangedListeners.clear();
+ buddyGroupChangedListeners.clear();
}
/**
@@ -204,26 +215,30 @@
*/
public Set<Object> getCacheListeners()
{
- Set<Object> s = new HashSet<Object>();
- synchronized (listenerInvocations)
- {
- for (Class annotation : allowedMethodAnnotations)
- {
- List<ListenerInvocation> l = listenerInvocations.get(annotation);
- if (l != null)
- {
- for (ListenerInvocation li : l) s.add(li.target);
- }
- }
- }
- return Collections.unmodifiableSet(s);
+ Set<Object> result = new HashSet<Object>();
+ result.addAll(getListeningObjects(cacheStartedListeners));
+ result.addAll(getListeningObjects(cacheStoppedListeners));
+ result.addAll(getListeningObjects(cacheBlockedListeners));
+ result.addAll(getListeningObjects(cacheUnblockedListeners));
+ result.addAll(getListeningObjects(nodeCreatedListeners));
+ result.addAll(getListeningObjects(nodeRemovedListeners));
+ result.addAll(getListeningObjects(nodeVisitedListeners));
+ result.addAll(getListeningObjects(nodeModifiedListeners));
+ result.addAll(getListeningObjects(nodeMovedListeners));
+ result.addAll(getListeningObjects(nodeActivatedListeners));
+ result.addAll(getListeningObjects(nodePassivatedListeners));
+ result.addAll(getListeningObjects(nodeLoadedListeners));
+ result.addAll(getListeningObjects(nodeEvictedListeners));
+ result.addAll(getListeningObjects(transactionRegisteredListeners));
+ result.addAll(getListeningObjects(transactionCompletedListeners));
+ result.addAll(getListeningObjects(viewChangedListeners));
+ result.addAll(getListeningObjects(buddyGroupChangedListeners));
+ return Collections.unmodifiableSet(result);
}
public void notifyNodeCreated(Fqn fqn, boolean pre, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeCreated.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeCreatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -235,16 +250,14 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setType(NODE_CREATED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeCreatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeModified(Fqn fqn, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeModified.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeModifiedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -259,22 +272,19 @@
e.setModificationType(modificationType);
e.setData(dataCopy);
e.setType(NODE_MODIFIED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeModifiedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public boolean shouldNotifyOnNodeModified()
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeRemoved.class);
- return (listeners != null && !listeners.isEmpty());
+ return !nodeModifiedListeners.isEmpty();
}
public void notifyNodeRemoved(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeRemoved.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeRemovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -288,16 +298,14 @@
e.setTransaction(tx);
e.setData(dataCopy);
e.setType(NODE_REMOVED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeRemovedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeVisited(Fqn fqn, boolean pre, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeVisited.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeVisitedListeners.isEmpty())
{
Transaction tx = ctx.getTransaction();
InvocationContext backup = resetInvocationContext(ctx);
@@ -307,16 +315,14 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setType(NODE_VISITED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeVisitedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeMoved.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeMovedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -329,16 +335,14 @@
e.setTargetFqn(newFqn);
e.setTransaction(tx);
e.setType(NODE_MOVED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeMovedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeEvicted(final Fqn fqn, final boolean pre, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeEvicted.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeEvictedListeners.isEmpty())
{
final boolean originLocal = ctx.isOriginLocal();
Transaction tx = ctx.getTransaction();
@@ -350,16 +354,14 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setType(NODE_EVICTED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeEvictedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeLoaded.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeLoadedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -373,16 +375,14 @@
e.setTransaction(tx);
e.setData(dataCopy);
e.setType(NODE_LOADED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeLoadedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodeActivated(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodeActivated.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodeActivatedListeners.isEmpty())
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data, useMarshalledValueMaps);
@@ -396,16 +396,14 @@
e.setTransaction(tx);
e.setData(dataCopy);
e.setType(NODE_ACTIVATED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodeActivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyNodePassivated(Fqn fqn, boolean pre, Map data, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(NodePassivated.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!nodePassivatedListeners.isEmpty())
{
Map dataCopy = copy(data, useMarshalledValueMaps);
Transaction tx = ctx.getTransaction();
@@ -417,7 +415,7 @@
e.setTransaction(tx);
e.setData(dataCopy);
e.setType(NODE_PASSIVATED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : nodePassivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
@@ -428,14 +426,12 @@
@Start(priority = 99)
public void notifyCacheStarted()
{
- List<ListenerInvocation> listeners = listenerInvocations.get(CacheStarted.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!cacheStartedListeners.isEmpty())
{
EventImpl e = new EventImpl();
e.setCache(cache);
e.setType(CACHE_STARTED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : cacheStartedListeners) listener.invoke(e);
}
}
@@ -445,53 +441,45 @@
@Stop(priority = 98)
public void notifyCacheStopped()
{
- List<ListenerInvocation> listeners = listenerInvocations.get(CacheStopped.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!cacheStoppedListeners.isEmpty())
{
EventImpl e = new EventImpl();
e.setCache(cache);
e.setType(CACHE_STOPPED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : cacheStoppedListeners) listener.invoke(e);
}
}
public void notifyViewChange(final View newView, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(ViewChanged.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!viewChangedListeners.isEmpty())
{
InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setNewView(newView);
e.setType(VIEW_CHANGED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : viewChangedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyBuddyGroupChange(final BuddyGroup buddyGroup, boolean pre)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(BuddyGroupChanged.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!buddyGroupChangedListeners.isEmpty())
{
EventImpl e = new EventImpl();
e.setCache(cache);
e.setBuddyGroup(buddyGroup);
e.setPre(pre);
e.setType(BUDDY_GROUP_CHANGED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : buddyGroupChangedListeners) listener.invoke(e);
}
}
public void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(TransactionCompleted.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!transactionCompletedListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
@@ -501,16 +489,14 @@
e.setTransaction(transaction);
e.setSuccessful(successful);
e.setType(TRANSACTION_COMPLETED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(TransactionRegistered.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!transactionRegisteredListeners.isEmpty())
{
boolean isOriginLocal = ctx.isOriginLocal();
InvocationContext backup = resetInvocationContext(ctx);
@@ -519,36 +505,32 @@
e.setOriginLocal(isOriginLocal);
e.setTransaction(transaction);
e.setType(TRANSACTION_REGISTERED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
}
public void notifyCacheBlocked(boolean pre)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(CacheBlocked.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!cacheBlockedListeners.isEmpty())
{
EventImpl e = new EventImpl();
e.setCache(this.cache);
e.setPre(pre);
e.setType(CACHE_BLOCKED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : cacheBlockedListeners) listener.invoke(e);
}
}
public void notifyCacheUnblocked(boolean pre)
{
- List<ListenerInvocation> listeners = listenerInvocations.get(CacheUnblocked.class);
-
- if (listeners != null && !listeners.isEmpty())
+ if (!cacheUnblockedListeners.isEmpty())
{
EventImpl e = new EventImpl();
e.setCache(this.cache);
e.setPre(pre);
e.setType(CACHE_UNBLOCKED);
- for (ListenerInvocation listener : listeners) listener.invoke(e);
+ for (ListenerInvocation listener : cacheUnblockedListeners) listener.invoke(e);
}
}
@@ -603,7 +585,9 @@
*/
class ListenerInvocation
{
+
private final Object target;
+
private final Method method;
public ListenerInvocation(Object target, Method method)
@@ -632,6 +616,177 @@
removeCacheListener(this.target);
}
}
+
}
+ private List<ListenerInvocation> getListenersForAnnotation(Class annotation)
+ {
+ if (annotation == CacheStarted.class)
+ {
+ return cacheStartedListeners;
+ }
+ else if (annotation == CacheStopped.class)
+ {
+ return cacheStoppedListeners;
+ }
+ else if (annotation == CacheBlocked.class)
+ {
+ return cacheBlockedListeners;
+ }
+ else if (annotation == CacheUnblocked.class)
+ {
+ return cacheUnblockedListeners;
+ }
+ else if (annotation == NodeCreated.class)
+ {
+ return nodeCreatedListeners;
+ }
+ else if (annotation == NodeRemoved.class)
+ {
+ return nodeRemovedListeners;
+ }
+ else if (annotation == NodeVisited.class)
+ {
+ return nodeVisitedListeners;
+ }
+ else if (annotation == NodeModified.class)
+ {
+ return nodeModifiedListeners;
+ }
+ else if (annotation == NodeMoved.class)
+ {
+ return nodeMovedListeners;
+ }
+ else if (annotation == NodeActivated.class)
+ {
+ return nodeActivatedListeners;
+ }
+ else if (annotation == NodePassivated.class)
+ {
+ return nodePassivatedListeners;
+ }
+ else if (annotation == NodeLoaded.class)
+ {
+ return nodeLoadedListeners;
+ }
+ else if (annotation == NodeEvicted.class)
+ {
+ return nodeEvictedListeners;
+ }
+ else if (annotation == TransactionRegistered.class)
+ {
+ return transactionRegisteredListeners;
+ }
+ else if (annotation == TransactionCompleted.class)
+ {
+ return transactionCompletedListeners;
+ }
+ else if (annotation == ViewChanged.class)
+ {
+ return viewChangedListeners;
+ }
+ else if (annotation == BuddyGroupChanged.class)
+ {
+ return buddyGroupChangedListeners;
+ }
+ else
+ {
+ throw new RuntimeException("Unknown listener class: " + annotation);
+ }
+ }
+
+ private Collection getListeningObjects(List<ListenerInvocation> cacheStartedListeners)
+ {
+ Set result = new HashSet();
+ for (ListenerInvocation li : cacheStartedListeners)
+ {
+ result.add(li.target);
+ }
+ return result;
+ }
+
+ public List<ListenerInvocation> getCacheStartedListeners()
+ {
+ return cacheStartedListeners;
+ }
+
+ public List<ListenerInvocation> getCacheStoppedListeners()
+ {
+ return cacheStoppedListeners;
+ }
+
+ public List<ListenerInvocation> getCacheBlockedListeners()
+ {
+ return cacheBlockedListeners;
+ }
+
+ public List<ListenerInvocation> getCacheUnblockedListeners()
+ {
+ return cacheUnblockedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeCreatedListeners()
+ {
+ return nodeCreatedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeRemovedListeners()
+ {
+ return nodeRemovedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeVisitedListeners()
+ {
+ return nodeVisitedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeModifiedListeners()
+ {
+ return nodeModifiedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeMovedListeners()
+ {
+ return nodeMovedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeActivatedListeners()
+ {
+ return nodeActivatedListeners;
+ }
+
+ public List<ListenerInvocation> getNodePassivatedListeners()
+ {
+ return nodePassivatedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeLoadedListeners()
+ {
+ return nodeLoadedListeners;
+ }
+
+ public List<ListenerInvocation> getNodeEvictedListeners()
+ {
+ return nodeEvictedListeners;
+ }
+
+ public List<ListenerInvocation> getTransactionRegisteredListeners()
+ {
+ return transactionRegisteredListeners;
+ }
+
+ public List<ListenerInvocation> getTransactionCompletedListeners()
+ {
+ return transactionCompletedListeners;
+ }
+
+ public List<ListenerInvocation> getViewChangedListeners()
+ {
+ return viewChangedListeners;
+ }
+
+ public List<ListenerInvocation> getBuddyGroupChangedListeners()
+ {
+ return buddyGroupChangedListeners;
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java 2008-05-23 10:34:25 UTC (rev 5883)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierAnnotationsTest.java 2008-05-23 14:30:16 UTC (rev 5884)
@@ -180,9 +180,9 @@
{
Object l = new TestMultipleMethodsListener();
n.addCacheListener(l);
- List invocations = n.listenerInvocations.get(CacheStarted.class);
+ List invocations = n.getCacheStartedListeners();
assertEquals(1, invocations.size());
- invocations = n.listenerInvocations.get(CacheStopped.class);
+ invocations = n.getCacheStoppedListeners();
assertEquals(1, invocations.size());
assertEquals(1, n.getCacheListeners().size());
}
@@ -191,9 +191,9 @@
{
Object l = new TestMultipleAnnotationsOneMethodListener();
n.addCacheListener(l);
- List invocations = n.listenerInvocations.get(CacheStarted.class);
+ List invocations = n.getCacheStartedListeners();
assertEquals(1, invocations.size());
- invocations = n.listenerInvocations.get(CacheStopped.class);
+ invocations = n.getCacheStoppedListeners();
assertEquals(1, invocations.size());
assertEquals(1, n.getCacheListeners().size());
}
@@ -202,7 +202,7 @@
{
Object l = new TestMultipleMethodsOneAnnotationListener();
n.addCacheListener(l);
- List invocations = n.listenerInvocations.get(CacheStarted.class);
+ List invocations = n.getCacheStartedListeners();
assertEquals(2, invocations.size());
assertEquals(1, n.getCacheListeners().size());
}
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-05-23 10:34:25 UTC (rev 5883)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-05-23 14:30:16 UTC (rev 5884)
@@ -62,6 +62,7 @@
Map expected = new HashMap();
expected.put("k", "v");
notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_DATA, expected, ctx);
+ assert notifier.getNodeModifiedListeners().size() == 1;
assert allEventsListener.nodeModifiedEvent != null;
assert allEventsListener.nodeModifiedEvent.getData().equals(expected);
assert allEventsListener.nodeModifiedEvent.getModificationType() == NodeModifiedEvent.ModificationType.PUT_DATA;
More information about the jbosscache-commits
mailing list