[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...
Manik Surtani
msurtani at jboss.com
Tue Aug 22 08:27:51 EDT 2006
User: msurtani
Date: 06/08/22 08:27:51
Modified: src/org/jboss/cache/notifications Notifier.java
Log:
Problem with invocation context leaking into notifications
Revision Changes Path
1.3 +45 -2 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.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Notifier.java 18 Aug 2006 15:40:40 -0000 1.2
+++ Notifier.java 22 Aug 2006 12:27:51 -0000 1.3
@@ -10,7 +10,10 @@
import org.jboss.cache.CacheListener;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jgroups.View;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.Map;
@@ -37,6 +40,8 @@
private Set<CacheListener> listeners = new CopyOnWriteArraySet();
private CacheSPI cache;
+ private InvocationContext tempCtx;
+ private Log log = LogFactory.getLog(Notifier.class);
public Notifier(CacheSPI cache)
{
@@ -104,6 +109,7 @@
{
boolean originLocal = cache.getInvocationContext().isOriginLocal();
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeCreated(fqn, pre, originLocal);
@@ -115,6 +121,7 @@
listener.nodeCreated(fqn, pre, originLocal);
}
}
+ restoreInvocationContext();
}
/**
@@ -126,6 +133,7 @@
public void notifyNodeModified(Fqn fqn, boolean pre, Map data)
{
boolean originLocal = cache.getInvocationContext().isOriginLocal();
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeModified(fqn, pre, originLocal, data);
@@ -137,6 +145,7 @@
listener.nodeModified(fqn, pre, originLocal, data);
}
}
+ restoreInvocationContext();
}
/**
@@ -148,6 +157,7 @@
public void notifyNodeRemoved(Fqn fqn, boolean pre, Map data)
{
boolean originLocal = cache.getInvocationContext().isOriginLocal();
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeRemoved(fqn, pre, originLocal, data);
@@ -159,6 +169,7 @@
listener.nodeRemoved(fqn, pre, originLocal, data);
}
}
+ restoreInvocationContext();
}
/**
@@ -168,6 +179,7 @@
*/
public void notifyNodeVisited(Fqn fqn, boolean pre)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeVisited(fqn, pre);
@@ -179,6 +191,7 @@
listener.nodeVisited(fqn, pre);
}
}
+ restoreInvocationContext();
}
/**
@@ -189,6 +202,7 @@
public void notifyNodeEvicted(Fqn fqn, boolean pre)
{
boolean originLocal = cache.getInvocationContext().isOriginLocal();
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeEvicted(fqn, pre, originLocal);
@@ -200,6 +214,7 @@
listener.nodeEvicted(fqn, pre, originLocal);
}
}
+ restoreInvocationContext();
}
/**
@@ -210,6 +225,7 @@
*/
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map data)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeLoaded(fqn, pre, data);
@@ -221,7 +237,7 @@
listener.nodeLoaded(fqn, pre, data);
}
}
-
+ restoreInvocationContext();
}
/**
@@ -231,6 +247,7 @@
*/
public void notifyNodeActivated(Fqn fqn, boolean pre)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodeActivated(fqn, pre);
@@ -242,7 +259,7 @@
listener.nodeActivated(fqn, pre);
}
}
-
+ restoreInvocationContext();
}
/**
@@ -252,6 +269,7 @@
*/
public void notifyNodePassivated(Fqn fqn, boolean pre)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.nodePassivated(fqn, pre);
@@ -263,6 +281,7 @@
listener.nodePassivated(fqn, pre);
}
}
+ restoreInvocationContext();
}
/**
@@ -271,6 +290,7 @@
*/
public void notifyCacheStarted(CacheSPI cache)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.cacheStarted(cache);
@@ -282,6 +302,7 @@
listener.cacheStarted(cache);
}
}
+ restoreInvocationContext();
}
/**
@@ -290,6 +311,7 @@
*/
public void notifyCacheStopped(CacheSPI cache)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.cacheStopped(cache);
@@ -301,6 +323,25 @@
listener.cacheStopped(cache);
}
}
+ restoreInvocationContext();
+ }
+
+ private void restoreInvocationContext()
+ {
+ cache.setInvocationContext(tempCtx);
+ }
+
+ private void resetInvocationContext()
+ {
+ try
+ {
+ tempCtx = cache.getInvocationContext().clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ log.warn("Unable to clone Invocation Context " + cache.getInvocationContext(), e);
+ }
+ cache.getInvocationContext().reset();
}
/**
@@ -309,6 +350,7 @@
*/
public void notifyViewChange(View new_view)
{
+ resetInvocationContext();
if (evictionPolicyListener != null)
{
evictionPolicyListener.viewChange(new_view);
@@ -320,5 +362,6 @@
listener.viewChange(new_view);
}
}
+ restoreInvocationContext();
}
}
More information about the jboss-cvs-commits
mailing list