[infinispan-commits] Infinispan SVN: r2525 - branches/4.2.x/core/src/main/java/org/infinispan/commands/write and 12 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Oct 20 09:04:26 EDT 2010


Author: trustin
Date: 2010-10-20 09:04:25 -0400 (Wed, 20 Oct 2010)
New Revision: 2525

Modified:
   branches/4.2.x/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java
   branches/4.2.x/core/src/main/java/org/infinispan/commands/write/EvictCommand.java
   branches/4.2.x/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java
   branches/4.2.x/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
   branches/4.2.x/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java
   branches/4.2.x/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java
   branches/4.2.x/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java
   branches/4.2.x/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java
   branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java
   branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java
   trunk/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java
   trunk/core/src/main/java/org/infinispan/commands/write/EvictCommand.java
   trunk/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java
   trunk/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
   trunk/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java
   trunk/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java
   trunk/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java
   trunk/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
   trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java
   trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java
   trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java
Log:
Resolved issue: ISPN-703 (Add cache value to event objects)
* Added getValue() method to most subtypes of CacheEntryEvent, except for CacheEntryCreatedEvent
* Changed CacheNotifier and its implementation to notify the events with the value property if necessary
* Updated CacheNotifierTest and CacheNotifierImplTest to catch up the changes
* Added some FIXMEs about streamlining event model and notification

Modified: branches/4.2.x/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -32,7 +32,7 @@
 import org.infinispan.util.logging.LogFactory;
 
 /**
- * Implements functionality defined by {@link org.infinispan.Cache#get(Object)} and 
+ * Implements functionality defined by {@link org.infinispan.Cache#get(Object)} and
  * {@link org.infinispan.Cache#containsKey(Object)} operations
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
@@ -54,6 +54,7 @@
    public GetKeyValueCommand() {
    }
 
+   @Override
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable {
       return visitor.visitGetKeyValueCommand(ctx, this);
    }
@@ -65,23 +66,33 @@
       this.returnCacheEntry = returnCacheEntry;
    }
 
+   @Override
    public Object perform(InvocationContext ctx) throws Throwable {
       CacheEntry entry = ctx.lookupEntry(key);
       if (entry == null || entry.isNull()) {
-         if (trace) log.trace("Entry not found");
+         if (trace) {
+            log.trace("Entry not found");
+         }
          return null;
       }
       if (entry.isRemoved()) {
-         if (trace) log.trace("Entry has been deleted and is of type " + entry.getClass().getSimpleName());
+         if (trace) {
+            log.trace("Entry has been deleted and is of type " + entry.getClass().getSimpleName());
+         }
          return null;
       }
-      notifier.notifyCacheEntryVisited(key, true, ctx);
-      Object result = returnCacheEntry ? entry : entry.getValue();
-      if (trace) log.trace("Found value " + result);
-      notifier.notifyCacheEntryVisited(key, false, ctx);
+      final Object value = entry.getValue();
+      // FIXME: There's no point in notifying twice.
+      notifier.notifyCacheEntryVisited(key, value, true, ctx);
+      final Object result = returnCacheEntry ? entry : value;
+      if (trace) {
+         log.trace("Found value " + result);
+      }
+      notifier.notifyCacheEntryVisited(key, value, false, ctx);
       return result;
    }
 
+   @Override
    public byte getCommandId() {
       return COMMAND_ID;
    }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/commands/write/EvictCommand.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/commands/write/EvictCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/commands/write/EvictCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -52,14 +52,16 @@
 
    @Override
    public Object perform(InvocationContext ctx) throws Throwable {
-      if (key == null) throw new NullPointerException("Key is null!!");
+      if (key == null) {
+         throw new NullPointerException("Key is null!!");
+      }
       super.perform(ctx);
       return null;
    }
 
    @Override
    public void notify(InvocationContext ctx, Object value, boolean isPre) {
-      notifier.notifyCacheEntryEvicted(key, isPre, ctx);
+      notifier.notifyCacheEntryEvicted(key, value, isPre, ctx);
    }
 
    @Override

Modified: branches/4.2.x/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,6 +21,8 @@
  */
 package org.infinispan.commands.write;
 
+import java.util.Arrays;
+
 import org.infinispan.commands.Visitor;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.marshall.Ids;
@@ -30,9 +32,7 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.util.Arrays;
 
-
 /**
  * Removes an entry from memory - never removes the entry.
  *
@@ -62,19 +62,23 @@
     */
    @Override
    public Object perform(InvocationContext ctx) throws Throwable {
-      if (trace) log.trace("Invalidating keys {0}", Arrays.toString(keys));
-      for (Object k : keys) invalidate(ctx, k);
+      if (trace) {
+         log.trace("Invalidating keys {0}", Arrays.toString(keys));
+      }
+      for (Object k : keys) {
+         invalidate(ctx, k);
+      }
       return null;
    }
 
    protected void invalidate(InvocationContext ctx, Object keyToInvalidate) throws Throwable {
-      this.key = keyToInvalidate; // so that the superclass can see it
+      key = keyToInvalidate; // so that the superclass can see it
       super.perform(ctx);
    }
 
    @Override
    protected void notify(InvocationContext ctx, Object value, boolean isPre) {
-      notifier.notifyCacheEntryInvalidated(key, isPre, ctx);
+      notifier.notifyCacheEntryInvalidated(key, value, isPre, ctx);
    }
 
    @Override
@@ -130,13 +134,21 @@
 
    @Override
    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (!(o instanceof InvalidateCommand)) return false;
-      if (!super.equals(o)) return false;
+      if (this == o) {
+         return true;
+      }
+      if (!(o instanceof InvalidateCommand)) {
+         return false;
+      }
+      if (!super.equals(o)) {
+         return false;
+      }
 
       InvalidateCommand that = (InvalidateCommand) o;
 
-      if (!Arrays.equals(keys, that.keys)) return false;
+      if (!Arrays.equals(keys, that.keys)) {
+         return false;
+      }
       return true;
    }
 

Modified: branches/4.2.x/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -86,11 +86,21 @@
          return false;
       }
 
-      notify(ctx, e.getValue(), true);
+      final Object removedValue = e.getValue();
+      notify(ctx, removedValue, true);
       e.setRemoved(true);
       e.setValid(false);
-      notify(ctx, null, false);
-      return value == null ? e.getValue() : true;
+
+      // Eviction has no notion of pre/post event since 4.2.0.ALPHA4.
+      // EvictionManagerImpl.onEntryEviction() triggers both pre and post events
+      // with non-null values, so we should do the same here as an ugly workaround.
+      if (this instanceof EvictCommand) {
+         notify(ctx, removedValue, false);
+      } else {
+         // FIXME: Do we really need to notify with null when a user can be given with more information?
+         notify(ctx, null, false);
+      }
+      return value == null ? removedValue : true;
    }
 
    protected void notify(InvocationContext ctx, Object value, boolean isPre) {
@@ -101,18 +111,28 @@
       return COMMAND_ID;
    }
 
+   @Override
    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (!(o instanceof RemoveCommand)) return false;
-      if (!super.equals(o)) return false;
+      if (this == o) {
+         return true;
+      }
+      if (!(o instanceof RemoveCommand)) {
+         return false;
+      }
+      if (!super.equals(o)) {
+         return false;
+      }
 
       RemoveCommand that = (RemoveCommand) o;
 
-      if (value != null ? !value.equals(that.value) : that.value != null) return false;
+      if (value != null ? !value.equals(that.value) : that.value != null) {
+         return false;
+      }
 
       return true;
    }
 
+   @Override
    public int hashCode() {
       int result = super.hashCode();
       result = 31 * result + (value != null ? value.hashCode() : 0);
@@ -120,6 +140,7 @@
    }
 
 
+   @Override
    public String toString() {
       return getClass().getSimpleName() + "{" +
             "key=" + key +

Modified: branches/4.2.x/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -146,20 +146,21 @@
 
    @Override
    public void onEntryEviction(Object key, InternalCacheEntry value) {
+      final Object entryValue = value.getValue();
       InvocationContext context = getInvocationContext();
       try {
          acquireLock(context, key);
       } catch (Exception e) {
          log.warn("Could not acquire lock for eviction of {0}", key, e);
       }
-      cacheNotifier.notifyCacheEntryEvicted(key, true, context);
+      cacheNotifier.notifyCacheEntryEvicted(key, entryValue, true, context);
 
       try {
          passivator.passivate(key, value, null);
       } catch (CacheLoaderException e) {
          log.warn("Unable to passivate entry under {0}", key, e);
       }
-      cacheNotifier.notifyCacheEntryEvicted(key, false, getInvocationContext());
+      cacheNotifier.notifyCacheEntryEvicted(key, entryValue, false, getInvocationContext());
       releaseLock(key);
    }
 

Modified: branches/4.2.x/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,5 +1,7 @@
 package org.infinispan.eviction;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.config.Configuration;
 import org.infinispan.config.ConfigurationException;
 import org.infinispan.container.entries.InternalCacheEntry;
@@ -13,8 +15,6 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 public class PassivationManagerImpl implements PassivationManager {
 
    CacheLoaderManager cacheLoaderManager;
@@ -39,8 +39,9 @@
       enabled = cfg.getCacheLoaderManagerConfig().isPassivation();
       if (enabled) {
          cacheStore = cacheLoaderManager == null ? null : cacheLoaderManager.getCacheStore();
-         if (cacheStore == null)
+         if (cacheStore == null) {
             throw new ConfigurationException("passivation can only be used with a CacheLoader that implements CacheStore!");
+         }
 
          enabled = cacheLoaderManager.isEnabled() && cacheLoaderManager.isUsingPassivation();
          statsEnabled = cfg.isExposeJmxStatistics();
@@ -55,12 +56,15 @@
    @Override
    public void passivate(Object key, InternalCacheEntry entry, InvocationContext ctx) throws CacheLoaderException {
       if (enabled) {
+         final Object value = entry != null ? entry.getValue() : null;
          // notify listeners that this entry is about to be passivated
-         notifier.notifyCacheEntryPassivated(key, true, ctx);
+         notifier.notifyCacheEntryPassivated(key, value, true, ctx);
          log.trace("Passivating entry {0}", key);
          cacheStore.store(entry);
-         notifier.notifyCacheEntryPassivated(key, false, ctx);
-         if (statsEnabled && entry != null) passivations.getAndIncrement();
+         notifier.notifyCacheEntryPassivated(key, value, false, ctx);
+         if (statsEnabled && entry != null) {
+            passivations.getAndIncrement();
+         }
       }
    }
 

Modified: branches/4.2.x/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,5 +1,7 @@
 package org.infinispan.interceptors;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.commands.read.GetKeyValueCommand;
 import org.infinispan.commands.write.PutKeyValueCommand;
 import org.infinispan.commands.write.PutMapCommand;
@@ -17,19 +19,18 @@
 import org.rhq.helpers.pluginAnnotations.agent.Metric;
 import org.rhq.helpers.pluginAnnotations.agent.Operation;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 @MBean(objectName = "Activation", description = "Component that handles activating entries that have been passivated to a CacheStore by loading them into memory.")
 public class ActivationInterceptor extends CacheLoaderInterceptor {
 
-   private AtomicLong activations = new AtomicLong(0);
+   private final AtomicLong activations = new AtomicLong(0);
    private CacheStore store;
 
    @Start(priority = 15)
    public void setCacheStore() {
       store = clm == null ? null : clm.getCacheStore();
-      if (store == null)
+      if (store == null) {
          throw new ConfigurationException("passivation can only be used with a CacheLoader that implements CacheStore!");
+      }
    }
 
    @Override
@@ -79,18 +80,21 @@
    }
 
    @Override
-   protected void sendNotification(Object key, boolean pre, InvocationContext ctx) {
-      super.sendNotification(key, pre, ctx);
-      notifier.notifyCacheEntryActivated(key, pre, ctx);
+   protected void sendNotification(Object key, Object value, boolean pre, InvocationContext ctx) {
+      super.sendNotification(key, value, pre, ctx);
+      notifier.notifyCacheEntryActivated(key, value, pre, ctx);
    }
 
    @ManagedAttribute(description = "Number of activation events")
    @Metric(displayName = "Number of cache entries activated", measurementType = MeasurementType.TRENDSUP)
    public String getActivations() {
-      if (!getStatisticsEnabled()) return "N/A";
+      if (!getStatisticsEnabled()) {
+         return "N/A";
+      }
       return String.valueOf(activations.get());
    }
 
+   @Override
    @ManagedOperation(description = "Resets statistics gathered by this component")
    @Operation(displayName = "Reset statistics")
    public void resetStatistics() {

Modified: branches/4.2.x/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,6 +21,8 @@
  */
 package org.infinispan.interceptors;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.commands.read.GetKeyValueCommand;
 import org.infinispan.commands.write.InvalidateCommand;
 import org.infinispan.commands.write.PutKeyValueCommand;
@@ -46,8 +48,6 @@
 import org.rhq.helpers.pluginAnnotations.agent.Metric;
 import org.rhq.helpers.pluginAnnotations.agent.Operation;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 @MBean(objectName = "CacheLoader", description = "Component that handles loading entries from a CacheStore into memory.")
 public class CacheLoaderInterceptor extends JmxStatsCommandInterceptor {
    private final AtomicLong cacheLoads = new AtomicLong(0);
@@ -75,7 +75,9 @@
    @Override
    public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeeded(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeeded(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
@@ -92,22 +94,29 @@
    @Override
    public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable {
       Object[] keys;
-      if ((keys = command.getKeys()) != null && keys.length > 0)
-         for (Object key : command.getKeys()) loadIfNeeded(ctx, key);
+      if ((keys = command.getKeys()) != null && keys.length > 0) {
+         for (Object key : command.getKeys()) {
+            loadIfNeeded(ctx, key);
+         }
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
    @Override
    public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeededAndUpdateStats(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeededAndUpdateStats(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
    @Override
    public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeededAndUpdateStats(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeededAndUpdateStats(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
@@ -131,14 +140,20 @@
                return true;
             }
          } finally {
-            if (keyLocked && unlockOnWayOut) entryFactory.releaseLock(key);
+            if (keyLocked && unlockOnWayOut) {
+               entryFactory.releaseLock(key);
+            }
          }
 
          // we *may* need to load this.
          InternalCacheEntry loaded = loader.load(key);
          if (loaded == null) {
-            if (log.isTraceEnabled()) log.trace("No need to load.  Key doesn't exist in the loader.");
-            if (keyLocked) entryFactory.releaseLock(key);
+            if (log.isTraceEnabled()) {
+               log.trace("No need to load.  Key doesn't exist in the loader.");
+            }
+            if (keyLocked) {
+               entryFactory.releaseLock(key);
+            }
             return false;
          }
 
@@ -163,11 +178,13 @@
     * @param ctx the current invocation's context
     * @param key key to record
     * @param entry the appropriately locked entry in the caller's context
-    * @param loadedEntry the internal entry loaded from the cache store. 
+    * @param loadedEntry the internal entry loaded from the cache store.
     */
    private MVCCEntry recordLoadedEntry(InvocationContext ctx, Object key, MVCCEntry entry, InternalCacheEntry loadedEntry) throws Exception {
-      boolean entryExists = (loadedEntry != null);
-      if (log.isTraceEnabled()) log.trace("Entry exists in loader? " + entryExists);
+      boolean entryExists = loadedEntry != null;
+      if (log.isTraceEnabled()) {
+         log.trace("Entry exists in loader? " + entryExists);
+      }
 
       if (getStatisticsEnabled()) {
          if (entryExists) {
@@ -178,22 +195,23 @@
       }
 
       if (entryExists) {
-         sendNotification(key, true, ctx);
-         entry.setValue(loadedEntry.getValue());
+         final Object value = loadedEntry.getValue();
+         // FIXME: There's no point to trigger the entryLoaded/Activated event twice.
+         sendNotification(key, value, true, ctx);
+         entry.setValue(value);
          entry.setLifespan(loadedEntry.getLifespan());
          entry.setMaxIdle(loadedEntry.getMaxIdle());
          // TODO shouldn't we also be setting last used and created timestamps?
          entry.setValid(true);
 
-         notifier.notifyCacheEntryLoaded(key, false, ctx);
-         sendNotification(key, false, ctx);
+         sendNotification(key, value, false, ctx);
       }
 
       return entry;
    }
 
-   protected void sendNotification(Object key, boolean pre, InvocationContext ctx) {
-      notifier.notifyCacheEntryLoaded(key, pre, ctx);
+   protected void sendNotification(Object key, Object value, boolean pre, InvocationContext ctx) {
+      notifier.notifyCacheEntryLoaded(key, value, pre, ctx);
    }
 
    private void loadIfNeededAndUpdateStats(InvocationContext ctx, Object key) throws Throwable {
@@ -215,6 +233,7 @@
       return cacheMisses.get();
    }
 
+   @Override
    @ManagedOperation(description = "Resets statistics gathered by this component")
    @Operation(displayName = "Reset Statistics")
    public void resetStatistics() {

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -53,32 +53,32 @@
    /**
     * Notifies all registered listeners of a CacheEntryVisited event.
     */
-   void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryVisited(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryEvicted event.
     */
-   void notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryEvicted(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryInvalidated event.
     */
-   void notifyCacheEntryInvalidated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryInvalidated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryLoaded event.
     */
-   void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryLoaded(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryActivated event.
     */
-   void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryActivated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryPassivated event.
     */
-   void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryPassivated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a transaction completion event.

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,25 +21,47 @@
  */
 package org.infinispan.notifications.cachelistener;
 
+import static org.infinispan.notifications.cachelistener.event.Event.Type.*;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
 import org.infinispan.Cache;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.context.InvocationContextContainer;
 import org.infinispan.context.impl.TxInvocationContext;
 import org.infinispan.factories.annotations.Inject;
 import org.infinispan.notifications.AbstractListenerImpl;
-import org.infinispan.notifications.cachelistener.annotation.*;
-import org.infinispan.notifications.cachelistener.event.*;
-import static org.infinispan.notifications.cachelistener.event.Event.Type.*;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryEvicted;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryInvalidated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryLoaded;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryPassivated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.infinispan.notifications.cachelistener.annotation.TransactionCompleted;
+import org.infinispan.notifications.cachelistener.annotation.TransactionRegistered;
+import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryInvalidatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryLoadedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryPassivatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
+import org.infinispan.notifications.cachelistener.event.EventImpl;
+import org.infinispan.notifications.cachelistener.event.TransactionCompletedEvent;
+import org.infinispan.notifications.cachelistener.event.TransactionRegisteredEvent;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
 /**
  * Helper class that handles all notifications to registered listeners.
  *
@@ -103,14 +125,17 @@
       this.cache = cache;
    }
 
+   @Override
    protected Log getLog() {
       return log;
    }
 
+   @Override
    protected Map<Class<? extends Annotation>, Class> getAllowedMethodAnnotations() {
       return allowedListeners;
    }
 
+   @Override
    public void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx) {
       if (!cacheEntryCreatedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -123,13 +148,16 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_CREATED);
-            for (ListenerInvocation listener : cacheEntryCreatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryCreatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyCacheEntryModified(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryModifiedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -143,13 +171,16 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_MODIFIED);
-            for (ListenerInvocation listener : cacheEntryModifiedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryModifiedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyCacheEntryRemoved(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryRemovedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -163,14 +194,17 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_REMOVED);
-            for (ListenerInvocation listener : cacheEntryRemovedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryRemovedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryVisited(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryVisitedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
@@ -178,16 +212,20 @@
             e.setCache(cache);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_VISITED);
-            for (ListenerInvocation listener : cacheEntryVisitedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryVisitedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryEvicted(final Object key, final boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryEvicted(final Object key, Object value, final boolean pre, InvocationContext ctx) {
       if (!cacheEntryEvictedListeners.isEmpty()) {
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -197,16 +235,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_EVICTED);
-            for (ListenerInvocation listener : cacheEntryEvictedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryEvictedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryInvalidated(final Object key, final boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryInvalidated(final Object key, Object value, final boolean pre, InvocationContext ctx) {
       if (!cacheEntryInvalidatedListeners.isEmpty()) {
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -216,16 +258,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_INVALIDATED);
-            for (ListenerInvocation listener : cacheEntryInvalidatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryInvalidatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryLoaded(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryLoadedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -235,16 +281,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_LOADED);
-            for (ListenerInvocation listener : cacheEntryLoadedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryLoadedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryActivated(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryActivatedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -254,9 +304,12 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_ACTIVATED);
-            for (ListenerInvocation listener : cacheEntryActivatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryActivatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
@@ -270,7 +323,8 @@
       }
    }
 
-   public void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryPassivated(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryPassivatedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
@@ -278,15 +332,19 @@
             e.setCache(cache);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_PASSIVATED);
-            for (ListenerInvocation listener : cacheEntryPassivatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryPassivatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyTransactionCompleted(GlobalTransaction transaction, boolean successful, InvocationContext ctx) {
       if (!transactionCompletedListeners.isEmpty()) {
          boolean isOriginLocal = ctx.isOriginLocal();
@@ -298,13 +356,16 @@
             e.setTransactionId(transaction);
             e.setTransactionSuccessful(successful);
             e.setType(TRANSACTION_COMPLETED);
-            for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : transactionCompletedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyTransactionRegistered(GlobalTransaction globalTransaction, InvocationContext ctx) {
       if (!transactionRegisteredListeners.isEmpty()) {
          boolean isOriginLocal = ctx.isOriginLocal();
@@ -315,7 +376,9 @@
             e.setOriginLocal(isOriginLocal);
             e.setTransactionId(globalTransaction);
             e.setType(TRANSACTION_REGISTERED);
-            for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
+            for (ListenerInvocation listener : transactionRegisteredListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryActivatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being activated.
+    *
+    * @return the value of the activated entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryEvictedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being evicted.
+    *
+    * @return the value of the evicted entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryInvalidatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being activated.
+    *
+    * @return the value of the invalidated entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryLoadedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being loaded.
+    *
+    * @return the value of the loaded entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryPassivatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being passivated.
+    *
+    * @return the value of the passivated entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryVisitedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being visited.
+    *
+    * @return the value of the visited entry
+    */
+   Object getValue();
 }

Modified: branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,15 +1,22 @@
 package org.infinispan.notifications.cachelistener;
 
+import static org.easymock.classextension.EasyMock.*;
+
 import org.easymock.EasyMock;
-import static org.easymock.classextension.EasyMock.createNiceMock;
 import org.infinispan.Cache;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.context.InvocationContextContainer;
 import org.infinispan.context.InvocationContextContainerImpl;
 import org.infinispan.context.impl.NonTxInvocationContext;
+import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryInvalidatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryLoadedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryPassivatedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
 import org.infinispan.notifications.cachelistener.event.Event;
 import org.infinispan.notifications.cachelistener.event.TransactionCompletedEvent;
 import org.infinispan.notifications.cachelistener.event.TransactionRegisteredEvent;
@@ -88,8 +95,8 @@
    }
 
    public void testNotifyCacheEntryVisited() {
-      n.notifyCacheEntryVisited("k", true, ctx);
-      n.notifyCacheEntryVisited("k", false, ctx);
+      n.notifyCacheEntryVisited("k", "v", true, ctx);
+      n.notifyCacheEntryVisited("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -97,15 +104,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_VISITED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryVisitedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_VISITED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
-
+      assert ((CacheEntryVisitedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryEvicted() {
-      n.notifyCacheEntryEvicted("k", true, ctx);
-      n.notifyCacheEntryEvicted("k", false, ctx);
+      n.notifyCacheEntryEvicted("k", "v", true, ctx);
+      n.notifyCacheEntryEvicted("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -113,14 +121,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_EVICTED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryEvictedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_EVICTED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryEvictedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryInvalidated() {
-      n.notifyCacheEntryInvalidated("k", true, ctx);
-      n.notifyCacheEntryInvalidated("k", false, ctx);
+      n.notifyCacheEntryInvalidated("k", "v", true, ctx);
+      n.notifyCacheEntryInvalidated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -128,14 +138,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryInvalidatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryInvalidatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryLoaded() {
-      n.notifyCacheEntryLoaded("k", true, ctx);
-      n.notifyCacheEntryLoaded("k", false, ctx);
+      n.notifyCacheEntryLoaded("k", "v", true, ctx);
+      n.notifyCacheEntryLoaded("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -143,14 +155,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_LOADED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryLoadedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_LOADED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryLoadedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryActivated() {
-      n.notifyCacheEntryActivated("k", true, ctx);
-      n.notifyCacheEntryActivated("k", false, ctx);
+      n.notifyCacheEntryActivated("k", "v", true, ctx);
+      n.notifyCacheEntryActivated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -158,14 +172,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryActivatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryActivatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryPassivated() {
-      n.notifyCacheEntryPassivated("k", true, ctx);
-      n.notifyCacheEntryPassivated("k", false, ctx);
+      n.notifyCacheEntryPassivated("k", "v", true, ctx);
+      n.notifyCacheEntryPassivated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -173,9 +189,11 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryPassivatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryPassivatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyTransactionCompleted() {

Modified: branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java
===================================================================
--- branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,6 +1,13 @@
 package org.infinispan.notifications.cachelistener;
 
 import static org.easymock.EasyMock.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.TransactionManager;
+
 import org.infinispan.Cache;
 import org.infinispan.config.Configuration;
 import org.infinispan.context.InvocationContext;
@@ -15,11 +22,6 @@
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import javax.transaction.TransactionManager;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 @Test(groups = "functional", testName = "notifications.cachelistener.CacheNotifierTest")
 public class CacheNotifierTest extends AbstractInfinispanTest {
    private Cache<Object, Object> cache;
@@ -120,9 +122,9 @@
    public void testVisit() throws Exception {
       initCacheData("key", "value");
 
-      mockNotifier.notifyCacheEntryVisited(eq("key"), eq(true), isA(InvocationContext.class));
+      mockNotifier.notifyCacheEntryVisited(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
       expectLastCall().once();
-      mockNotifier.notifyCacheEntryVisited(eq("key"), eq(false), isA(InvocationContext.class));
+      mockNotifier.notifyCacheEntryVisited(eq("key"), eq("value"), eq(false), isA(InvocationContext.class));
       expectLastCall().once();
       replay(mockNotifier);
       cache.get("key");

Modified: trunk/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/commands/read/GetKeyValueCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -32,7 +32,7 @@
 import org.infinispan.util.logging.LogFactory;
 
 /**
- * Implements functionality defined by {@link org.infinispan.Cache#get(Object)} and 
+ * Implements functionality defined by {@link org.infinispan.Cache#get(Object)} and
  * {@link org.infinispan.Cache#containsKey(Object)} operations
  *
  * @author Manik Surtani (<a href="mailto:manik at jboss.org">manik at jboss.org</a>)
@@ -54,6 +54,7 @@
    public GetKeyValueCommand() {
    }
 
+   @Override
    public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable {
       return visitor.visitGetKeyValueCommand(ctx, this);
    }
@@ -65,23 +66,33 @@
       this.returnCacheEntry = returnCacheEntry;
    }
 
+   @Override
    public Object perform(InvocationContext ctx) throws Throwable {
       CacheEntry entry = ctx.lookupEntry(key);
       if (entry == null || entry.isNull()) {
-         if (trace) log.trace("Entry not found");
+         if (trace) {
+            log.trace("Entry not found");
+         }
          return null;
       }
       if (entry.isRemoved()) {
-         if (trace) log.trace("Entry has been deleted and is of type " + entry.getClass().getSimpleName());
+         if (trace) {
+            log.trace("Entry has been deleted and is of type " + entry.getClass().getSimpleName());
+         }
          return null;
       }
-      notifier.notifyCacheEntryVisited(key, true, ctx);
-      Object result = returnCacheEntry ? entry : entry.getValue();
-      if (trace) log.trace("Found value " + result);
-      notifier.notifyCacheEntryVisited(key, false, ctx);
+      final Object value = entry.getValue();
+      // FIXME: There's no point in notifying twice.
+      notifier.notifyCacheEntryVisited(key, value, true, ctx);
+      final Object result = returnCacheEntry ? entry : value;
+      if (trace) {
+         log.trace("Found value " + result);
+      }
+      notifier.notifyCacheEntryVisited(key, value, false, ctx);
       return result;
    }
 
+   @Override
    public byte getCommandId() {
       return COMMAND_ID;
    }

Modified: trunk/core/src/main/java/org/infinispan/commands/write/EvictCommand.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/commands/write/EvictCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/commands/write/EvictCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -52,14 +52,16 @@
 
    @Override
    public Object perform(InvocationContext ctx) throws Throwable {
-      if (key == null) throw new NullPointerException("Key is null!!");
+      if (key == null) {
+         throw new NullPointerException("Key is null!!");
+      }
       super.perform(ctx);
       return null;
    }
 
    @Override
    public void notify(InvocationContext ctx, Object value, boolean isPre) {
-      notifier.notifyCacheEntryEvicted(key, isPre, ctx);
+      notifier.notifyCacheEntryEvicted(key, value, isPre, ctx);
    }
 
    @Override

Modified: trunk/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/commands/write/InvalidateCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,6 +21,8 @@
  */
 package org.infinispan.commands.write;
 
+import java.util.Arrays;
+
 import org.infinispan.commands.Visitor;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.marshall.Ids;
@@ -30,9 +32,7 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.util.Arrays;
 
-
 /**
  * Removes an entry from memory - never removes the entry.
  *
@@ -62,19 +62,23 @@
     */
    @Override
    public Object perform(InvocationContext ctx) throws Throwable {
-      if (trace) log.trace("Invalidating keys {0}", Arrays.toString(keys));
-      for (Object k : keys) invalidate(ctx, k);
+      if (trace) {
+         log.trace("Invalidating keys {0}", Arrays.toString(keys));
+      }
+      for (Object k : keys) {
+         invalidate(ctx, k);
+      }
       return null;
    }
 
    protected void invalidate(InvocationContext ctx, Object keyToInvalidate) throws Throwable {
-      this.key = keyToInvalidate; // so that the superclass can see it
+      key = keyToInvalidate; // so that the superclass can see it
       super.perform(ctx);
    }
 
    @Override
    protected void notify(InvocationContext ctx, Object value, boolean isPre) {
-      notifier.notifyCacheEntryInvalidated(key, isPre, ctx);
+      notifier.notifyCacheEntryInvalidated(key, value, isPre, ctx);
    }
 
    @Override
@@ -130,13 +134,21 @@
 
    @Override
    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (!(o instanceof InvalidateCommand)) return false;
-      if (!super.equals(o)) return false;
+      if (this == o) {
+         return true;
+      }
+      if (!(o instanceof InvalidateCommand)) {
+         return false;
+      }
+      if (!super.equals(o)) {
+         return false;
+      }
 
       InvalidateCommand that = (InvalidateCommand) o;
 
-      if (!Arrays.equals(keys, that.keys)) return false;
+      if (!Arrays.equals(keys, that.keys)) {
+         return false;
+      }
       return true;
    }
 

Modified: trunk/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/commands/write/RemoveCommand.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -86,11 +86,21 @@
          return false;
       }
 
-      notify(ctx, e.getValue(), true);
+      final Object removedValue = e.getValue();
+      notify(ctx, removedValue, true);
       e.setRemoved(true);
       e.setValid(false);
-      notify(ctx, null, false);
-      return value == null ? e.getValue() : true;
+
+      // Eviction has no notion of pre/post event since 4.2.0.ALPHA4.
+      // EvictionManagerImpl.onEntryEviction() triggers both pre and post events
+      // with non-null values, so we should do the same here as an ugly workaround.
+      if (this instanceof EvictCommand) {
+         notify(ctx, removedValue, false);
+      } else {
+         // FIXME: Do we really need to notify with null when a user can be given with more information?
+         notify(ctx, null, false);
+      }
+      return value == null ? removedValue : true;
    }
 
    protected void notify(InvocationContext ctx, Object value, boolean isPre) {
@@ -101,18 +111,28 @@
       return COMMAND_ID;
    }
 
+   @Override
    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (!(o instanceof RemoveCommand)) return false;
-      if (!super.equals(o)) return false;
+      if (this == o) {
+         return true;
+      }
+      if (!(o instanceof RemoveCommand)) {
+         return false;
+      }
+      if (!super.equals(o)) {
+         return false;
+      }
 
       RemoveCommand that = (RemoveCommand) o;
 
-      if (value != null ? !value.equals(that.value) : that.value != null) return false;
+      if (value != null ? !value.equals(that.value) : that.value != null) {
+         return false;
+      }
 
       return true;
    }
 
+   @Override
    public int hashCode() {
       int result = super.hashCode();
       result = 31 * result + (value != null ? value.hashCode() : 0);
@@ -120,6 +140,7 @@
    }
 
 
+   @Override
    public String toString() {
       return getClass().getSimpleName() + "{" +
             "key=" + key +

Modified: trunk/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/eviction/EvictionManagerImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -146,20 +146,21 @@
 
    @Override
    public void onEntryEviction(Object key, InternalCacheEntry value) {
+      final Object entryValue = value.getValue();
       InvocationContext context = getInvocationContext();
       try {
          acquireLock(context, key);
       } catch (Exception e) {
          log.warn("Could not acquire lock for eviction of {0}", key, e);
       }
-      cacheNotifier.notifyCacheEntryEvicted(key, true, context);
+      cacheNotifier.notifyCacheEntryEvicted(key, entryValue, true, context);
 
       try {
          passivator.passivate(key, value, null);
       } catch (CacheLoaderException e) {
          log.warn("Unable to passivate entry under {0}", key, e);
       }
-      cacheNotifier.notifyCacheEntryEvicted(key, false, getInvocationContext());
+      cacheNotifier.notifyCacheEntryEvicted(key, entryValue, false, getInvocationContext());
       releaseLock(key);
    }
 

Modified: trunk/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/eviction/PassivationManagerImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,5 +1,7 @@
 package org.infinispan.eviction;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.config.Configuration;
 import org.infinispan.config.ConfigurationException;
 import org.infinispan.container.entries.InternalCacheEntry;
@@ -13,8 +15,6 @@
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 public class PassivationManagerImpl implements PassivationManager {
 
    CacheLoaderManager cacheLoaderManager;
@@ -39,8 +39,9 @@
       enabled = cfg.getCacheLoaderManagerConfig().isPassivation();
       if (enabled) {
          cacheStore = cacheLoaderManager == null ? null : cacheLoaderManager.getCacheStore();
-         if (cacheStore == null)
+         if (cacheStore == null) {
             throw new ConfigurationException("passivation can only be used with a CacheLoader that implements CacheStore!");
+         }
 
          enabled = cacheLoaderManager.isEnabled() && cacheLoaderManager.isUsingPassivation();
          statsEnabled = cfg.isExposeJmxStatistics();
@@ -55,12 +56,15 @@
    @Override
    public void passivate(Object key, InternalCacheEntry entry, InvocationContext ctx) throws CacheLoaderException {
       if (enabled) {
+         final Object value = entry != null ? entry.getValue() : null;
          // notify listeners that this entry is about to be passivated
-         notifier.notifyCacheEntryPassivated(key, true, ctx);
+         notifier.notifyCacheEntryPassivated(key, value, true, ctx);
          log.trace("Passivating entry {0}", key);
          cacheStore.store(entry);
-         notifier.notifyCacheEntryPassivated(key, false, ctx);
-         if (statsEnabled && entry != null) passivations.getAndIncrement();
+         notifier.notifyCacheEntryPassivated(key, value, false, ctx);
+         if (statsEnabled && entry != null) {
+            passivations.getAndIncrement();
+         }
       }
    }
 

Modified: trunk/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/interceptors/ActivationInterceptor.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,5 +1,7 @@
 package org.infinispan.interceptors;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.commands.read.GetKeyValueCommand;
 import org.infinispan.commands.write.PutKeyValueCommand;
 import org.infinispan.commands.write.PutMapCommand;
@@ -17,19 +19,18 @@
 import org.rhq.helpers.pluginAnnotations.agent.Metric;
 import org.rhq.helpers.pluginAnnotations.agent.Operation;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 @MBean(objectName = "Activation", description = "Component that handles activating entries that have been passivated to a CacheStore by loading them into memory.")
 public class ActivationInterceptor extends CacheLoaderInterceptor {
 
-   private AtomicLong activations = new AtomicLong(0);
+   private final AtomicLong activations = new AtomicLong(0);
    private CacheStore store;
 
    @Start(priority = 15)
    public void setCacheStore() {
       store = clm == null ? null : clm.getCacheStore();
-      if (store == null)
+      if (store == null) {
          throw new ConfigurationException("passivation can only be used with a CacheLoader that implements CacheStore!");
+      }
    }
 
    @Override
@@ -79,18 +80,21 @@
    }
 
    @Override
-   protected void sendNotification(Object key, boolean pre, InvocationContext ctx) {
-      super.sendNotification(key, pre, ctx);
-      notifier.notifyCacheEntryActivated(key, pre, ctx);
+   protected void sendNotification(Object key, Object value, boolean pre, InvocationContext ctx) {
+      super.sendNotification(key, value, pre, ctx);
+      notifier.notifyCacheEntryActivated(key, value, pre, ctx);
    }
 
    @ManagedAttribute(description = "Number of activation events")
    @Metric(displayName = "Number of cache entries activated", measurementType = MeasurementType.TRENDSUP)
    public String getActivations() {
-      if (!getStatisticsEnabled()) return "N/A";
+      if (!getStatisticsEnabled()) {
+         return "N/A";
+      }
       return String.valueOf(activations.get());
    }
 
+   @Override
    @ManagedOperation(description = "Resets statistics gathered by this component")
    @Operation(displayName = "Reset statistics")
    public void resetStatistics() {

Modified: trunk/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/interceptors/CacheLoaderInterceptor.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,6 +21,8 @@
  */
 package org.infinispan.interceptors;
 
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.infinispan.commands.read.GetKeyValueCommand;
 import org.infinispan.commands.write.InvalidateCommand;
 import org.infinispan.commands.write.PutKeyValueCommand;
@@ -46,8 +48,6 @@
 import org.rhq.helpers.pluginAnnotations.agent.Metric;
 import org.rhq.helpers.pluginAnnotations.agent.Operation;
 
-import java.util.concurrent.atomic.AtomicLong;
-
 @MBean(objectName = "CacheLoader", description = "Component that handles loading entries from a CacheStore into memory.")
 public class CacheLoaderInterceptor extends JmxStatsCommandInterceptor {
    private final AtomicLong cacheLoads = new AtomicLong(0);
@@ -75,7 +75,9 @@
    @Override
    public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeeded(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeeded(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
@@ -92,22 +94,29 @@
    @Override
    public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable {
       Object[] keys;
-      if ((keys = command.getKeys()) != null && keys.length > 0)
-         for (Object key : command.getKeys()) loadIfNeeded(ctx, key);
+      if ((keys = command.getKeys()) != null && keys.length > 0) {
+         for (Object key : command.getKeys()) {
+            loadIfNeeded(ctx, key);
+         }
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
    @Override
    public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeededAndUpdateStats(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeededAndUpdateStats(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
    @Override
    public Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command) throws Throwable {
       Object key;
-      if ((key = command.getKey()) != null) loadIfNeededAndUpdateStats(ctx, key);
+      if ((key = command.getKey()) != null) {
+         loadIfNeededAndUpdateStats(ctx, key);
+      }
       return invokeNextInterceptor(ctx, command);
    }
 
@@ -131,14 +140,20 @@
                return true;
             }
          } finally {
-            if (keyLocked && unlockOnWayOut) entryFactory.releaseLock(key);
+            if (keyLocked && unlockOnWayOut) {
+               entryFactory.releaseLock(key);
+            }
          }
 
          // we *may* need to load this.
          InternalCacheEntry loaded = loader.load(key);
          if (loaded == null) {
-            if (log.isTraceEnabled()) log.trace("No need to load.  Key doesn't exist in the loader.");
-            if (keyLocked) entryFactory.releaseLock(key);
+            if (log.isTraceEnabled()) {
+               log.trace("No need to load.  Key doesn't exist in the loader.");
+            }
+            if (keyLocked) {
+               entryFactory.releaseLock(key);
+            }
             return false;
          }
 
@@ -163,11 +178,13 @@
     * @param ctx the current invocation's context
     * @param key key to record
     * @param entry the appropriately locked entry in the caller's context
-    * @param loadedEntry the internal entry loaded from the cache store. 
+    * @param loadedEntry the internal entry loaded from the cache store.
     */
    private MVCCEntry recordLoadedEntry(InvocationContext ctx, Object key, MVCCEntry entry, InternalCacheEntry loadedEntry) throws Exception {
-      boolean entryExists = (loadedEntry != null);
-      if (log.isTraceEnabled()) log.trace("Entry exists in loader? " + entryExists);
+      boolean entryExists = loadedEntry != null;
+      if (log.isTraceEnabled()) {
+         log.trace("Entry exists in loader? " + entryExists);
+      }
 
       if (getStatisticsEnabled()) {
          if (entryExists) {
@@ -178,22 +195,23 @@
       }
 
       if (entryExists) {
-         sendNotification(key, true, ctx);
-         entry.setValue(loadedEntry.getValue());
+         final Object value = loadedEntry.getValue();
+         // FIXME: There's no point to trigger the entryLoaded/Activated event twice.
+         sendNotification(key, value, true, ctx);
+         entry.setValue(value);
          entry.setLifespan(loadedEntry.getLifespan());
          entry.setMaxIdle(loadedEntry.getMaxIdle());
          // TODO shouldn't we also be setting last used and created timestamps?
          entry.setValid(true);
 
-         notifier.notifyCacheEntryLoaded(key, false, ctx);
-         sendNotification(key, false, ctx);
+         sendNotification(key, value, false, ctx);
       }
 
       return entry;
    }
 
-   protected void sendNotification(Object key, boolean pre, InvocationContext ctx) {
-      notifier.notifyCacheEntryLoaded(key, pre, ctx);
+   protected void sendNotification(Object key, Object value, boolean pre, InvocationContext ctx) {
+      notifier.notifyCacheEntryLoaded(key, value, pre, ctx);
    }
 
    private void loadIfNeededAndUpdateStats(InvocationContext ctx, Object key) throws Throwable {
@@ -215,6 +233,7 @@
       return cacheMisses.get();
    }
 
+   @Override
    @ManagedOperation(description = "Resets statistics gathered by this component")
    @Operation(displayName = "Reset Statistics")
    public void resetStatistics() {

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifier.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -53,32 +53,32 @@
    /**
     * Notifies all registered listeners of a CacheEntryVisited event.
     */
-   void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryVisited(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryEvicted event.
     */
-   void notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryEvicted(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryInvalidated event.
     */
-   void notifyCacheEntryInvalidated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryInvalidated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryLoaded event.
     */
-   void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryLoaded(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryActivated event.
     */
-   void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryActivated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a CacheEntryPassivated event.
     */
-   void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx);
+   void notifyCacheEntryPassivated(Object key, Object value, boolean pre, InvocationContext ctx);
 
    /**
     * Notifies all registered listeners of a transaction completion event.

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -21,25 +21,47 @@
  */
 package org.infinispan.notifications.cachelistener;
 
+import static org.infinispan.notifications.cachelistener.event.Event.Type.*;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
 import org.infinispan.Cache;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.context.InvocationContextContainer;
 import org.infinispan.context.impl.TxInvocationContext;
 import org.infinispan.factories.annotations.Inject;
 import org.infinispan.notifications.AbstractListenerImpl;
-import org.infinispan.notifications.cachelistener.annotation.*;
-import org.infinispan.notifications.cachelistener.event.*;
-import static org.infinispan.notifications.cachelistener.event.Event.Type.*;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryActivated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryEvicted;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryInvalidated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryLoaded;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryPassivated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.infinispan.notifications.cachelistener.annotation.TransactionCompleted;
+import org.infinispan.notifications.cachelistener.annotation.TransactionRegistered;
+import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryInvalidatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryLoadedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryPassivatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
+import org.infinispan.notifications.cachelistener.event.EventImpl;
+import org.infinispan.notifications.cachelistener.event.TransactionCompletedEvent;
+import org.infinispan.notifications.cachelistener.event.TransactionRegisteredEvent;
 import org.infinispan.transaction.xa.GlobalTransaction;
 import org.infinispan.util.logging.Log;
 import org.infinispan.util.logging.LogFactory;
 
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
 /**
  * Helper class that handles all notifications to registered listeners.
  *
@@ -103,14 +125,17 @@
       this.cache = cache;
    }
 
+   @Override
    protected Log getLog() {
       return log;
    }
 
+   @Override
    protected Map<Class<? extends Annotation>, Class> getAllowedMethodAnnotations() {
       return allowedListeners;
    }
 
+   @Override
    public void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx) {
       if (!cacheEntryCreatedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -123,13 +148,16 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_CREATED);
-            for (ListenerInvocation listener : cacheEntryCreatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryCreatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyCacheEntryModified(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryModifiedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -143,13 +171,16 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_MODIFIED);
-            for (ListenerInvocation listener : cacheEntryModifiedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryModifiedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyCacheEntryRemoved(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryRemovedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
@@ -163,14 +194,17 @@
             e.setKey(key);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_REMOVED);
-            for (ListenerInvocation listener : cacheEntryRemovedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryRemovedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryVisited(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryVisitedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
@@ -178,16 +212,20 @@
             e.setCache(cache);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_VISITED);
-            for (ListenerInvocation listener : cacheEntryVisitedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryVisitedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryEvicted(final Object key, final boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryEvicted(final Object key, Object value, final boolean pre, InvocationContext ctx) {
       if (!cacheEntryEvictedListeners.isEmpty()) {
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -197,16 +235,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_EVICTED);
-            for (ListenerInvocation listener : cacheEntryEvictedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryEvictedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryInvalidated(final Object key, final boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryInvalidated(final Object key, Object value, final boolean pre, InvocationContext ctx) {
       if (!cacheEntryInvalidatedListeners.isEmpty()) {
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -216,16 +258,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_INVALIDATED);
-            for (ListenerInvocation listener : cacheEntryInvalidatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryInvalidatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryLoaded(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryLoadedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -235,16 +281,20 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_LOADED);
-            for (ListenerInvocation listener : cacheEntryLoadedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryLoadedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
-   public void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryActivated(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryActivatedListeners.isEmpty()) {
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
@@ -254,9 +304,12 @@
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_ACTIVATED);
-            for (ListenerInvocation listener : cacheEntryActivatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryActivatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
@@ -270,7 +323,8 @@
       }
    }
 
-   public void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx) {
+   @Override
+   public void notifyCacheEntryPassivated(Object key, Object value, boolean pre, InvocationContext ctx) {
       if (!cacheEntryPassivatedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
@@ -278,15 +332,19 @@
             e.setCache(cache);
             e.setPre(pre);
             e.setKey(key);
+            e.setValue(value);
             setTx(ctx, e);
             e.setType(CACHE_ENTRY_PASSIVATED);
-            for (ListenerInvocation listener : cacheEntryPassivatedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : cacheEntryPassivatedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyTransactionCompleted(GlobalTransaction transaction, boolean successful, InvocationContext ctx) {
       if (!transactionCompletedListeners.isEmpty()) {
          boolean isOriginLocal = ctx.isOriginLocal();
@@ -298,13 +356,16 @@
             e.setTransactionId(transaction);
             e.setTransactionSuccessful(successful);
             e.setType(TRANSACTION_COMPLETED);
-            for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
+            for (ListenerInvocation listener : transactionCompletedListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }
       }
    }
 
+   @Override
    public void notifyTransactionRegistered(GlobalTransaction globalTransaction, InvocationContext ctx) {
       if (!transactionRegisteredListeners.isEmpty()) {
          boolean isOriginLocal = ctx.isOriginLocal();
@@ -315,7 +376,9 @@
             e.setOriginLocal(isOriginLocal);
             e.setTransactionId(globalTransaction);
             e.setType(TRANSACTION_REGISTERED);
-            for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
+            for (ListenerInvocation listener : transactionRegisteredListeners) {
+               listener.invoke(e);
+            }
          } finally {
             icc.resume(contexts);
          }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryActivatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being activated.
+    *
+    * @return the value of the activated entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryEvictedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being evicted.
+    *
+    * @return the value of the evicted entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryInvalidatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being activated.
+    *
+    * @return the value of the invalidated entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryLoadedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being loaded.
+    *
+    * @return the value of the loaded entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryPassivatedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being passivated.
+    *
+    * @return the value of the passivated entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -28,4 +28,10 @@
  * @since 4.0
  */
 public interface CacheEntryVisitedEvent extends CacheEntryEvent {
+   /**
+    * Retrieves the value of the entry being visited.
+    *
+    * @return the value of the visited entry
+    */
+   Object getValue();
 }

Modified: trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierImplTest.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,15 +1,22 @@
 package org.infinispan.notifications.cachelistener;
 
+import static org.easymock.classextension.EasyMock.*;
+
 import org.easymock.EasyMock;
-import static org.easymock.classextension.EasyMock.createNiceMock;
 import org.infinispan.Cache;
 import org.infinispan.context.InvocationContext;
 import org.infinispan.context.InvocationContextContainer;
 import org.infinispan.context.InvocationContextContainerImpl;
 import org.infinispan.context.impl.NonTxInvocationContext;
+import org.infinispan.notifications.cachelistener.event.CacheEntryActivatedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryInvalidatedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryLoadedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryPassivatedEvent;
 import org.infinispan.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
 import org.infinispan.notifications.cachelistener.event.Event;
 import org.infinispan.notifications.cachelistener.event.TransactionCompletedEvent;
 import org.infinispan.notifications.cachelistener.event.TransactionRegisteredEvent;
@@ -88,8 +95,8 @@
    }
 
    public void testNotifyCacheEntryVisited() {
-      n.notifyCacheEntryVisited("k", true, ctx);
-      n.notifyCacheEntryVisited("k", false, ctx);
+      n.notifyCacheEntryVisited("k", "v", true, ctx);
+      n.notifyCacheEntryVisited("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -97,15 +104,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_VISITED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryVisitedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_VISITED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
-
+      assert ((CacheEntryVisitedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryEvicted() {
-      n.notifyCacheEntryEvicted("k", true, ctx);
-      n.notifyCacheEntryEvicted("k", false, ctx);
+      n.notifyCacheEntryEvicted("k", "v", true, ctx);
+      n.notifyCacheEntryEvicted("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -113,14 +121,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_EVICTED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryEvictedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_EVICTED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryEvictedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryInvalidated() {
-      n.notifyCacheEntryInvalidated("k", true, ctx);
-      n.notifyCacheEntryInvalidated("k", false, ctx);
+      n.notifyCacheEntryInvalidated("k", "v", true, ctx);
+      n.notifyCacheEntryInvalidated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -128,14 +138,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryInvalidatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryInvalidatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryLoaded() {
-      n.notifyCacheEntryLoaded("k", true, ctx);
-      n.notifyCacheEntryLoaded("k", false, ctx);
+      n.notifyCacheEntryLoaded("k", "v", true, ctx);
+      n.notifyCacheEntryLoaded("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -143,14 +155,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_LOADED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryLoadedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_LOADED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryLoadedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryActivated() {
-      n.notifyCacheEntryActivated("k", true, ctx);
-      n.notifyCacheEntryActivated("k", false, ctx);
+      n.notifyCacheEntryActivated("k", "v", true, ctx);
+      n.notifyCacheEntryActivated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -158,14 +172,16 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryActivatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryActivatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyCacheEntryPassivated() {
-      n.notifyCacheEntryPassivated("k", true, ctx);
-      n.notifyCacheEntryPassivated("k", false, ctx);
+      n.notifyCacheEntryPassivated("k", "v", true, ctx);
+      n.notifyCacheEntryPassivated("k", "v", false, ctx);
 
       assert cl.isReceivedPost();
       assert cl.isReceivedPre();
@@ -173,9 +189,11 @@
       assert cl.getEvents().get(0).getCache() == mockCache;
       assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+      assert ((CacheEntryPassivatedEvent) cl.getEvents().get(0)).getValue().equals("v");
       assert cl.getEvents().get(1).getCache() == mockCache;
       assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
       assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+      assert ((CacheEntryPassivatedEvent) cl.getEvents().get(1)).getValue().equals("v");
    }
 
    public void testNotifyTransactionCompleted() {

Modified: trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java	2010-10-20 10:50:44 UTC (rev 2524)
+++ trunk/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java	2010-10-20 13:04:25 UTC (rev 2525)
@@ -1,6 +1,13 @@
 package org.infinispan.notifications.cachelistener;
 
 import static org.easymock.EasyMock.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.transaction.TransactionManager;
+
 import org.infinispan.Cache;
 import org.infinispan.config.Configuration;
 import org.infinispan.context.InvocationContext;
@@ -15,11 +22,6 @@
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import javax.transaction.TransactionManager;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 @Test(groups = "functional", testName = "notifications.cachelistener.CacheNotifierTest")
 public class CacheNotifierTest extends AbstractInfinispanTest {
    private Cache<Object, Object> cache;
@@ -120,9 +122,9 @@
    public void testVisit() throws Exception {
       initCacheData("key", "value");
 
-      mockNotifier.notifyCacheEntryVisited(eq("key"), eq(true), isA(InvocationContext.class));
+      mockNotifier.notifyCacheEntryVisited(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
       expectLastCall().once();
-      mockNotifier.notifyCacheEntryVisited(eq("key"), eq(false), isA(InvocationContext.class));
+      mockNotifier.notifyCacheEntryVisited(eq("key"), eq("value"), eq(false), isA(InvocationContext.class));
       expectLastCall().once();
       replay(mockNotifier);
       cache.get("key");



More information about the infinispan-commits mailing list