[jbosscache-commits] JBoss Cache SVN: r6649 - in core/trunk/src: main/java/org/jboss/cache/invocation and 3 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Sep 1 01:15:41 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-09-01 01:15:40 -0400 (Mon, 01 Sep 2008)
New Revision: 6649

Modified:
   core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
   core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
   core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
Log:
Notification callbacks to allow for looked up nodes to be injected into call back contexts

Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -74,6 +74,13 @@
    public abstract void putLookedUpNode(Fqn f, NodeSPI n);
 
    /**
+    * Adds a map of looked up nodes to the current map of looked up nodes
+    *
+    * @param lookedUpNodes looked up nodes to add
+    */
+   public abstract void putLookedUpNodes(Map<Fqn, NodeSPI> lookedUpNodes);
+
+   /**
     * Clears the registry of looked up nodes.
     *
     * @since 3.0.

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -34,6 +34,11 @@
       throw new UnsupportedOperationException("Should not be called on legacy locking schemes!");
    }
 
+   public void putLookedUpNodes(Map<Fqn, NodeSPI> lookedUpNodes)
+   {
+      // a no-op by default.
+   }
+
    public void clearLookedUpNodes()
    {
       // no-op

Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -63,6 +63,19 @@
       }
    }
 
+   public void putLookedUpNodes(Map<Fqn, NodeSPI> lookedUpNodes)
+   {
+      if (mvccTCtx != null)
+         mvccTCtx.putLookedUpNodes(lookedUpNodes);
+      else
+      {
+         if (this.lookedUpNodes == null)
+            this.lookedUpNodes = new HashMap<Fqn, NodeSPI>(lookedUpNodes);
+         else
+            lookedUpNodes.putAll(lookedUpNodes);
+      }
+   }
+
    /**
     * Clears the registry of looked up nodes.
     * <p/>

Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -6,43 +6,6 @@
  */
 package org.jboss.cache.notifications;
 
-import static org.jboss.cache.notifications.event.Event.Type.BUDDY_GROUP_CHANGED;
-import static org.jboss.cache.notifications.event.Event.Type.CACHE_BLOCKED;
-import static org.jboss.cache.notifications.event.Event.Type.CACHE_STARTED;
-import static org.jboss.cache.notifications.event.Event.Type.CACHE_STOPPED;
-import static org.jboss.cache.notifications.event.Event.Type.CACHE_UNBLOCKED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_ACTIVATED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_CREATED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_EVICTED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_INVALIDATED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_LOADED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_MODIFIED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_MOVED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_PASSIVATED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_REMOVED;
-import static org.jboss.cache.notifications.event.Event.Type.NODE_VISITED;
-import static org.jboss.cache.notifications.event.Event.Type.TRANSACTION_COMPLETED;
-import static org.jboss.cache.notifications.event.Event.Type.TRANSACTION_REGISTERED;
-import static org.jboss.cache.notifications.event.Event.Type.VIEW_CHANGED;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.transaction.Transaction;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Cache;
@@ -58,49 +21,30 @@
 import org.jboss.cache.factories.annotations.Start;
 import org.jboss.cache.factories.annotations.Stop;
 import org.jboss.cache.marshall.MarshalledValueMap;
-import org.jboss.cache.notifications.annotation.BuddyGroupChanged;
-import org.jboss.cache.notifications.annotation.CacheBlocked;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheStarted;
-import org.jboss.cache.notifications.annotation.CacheStopped;
-import org.jboss.cache.notifications.annotation.CacheUnblocked;
-import org.jboss.cache.notifications.annotation.NodeActivated;
-import org.jboss.cache.notifications.annotation.NodeCreated;
-import org.jboss.cache.notifications.annotation.NodeEvicted;
-import org.jboss.cache.notifications.annotation.NodeInvalidated;
-import org.jboss.cache.notifications.annotation.NodeLoaded;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.annotation.NodeMoved;
-import org.jboss.cache.notifications.annotation.NodePassivated;
-import org.jboss.cache.notifications.annotation.NodeRemoved;
-import org.jboss.cache.notifications.annotation.NodeVisited;
-import org.jboss.cache.notifications.annotation.TransactionCompleted;
-import org.jboss.cache.notifications.annotation.TransactionRegistered;
-import org.jboss.cache.notifications.annotation.ViewChanged;
-import org.jboss.cache.notifications.event.BuddyGroupChangedEvent;
-import org.jboss.cache.notifications.event.CacheBlockedEvent;
-import org.jboss.cache.notifications.event.CacheStartedEvent;
-import org.jboss.cache.notifications.event.CacheStoppedEvent;
-import org.jboss.cache.notifications.event.CacheUnblockedEvent;
-import org.jboss.cache.notifications.event.Event;
-import org.jboss.cache.notifications.event.EventImpl;
-import org.jboss.cache.notifications.event.NodeActivatedEvent;
-import org.jboss.cache.notifications.event.NodeCreatedEvent;
-import org.jboss.cache.notifications.event.NodeEvictedEvent;
-import org.jboss.cache.notifications.event.NodeInvalidatedEvent;
-import org.jboss.cache.notifications.event.NodeLoadedEvent;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.notifications.event.NodeMovedEvent;
-import org.jboss.cache.notifications.event.NodePassivatedEvent;
-import org.jboss.cache.notifications.event.NodeRemovedEvent;
-import org.jboss.cache.notifications.event.NodeVisitedEvent;
-import org.jboss.cache.notifications.event.TransactionCompletedEvent;
-import org.jboss.cache.notifications.event.TransactionRegisteredEvent;
-import org.jboss.cache.notifications.event.ViewChangedEvent;
+import org.jboss.cache.notifications.annotation.*;
+import org.jboss.cache.notifications.event.*;
+import static org.jboss.cache.notifications.event.Event.Type.*;
 import org.jboss.cache.util.Immutables;
 import org.jboss.cache.util.concurrent.WithinThreadExecutor;
 import org.jgroups.View;
 
+import javax.transaction.Transaction;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
 /**
  * Helper class that handles all notifications to registered listeners.
  *
@@ -682,6 +626,9 @@
    {
       // wipe current context.
       cache.setInvocationContext(null);
+      // get a new Invocation Context
+      InvocationContext newContext = cache.getInvocationContext();
+      newContext.putLookedUpNodes(ctx.getLookedUpNodes());
       return ctx;
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -86,4 +86,9 @@
       super.reset();
       lookedUpNodes.clear();
    }
+
+   public void putLookedUpNodes(Map<Fqn, NodeSPI> lookedUpNodes)
+   {
+      lookedUpNodes.putAll(lookedUpNodes);
+   }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java	2008-09-01 05:13:32 UTC (rev 6648)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java	2008-09-01 05:15:40 UTC (rev 6649)
@@ -50,7 +50,6 @@
    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception
    {
-      log.debug("");
       CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
       cache = (CacheSPI<String, String>) instance.createCache(false);
       cache.getConfiguration().setCacheMode("local");
@@ -124,6 +123,9 @@
       Object obj = cache.get(fqn, "bean");
       assertEquals("Got bean", "A bean", obj);
 
+      if (listener.activationException != null) throw listener.activationException;
+      if (listener.passivationException != null) throw listener.passivationException;
+
       assertNull("No activation exception", listener.activationException);
       assertNull("No passivation exception", listener.passivationException);
       assertTrue(listener.activated.contains(fqn));




More information about the jbosscache-commits mailing list