[infinispan-commits] Infinispan SVN: r2605 - in branches/4.2.x/core/src: main/java/org/infinispan/notifications/cachelistener/event and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Tue Oct 26 11:22:40 EDT 2010


Author: manik.surtani at jboss.com
Date: 2010-10-26 11:22:38 -0400 (Tue, 26 Oct 2010)
New Revision: 2605

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/event/CacheEntryActivatedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryCreatedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvent.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/CacheEntryModifiedEvent.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/CacheEntryRemovedEvent.java
   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/Event.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionCompletedEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionRegisteredEvent.java
   branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionalEvent.java
   branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java
Log:
ISPN-704 - Make cache events generic where possible

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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/CacheNotifierImpl.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -102,7 +102,7 @@
    final List<ListenerInvocation> transactionCompletedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
 
    private InvocationContextContainer icc;
-   private Cache cache;
+   private Cache<Object, Object> cache;
 
    public CacheNotifierImpl() {
 
@@ -120,6 +120,7 @@
    }
 
    @Inject
+   @SuppressWarnings("unchecked")
    void injectDependencies(InvocationContextContainer icc, Cache cache) {
       this.icc = icc;
       this.cache = cache;
@@ -141,16 +142,12 @@
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_CREATED);
             e.setOriginLocal(originLocal);
             e.setPre(pre);
             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);
          }
@@ -163,17 +160,13 @@
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_MODIFIED);
             e.setOriginLocal(originLocal);
             e.setValue(value);
             e.setPre(pre);
             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);
          }
@@ -186,17 +179,13 @@
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_REMOVED);
             e.setOriginLocal(originLocal);
             e.setValue(value);
             e.setPre(pre);
             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);
          }
@@ -208,16 +197,12 @@
       if (!cacheEntryVisitedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_VISITED);
             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);
          }
@@ -230,17 +215,13 @@
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_EVICTED);
             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);
          }
@@ -253,17 +234,13 @@
          final boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_INVALIDATED);
             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);
          }
@@ -276,17 +253,13 @@
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_LOADED);
             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);
          }
@@ -299,17 +272,13 @@
          boolean originLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_ACTIVATED);
             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);
          }
@@ -328,16 +297,12 @@
       if (!cacheEntryPassivatedListeners.isEmpty()) {
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, CACHE_ENTRY_PASSIVATED);
             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);
          }
@@ -350,15 +315,11 @@
          boolean isOriginLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, TRANSACTION_COMPLETED);
             e.setOriginLocal(isOriginLocal);
             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);
          }
@@ -371,14 +332,10 @@
          boolean isOriginLocal = ctx.isOriginLocal();
          InvocationContext contexts = icc.suspend();
          try {
-            EventImpl e = new EventImpl();
-            e.setCache(cache);
+            EventImpl<Object, Object> e = EventImpl.createEvent(cache, TRANSACTION_REGISTERED);
             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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryActivatedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryActivatedEvent extends CacheEntryEvent {
+public interface CacheEntryActivatedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being activated.
     *
     * @return the value of the activated entry
     */
-   Object getValue();
+   V getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryCreatedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryCreatedEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryCreatedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,5 +27,5 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryCreatedEvent extends CacheEntryEvent {
+public interface CacheEntryCreatedEvent<K, V> extends CacheEntryEvent<K, V> {
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,9 +27,9 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryEvent extends TransactionalEvent {
+public interface CacheEntryEvent<K, V> extends TransactionalEvent<K, V> {
    /**
     * @return the key to the affected cache entry.
     */
-   Object getKey();
+   K getKey();
 }

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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryEvictedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryEvictedEvent extends CacheEntryEvent {
+public interface CacheEntryEvictedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being evicted.
     *
     * @return the value of the evicted entry
     */
-   Object getValue();
+   V 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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryInvalidatedEvent extends CacheEntryEvent {
+public interface CacheEntryInvalidatedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being activated.
     *
     * @return the value of the invalidated entry
     */
-   Object getValue();
+   V 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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryLoadedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryLoadedEvent extends CacheEntryEvent {
+public interface CacheEntryLoadedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being loaded.
     *
     * @return the value of the loaded entry
     */
-   Object getValue();
+   V getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryModifiedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryModifiedEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryModifiedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -32,11 +32,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryModifiedEvent extends CacheEntryEvent {
+public interface CacheEntryModifiedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being modified.
     * <p />
     * @return the previous or new value of the entry, depending on whether isPre() is true or false.
     */
-   Object getValue();
+   V 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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryPassivatedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryPassivatedEvent extends CacheEntryEvent {
+public interface CacheEntryPassivatedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being passivated.
     *
     * @return the value of the passivated entry
     */
-   Object getValue();
+   V getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryRemovedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryRemovedEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryRemovedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -30,12 +30,12 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryRemovedEvent extends CacheEntryEvent {
+public interface CacheEntryRemovedEvent<K, V> extends CacheEntryEvent<K, V> {
 
    /**
     * Retrieves the value of the entry being deleted.
     * <p />
     * @return the value of the entry being deleted, if <tt>isPre()</tt> is <tt>true</tt>.  <tt>null</tt> otherwise.
     */
-   Object getValue();
+   V 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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/CacheEntryVisitedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -27,11 +27,11 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface CacheEntryVisitedEvent extends CacheEntryEvent {
+public interface CacheEntryVisitedEvent<K, V> extends CacheEntryEvent<K, V> {
    /**
     * Retrieves the value of the entry being visited.
     *
     * @return the value of the visited entry
     */
-   Object getValue();
+   V getValue();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/Event.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/Event.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/Event.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -29,7 +29,7 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface Event {
+public interface Event<K, V> {
    static enum Type {
       CACHE_ENTRY_ACTIVATED, CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED,
       CACHE_ENTRY_LOADED, CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, CACHE_ENTRY_MODIFIED,
@@ -49,5 +49,5 @@
    /**
     * @return a handle to the cache instance that generated this notification.
     */
-   Cache getCache();
+   Cache<K, V> getCache();
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/EventImpl.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -34,21 +34,28 @@
  * @since 4.0
  */
 @NotThreadSafe
-public class EventImpl implements CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
+public class EventImpl<K, V> implements CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
                                   CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
                                   CacheEntryInvalidatedEvent {
    private boolean pre = false; // by default events are after the fact
-   private Cache cache;
-   private Object key;
+   private Cache<K, V> cache;
+   private K key;
    private GlobalTransaction transaction;
    private boolean originLocal = true; // by default events all originate locally
    private boolean transactionSuccessful;
    private Type type;
-   private Object value;
+   private V value;
 
    public EventImpl() {
    }
 
+   public static <K, V> EventImpl<K, V> createEvent(Cache<K, V> cache, Type type) {
+      EventImpl<K, V> e = new EventImpl<K,V>();
+      e.cache = cache;
+      e.type = type;
+      return e;
+   }
+
    public Type getType() {
       return type;
    }
@@ -57,13 +64,14 @@
       return pre;
    }
 
-   public Cache getCache() {
+   public Cache<K, V> getCache() {
       return cache;
    }
 
-   public Object getKey() {
+   @SuppressWarnings("unchecked")
+   public K getKey() {
       if (key instanceof MarshalledValue)
-         key = ((MarshalledValue) key).get();
+         key = (K) ((MarshalledValue) key).get();
       return key;
    }
 
@@ -85,11 +93,11 @@
       this.pre = pre;
    }
 
-   public void setCache(Cache cache) {
+   public void setCache(Cache<K, V> cache) {
       this.cache = cache;
    }
 
-   public void setKey(Object key) {
+   public void setKey(K key) {
       this.key = key;
    }
 
@@ -109,13 +117,14 @@
       this.type = type;
    }
 
-   public Object getValue() {
+   @SuppressWarnings("unchecked")
+   public V getValue() {
       if (value instanceof MarshalledValue)
-         value = ((MarshalledValue) value).get();
+         value = (V) ((MarshalledValue) value).get();
       return value;
    }
 
-   public void setValue(Object value) {
+   public void setValue(V value) {
       this.value = value;
    }
 

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionCompletedEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionCompletedEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionCompletedEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -30,7 +30,7 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface TransactionCompletedEvent extends TransactionalEvent {
+public interface TransactionCompletedEvent<K, V> extends TransactionalEvent<K, V> {
    /**
     * @return if <tt>true</tt>, the transaction completed by committing successfully.  If <tt>false</tt>, the
     *         transaction completed with a rollback.

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionRegisteredEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionRegisteredEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionRegisteredEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -30,5 +30,5 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface TransactionRegisteredEvent extends TransactionalEvent {
+public interface TransactionRegisteredEvent<K, V> extends TransactionalEvent<K, V> {
 }

Modified: branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionalEvent.java
===================================================================
--- branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionalEvent.java	2010-10-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/main/java/org/infinispan/notifications/cachelistener/event/TransactionalEvent.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -30,7 +30,7 @@
  * @author Manik Surtani
  * @since 4.0
  */
-public interface TransactionalEvent extends Event {
+public interface TransactionalEvent<K, V> extends Event<K, V> {
    /**
     * @return the Transaction associated with the current call.  May be null if the current call is outside the scope of
     *         a transaction.

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-25 16:30:20 UTC (rev 2604)
+++ branches/4.2.x/core/src/test/java/org/infinispan/notifications/cachelistener/CacheNotifierTest.java	2010-10-26 15:22:38 UTC (rev 2605)
@@ -59,7 +59,7 @@
       initCacheData(Collections.singletonMap(key, value));
    }
 
-   private void initCacheData(Map data) {
+   private void initCacheData(Map<Object, Object> data) {
       mockNotifier.notifyCacheEntryCreated(anyObject(), anyBoolean(), isA(InvocationContext.class));
       expectLastCall().anyTimes();
       mockNotifier.notifyCacheEntryModified(anyObject(), anyObject(), anyBoolean(), isA(InvocationContext.class));
@@ -138,7 +138,7 @@
    }
 
    public void testRemoveData() throws Exception {
-      Map data = new HashMap();
+      Map<Object, Object> data = new HashMap<Object, Object>();
       data.put("key", "value");
       data.put("key2", "value2");
       initCacheData(data);
@@ -216,7 +216,7 @@
    }
 
    public void testTxRemoveData() throws Exception {
-      Map data = new HashMap();
+      Map<Object, Object> data = new HashMap<Object, Object>();
       data.put("key", "value");
       data.put("key2", "value2");
       initCacheData(data);



More information about the infinispan-commits mailing list