[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...
Manik Surtani
manik at jboss.org
Tue May 29 12:25:20 EDT 2007
User: msurtani
Date: 07/05/29 12:25:20
Modified: src/org/jboss/cache/notifications Notifier.java
Log:
Bug in deferred notification of view changes
Revision Changes Path
1.23 +148 -132 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.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- Notifier.java 23 May 2007 16:56:23 -0000 1.22
+++ Notifier.java 29 May 2007 16:25:20 -0000 1.23
@@ -156,7 +156,9 @@
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -172,6 +174,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeCreated, new Object[]{fqn, pre, originLocal});
@@ -193,7 +196,9 @@
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data);
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -209,6 +214,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeModified, new Object[]{fqn, pre, originLocal, modificationType, dataCopy});
@@ -229,7 +235,9 @@
{
boolean originLocal = ctx.isOriginLocal();
Map dataCopy = copy(data);
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -245,6 +253,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeRemoved, new Object[]{fqn, pre, originLocal, dataCopy});
@@ -263,7 +272,9 @@
*/
public void notifyNodeVisited(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -279,6 +290,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeVisited, new Object[]{fqn, pre});
@@ -290,7 +302,9 @@
public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -306,6 +320,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeMoved, new Object[]{originalFqn, newFqn, pre, originLocal});
@@ -325,7 +340,9 @@
public void notifyNodeEvicted(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
boolean originLocal = ctx.isOriginLocal();
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -341,6 +358,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeEvicted, new Object[]{fqn, pre, originLocal});
@@ -360,7 +378,9 @@
public void notifyNodeLoaded(Fqn fqn, boolean pre, Map<K, V> data, InvocationContext ctx, boolean sendImmediately)
{
Map<K, V> dataCopy = copy(data);
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -376,6 +396,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeLoaded, new Object[]{fqn, pre, dataCopy});
@@ -393,7 +414,9 @@
*/
public void notifyNodeActivated(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -409,6 +432,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodeActivated, new Object[]{fqn, pre});
@@ -426,7 +450,9 @@
*/
public void notifyNodePassivated(Fqn fqn, boolean pre, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -442,6 +468,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(nodePassivated, new Object[]{fqn, pre});
@@ -458,7 +485,9 @@
*/
public void notifyCacheStarted(CacheSPI cache, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -474,6 +503,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(cacheStarted, new Object[]{cache});
@@ -490,7 +520,9 @@
*/
public void notifyCacheStopped(CacheSPI cache, InvocationContext ctx, boolean sendImmediately)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (sendImmediately)
+ {
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -506,6 +538,7 @@
}
restoreInvocationContext(backup);
}
+ }
else
{
MethodCall call = new MethodCall(cacheStopped, new Object[]{cache});
@@ -514,15 +547,15 @@
}
/**
- * Notifies all registered listeners of a viewChange event.
+ * Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
+ * immediately.
*
* @param new_view
* @param ctx context of invocation
- * @param sendImmediately whether notifications are deferred to the NotificationInterceptor (sendImmediately = false)
*/
- public void notifyViewChange(View new_view, InvocationContext ctx, boolean sendImmediately)
+ public void notifyViewChange(View new_view, InvocationContext ctx)
{
- if (sendImmediately && hasListenersOrEvictionListener)
+ if (hasListenersOrEvictionListener)
{
InvocationContext backup = resetInvocationContext(ctx);
if (evictionPolicyListener != null)
@@ -538,11 +571,6 @@
}
restoreInvocationContext(backup);
}
- else
- {
- MethodCall call = new MethodCall(viewChange, new Object[]{new_view});
- ctx.addCacheListenerEvent(call);
- }
}
private Map<K, V> copy(Map<K, V> data)
@@ -565,18 +593,6 @@
*/
private InvocationContext resetInvocationContext(InvocationContext ctx)
{
-// InvocationContext tempCtx = null;
-// try
-// {
-// tempCtx = ctx.clone();
-// }
-// catch (CloneNotSupportedException e)
-// {
-// log.warn("Unable to clone Invocation Context " + ctx, e);
-// }
-// ctx.reset();
-// return tempCtx;
-
// wipe current context.
cache.setInvocationContext(null);
return ctx;
More information about the jboss-cvs-commits
mailing list