[jboss-cvs] JBossCache/src/org/jboss/cache ...

Manik Surtani msurtani at jboss.com
Wed Jul 19 14:54:07 EDT 2006


  User: msurtani
  Date: 06/07/19 14:54:07

  Modified:    src/org/jboss/cache  TreeCache.java
  Log:
  Added ThreadLocal container to invocation context object
  
  Revision  Changes    Path
  1.203     +26 -125   JBossCache/src/org/jboss/cache/TreeCache.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TreeCache.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
  retrieving revision 1.202
  retrieving revision 1.203
  diff -u -b -r1.202 -r1.203
  --- TreeCache.java	19 Jul 2006 08:29:18 -0000	1.202
  +++ TreeCache.java	19 Jul 2006 18:54:07 -0000	1.203
  @@ -79,7 +79,7 @@
    * @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
    * @author Brian Stansberry
    * @author Daniel Huang (dhuang at jboss.org)
  - * @version $Id: TreeCache.java,v 1.202 2006/07/19 08:29:18 msurtani Exp $
  + * @version $Id: TreeCache.java,v 1.203 2006/07/19 18:54:07 msurtani Exp $
    *          <p/>
    * @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
    */
  @@ -249,12 +249,6 @@
      protected IsolationLevel isolationLevel = IsolationLevel.REPEATABLE_READ;
   
      /**
  -    * This ThreadLocal contains an {@see InvocationContext} object, which holds
  -    * invocation-specific details.
  -    */
  -   private ThreadLocal invocationContextContainer = new ThreadLocal();
  -
  -   /**
       * Eviction policy configuration in xml Element
       */
      protected Element evictConfig_ = null;
  @@ -2374,7 +2368,7 @@
            finally
            {
               // Clear any invocation context from this thread
  -            setInvocationContext(null);
  +            InvocationContext.setCurrent(null);
            }
         }
      }
  @@ -2397,9 +2391,6 @@
       * @param suppressErrors should any Throwable thrown be suppressed?
       * @return a serialized byte[][], element 0 is the transient state
       *         (or null), and element 1 is the persistent state (or null).
  -    * @throws UnsupportedOperationException if persistent state transfer is
  -    *                                       enabled, the requested Fqn is not the root node, and the
  -    *                                       cache loader does not implement {@link ExtendedCacheLoader}.
       */
      public byte[] _getState(Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Throwable
      {
  @@ -2430,7 +2421,6 @@
         if (rootNode == null)
            return null;
   
  -      boolean getRoot = rootNode.equals(root);
         boolean fetchTransientState  = getFetchInMemoryState();
         boolean fetchPersistentState = getFetchPersistentState();
   
  @@ -3113,7 +3103,7 @@
       */
      public DataNode get(Fqn fqn, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
   
         try
         {
  @@ -3121,7 +3111,7 @@
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3136,14 +3126,14 @@
       */
      public Object get(Fqn fqn, Object key, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            return get(fqn, key);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3153,14 +3143,14 @@
       */
      public Object get(Fqn fqn, Object key, boolean sendNodeEvent, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            return get(fqn, key, sendNodeEvent);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3170,14 +3160,14 @@
       */
      public void remove(Fqn fqn, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            remove(fqn);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3187,14 +3177,14 @@
       */
      public Object remove(Fqn fqn, Object key, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            return remove(fqn, key);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3204,14 +3194,14 @@
       */
      public Set getChildrenNames(Fqn fqn, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            return getChildrenNames(fqn);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
   
      }
  @@ -3222,14 +3212,14 @@
       */
      public void put(Fqn fqn, Map data, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            put(fqn, data);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -3239,14 +3229,14 @@
       */
      public void put(Fqn fqn, Object key, Object value, Option option) throws CacheException
      {
  -      getInvocationContext().setOptionOverrides(option);
  +      InvocationContext.getCurrent().setOptionOverrides(option);
         try
         {
            put(fqn, key, value);
         }
         finally
         {
  -         getInvocationContext().setOptionOverrides(null);
  +         InvocationContext.getCurrent().setOptionOverrides(null);
         }
      }
   
  @@ -4719,7 +4709,7 @@
      {
         try
         {
  -         getInvocationContext().setOriginLocal(false);
  +         InvocationContext.getCurrent().setOriginLocal(false);
            return invokeMethod(method_call);
         }
         catch (Exception ex)
  @@ -4729,7 +4719,7 @@
         }
         finally
         {
  -         getInvocationContext().setOriginLocal(true);
  +         InvocationContext.getCurrent().setOriginLocal(true);
         }
      }
   
  @@ -4893,68 +4883,6 @@
          return list;
      }
   
  -
  -    /**
  -     * Performs a search.  returns a 2-dim object array, 0 - callResult, 1 - actualFqn (if found in a backup subtree), null otherwise
  -     * @param m
  -     * @param args
  -     * @param searchBackupSubtrees
  -     * @return
  -     * @throws Exception
  -     */
  -//   private Object[] findForClusteredGet(MethodCall mc, Object[] args, boolean searchBackupSubtrees) throws Exception
  -//   {
  -//       Fqn fqn = (Fqn) args[0];
  -//       Method m = mc.getMethod();
  -//
  -//       if (log.isTraceEnabled()) log.trace("Invoking call " + m + " with Fqn " + fqn);
  -//       Object callResults = m.invoke(this, args);
  -//       boolean found = validResult(callResults, mc, fqn);
  -//       if (log.isTraceEnabled()) log.trace("Got result " + callResults + ", found=" + found);
  -//       if (found && callResults == null) callResults = createEmptyResults(mc);
  -//
  -//       if (found)
  -//       {
  -//           return new Object[]{callResults, null};
  -//       }
  -//       else if (searchBackupSubtrees)
  -//       {
  -//            return findForClusteredGetBackupTree(mc, args);
  -//       }
  -//       else return null;
  -//   }
  -
  -//   private Object[] findForClusteredGetBackupTree(MethodCall mc, Object[] args) throws Exception
  -//   {
  -//       // first find all the backup subtrees we have.
  -//       DataNode backupSubtree = findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
  -//       if (backupSubtree == null) return null; // couldn't find anything here
  -//       Map children = backupSubtree.getChildren();
  -//       if (children != null)
  -//       {
  -//           Fqn originalFqn = (Fqn) args[0];
  -//
  -//           Iterator childNames = children.keySet().iterator();
  -//
  -//           Object[] retVal = null;
  -//
  -//           while (childNames.hasNext() && retVal == null)
  -//           {
  -//               Fqn backupSubtreeFqn = BuddyManager.getBackupFqn(childNames.next().toString(), originalFqn);
  -//
  -//               args[0] = backupSubtreeFqn;
  -//
  -//               Object[] callResult = findForClusteredGet(mc, args, false);
  -//
  -//               if (callResult != null) retVal = new Object[]{callResult[0], backupSubtreeFqn};
  -//           }
  -//
  -//           return retVal;
  -//       }
  -//       else return null; // couldnt find anything
  -//   }
  -
  -
       // ------------- start: buddy replication specific 'lifecycle' method calls
   
       public void _remoteAssignToBuddyGroup(BuddyGroup group, Map state) throws Exception
  @@ -5640,13 +5568,13 @@
      {
         if (evictionPolicyListener != null)
         {
  -        evictionPolicyListener.nodeRemoved(fqn, pre, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
  +        evictionPolicyListener.nodeRemoved(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
         }
         if (hasListeners)
         {
            for (CacheListener listener : listeners)
            {
  -               listener.nodeRemoved(fqn, pre, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
  +               listener.nodeRemoved(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
            }
         }
      }
  @@ -5655,13 +5583,13 @@
      {
         if (evictionPolicyListener != null)
         {
  -         evictionPolicyListener.nodeRemoved(fqn, false, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
  +         evictionPolicyListener.nodeRemoved(fqn, false, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
         }
         if (hasListeners)
         {
            for (CacheListener listener : listeners)
            {
  -            listener.nodeRemoved(fqn, false, getInvocationContext().isOriginLocal(), Collections.EMPTY_MAP);
  +            listener.nodeRemoved(fqn, false, InvocationContext.getCurrent().isOriginLocal(), Collections.EMPTY_MAP);
            }
         }
      }
  @@ -5708,13 +5636,13 @@
      {
         if (evictionPolicyListener != null)
         {
  -        evictionPolicyListener.nodeModified(fqn, pre, getInvocationContext().isOriginLocal(), null);
  +        evictionPolicyListener.nodeModified(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), null);
         }
         if (hasListeners)
         {
             for (CacheListener listener : listeners)
             {
  -              listener.nodeModified(fqn, pre, getInvocationContext().isOriginLocal(), null);
  +              listener.nodeModified(fqn, pre, InvocationContext.getCurrent().isOriginLocal(), null);
             }
         }
      }
  @@ -5869,33 +5797,6 @@
            cacheLoaderManager.setConfig(cloaderConfig, this);
         }
      }
  -
  -   /**
  -    * Sets the thread-local invocation context
  -    *
  -    * @param invocationContext the context for the current invocation
  -    */
  -   public void setInvocationContext(InvocationContext invocationContext)
  -   {
  -      invocationContextContainer.set(invocationContext);
  -   }
  -
  -   /**
  -    * Retrieves the thread-local InvocationContext.
  -    *
  -    * @return the context for the current invocation
  -    */
  -   public InvocationContext getInvocationContext()
  -   {
  -      InvocationContext ctx = (InvocationContext) invocationContextContainer.get();
  -      if (ctx == null)
  -      {
  -         ctx = new InvocationContext();
  -         invocationContextContainer.set(ctx);
  -      }
  -      return ctx;
  -   }
  -
      // ---------------------------------------------------------------
      // START: Methods to provide backward compatibility with older cache loader config settings
      // ---------------------------------------------------------------
  
  
  



More information about the jboss-cvs-commits mailing list