[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...
Manik Surtani
manik at jboss.org
Wed May 23 12:56:23 EDT 2007
User: msurtani
Date: 07/05/23 12:56:23
Modified: src/org/jboss/cache/notifications Notifier.java
Log:
minor optimisation in the notifier
Revision Changes Path
1.22 +22 -14 JBossCache/src/org/jboss/cache/notifications/Notifier.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Notifier.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/notifications/Notifier.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Notifier.java 23 May 2007 15:22:04 -0000 1.21
+++ Notifier.java 23 May 2007 16:56:23 -0000 1.22
@@ -37,6 +37,7 @@
// is empty
//
private boolean hasListeners = false;
+ private boolean hasListenersOrEvictionListener = false;
private Cache cache;
// store this seperately from other listeners to avoid concurrency penalty of
@@ -89,6 +90,7 @@
public void setEvictionPolicyListener(CacheListener l)
{
evictionPolicyListener = l;
+ if (evictionPolicyListener != null) hasListenersOrEvictionListener = true;
}
/**
@@ -102,6 +104,7 @@
{
listeners.add(l);
hasListeners = true;
+ hasListenersOrEvictionListener = true;
}
}
@@ -116,6 +119,7 @@
{
listeners.remove(l);
hasListeners = !listeners.isEmpty();
+ hasListenersOrEvictionListener = hasListeners || evictionPolicyListener != null;
}
}
@@ -124,8 +128,12 @@
*/
public void removeAllCacheListeners()
{
+ synchronized (listeners)
+ {
listeners.clear();
hasListeners = false;
+ hasListenersOrEvictionListener = evictionPolicyListener != null;
+ }
}
/**
@@ -148,7 +156,7 @@
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -185,7 +193,7 @@
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data);
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -221,7 +229,7 @@
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data);
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -255,7 +263,7 @@
*/
public void notifyNodeVisited(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -282,7 +290,7 @@
public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -317,7 +325,7 @@
public void notifyNodeEvicted(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -352,7 +360,7 @@
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map<K, V> data, InvocationContext ctx, boolean sendImmediately)
{
Map<K, V> dataCopy = copy(data);
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -385,7 +393,7 @@
*/
public void notifyNodeActivated(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -418,7 +426,7 @@
*/
public void notifyNodePassivated(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -450,7 +458,7 @@
*/
public void notifyCacheStarted(CacheSPI cache, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -482,7 +490,7 @@
*/
public void notifyCacheStopped(CacheSPI cache, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -514,7 +522,7 @@
*/
public void notifyViewChange(View new_view, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately)
+ if (sendImmediately && hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
More information about the jboss-cvs-commits
mailing list