[jbosscache-commits] JBoss Cache SVN: r6044 - in core/trunk/src/main/java/org/jboss/cache: transaction and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jun 25 14:28:12 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-06-25 14:28:12 -0400 (Wed, 25 Jun 2008)
New Revision: 6044

Modified:
   core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
Log:
Added caching of looked up nodes

Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-06-25 18:27:24 UTC (rev 6043)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-06-25 18:28:12 UTC (rev 6044)
@@ -59,24 +59,68 @@
 
    private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
 
+   /**
+    * Retrieves a node from the registry of looked up nodes in the current scope.
+    * <p/>
+    * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#lookUpNode(Fqn)}
+    * <p/>
+    *
+    * @param fqn fqn to look up
+    * @return a node, or null if it cannot be found.
+    * @since 3.0.
+    */
    public NodeSPI lookUpNode(Fqn fqn)
    {
-      // TODO: should delegate to TransactionEntry if one is in scope
+      if (transactionContext != null) return transactionContext.lookUpNode(fqn);
       return lookedUpNodes.get(fqn);
    }
 
+   /**
+    * Puts an entry in the registry of looked up nodes in the current scope.
+    * <p/>
+    * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#putLookedUpNode(Fqn, NodeSPI)}
+    * <p/>
+    *
+    * @param f fqn to add
+    * @param n node to add
+    * @since 3.0.
+    */
    public void putLookedUpNode(Fqn f, NodeSPI n)
    {
-      lookedUpNodes.put(f, n);
+      if (transactionContext != null)
+         transactionContext.putLookedUpNode(f, n);
+      else
+         lookedUpNodes.put(f, n);
    }
 
+   /**
+    * Clears the registry of looked up nodes.
+    * <p/>
+    * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#clearLookedUpNodes()}.
+    * <p/>
+    *
+    * @since 3.0.
+    */
    public void clearLookedUpNodes()
    {
-      lookedUpNodes.clear();
+      if (transactionContext != null)
+         transactionContext.clearLookedUpNodes();
+      else
+         lookedUpNodes.clear();
    }
 
+   /**
+    * Retrieves a map of nodes looked up within the current invocation's scope.
+    * <p/>
+    * If a transaction is in progress, this method will delegate to {@link org.jboss.cache.transaction.TransactionContext#getLookedUpNodes()}.
+    * <p/>
+    *
+    * @return a map of looked up nodes.
+    * @since 3.0
+    */
    public Map<Fqn, NodeSPI> getLookedUpNodes()
    {
+      if (transactionContext != null) return transactionContext.getLookedUpNodes();
       return lookedUpNodes;
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java	2008-06-25 18:27:24 UTC (rev 6043)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java	2008-06-25 18:28:12 UTC (rev 6044)
@@ -425,27 +425,67 @@
       return localModifications != null && !localModifications.isEmpty();
    }
 
+   /**
+    * Retrieves a node from the registry of looked up nodes in the current scope.
+    * <p/>
+    * This is not normally called directly since {@link org.jboss.cache.InvocationContext#lookUpNode(org.jboss.cache.Fqn)}
+    * would delegate to this method if a transaction is in scope.
+    * <p/>
+    *
+    * @param fqn fqn to look up
+    * @return a node, or null if it cannot be found.
+    * @since 3.0.
+    */
    public NodeSPI lookUpNode(Fqn fqn)
    {
       return lookedUpNodes.get(fqn);
    }
 
+   /**
+    * Puts an entry in the registry of looked up nodes in the current scope.
+    * <p/>
+    * This is not normally called directly since {@link org.jboss.cache.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSPI)}
+    * would delegate to this method if a transaction is in scope.
+    * <p/>
+    *
+    * @param f fqn to add
+    * @param n node to add
+    * @since 3.0.
+    */
    public void putLookedUpNode(Fqn f, NodeSPI n)
    {
       lookedUpNodes.put(f, n);
    }
 
+   /**
+    * Clears the registry of looked up nodes.
+    * <p/>
+    * This is not normally called directly since {@link org.jboss.cache.InvocationContext#clearLookedUpNodes()}
+    * would delegate to this method if a transaction is in scope.
+    * <p/>
+    *
+    * @since 3.0.
+    */
    public void clearLookedUpNodes()
    {
       lookedUpNodes.clear();
    }
 
+   /**
+    * Retrieves a map of nodes looked up within the current invocation's scope.
+    * <p/>
+    * This is not normally called directly since {@link org.jboss.cache.InvocationContext#getLookedUpNodes()}
+    * would delegate to this method if a transaction is in scope.
+    * <p/>
+    *
+    * @return a map of looked up nodes.
+    * @since 3.0
+    */
    public Map<Fqn, NodeSPI> getLookedUpNodes()
    {
       return lookedUpNodes;
    }
 
-
    /**
     * Cleans up internal state
     */




More information about the jbosscache-commits mailing list