[jbosscache-commits] JBoss Cache SVN: r7245 - in core/branches/flat/src/main/java/org/jboss/starobrno: interceptors and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Dec 3 10:19:08 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-12-03 10:19:08 -0500 (Wed, 03 Dec 2008)
New Revision: 7245

Removed:
   core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java
Modified:
   core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
   core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
   core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
Log:
Ordered sync handler is no longer necessary since we only register a single sync!!

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java	2008-12-03 13:41:59 UTC (rev 7244)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java	2008-12-03 15:19:08 UTC (rev 7245)
@@ -23,7 +23,6 @@
 
 import org.jboss.starobrno.commands.VisitableCommand;
 import org.jboss.starobrno.config.Option;
-import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
 
 import javax.transaction.Transaction;
 import java.util.List;
@@ -71,7 +70,7 @@
    /**
     * Adds the node that has been removed in the scope of the current transaction.
     *
-    * @param fqn fqn that has been removed.
+    * @param key fqn that has been removed.
     * @throws NullPointerException if the Fqn is null.
     */
    void addRemovedEntry(Object key);
@@ -225,7 +224,7 @@
    /**
     * Adds an Fqn to the list of uninitialized nodes created by the cache loader.
     *
-    * @param fqn fqn to add.  Must not be null.
+    * @param key fqn to add.  Must not be null.
     */
    void addDummyEntryCreatedByCacheLoader(Object key);
 
@@ -249,18 +248,6 @@
    Option getOption();
 
    /**
-    * @return the ordered sync handler associated with this transaction
-    */
-   OrderedSynchronizationHandler getOrderedSynchronizationHandler();
-
-   /**
-    * Associates an ordered sync handler with this transaction.
-    *
-    * @param orderedSynchronizationHandler to set
-    */
-   void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler);
-
-   /**
     * @return true if modifications were registered.
     */
    boolean hasModifications();

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java	2008-12-03 13:41:59 UTC (rev 7244)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java	2008-12-03 15:19:08 UTC (rev 7245)
@@ -25,18 +25,11 @@
 import org.jboss.starobrno.commands.VisitableCommand;
 import org.jboss.starobrno.config.Option;
 import org.jboss.starobrno.container.MVCCEntry;
-import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
 
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * A transaction context specially geared to dealing with MVCC.
@@ -51,8 +44,6 @@
     */
    private Transaction ltx = null;
    private Option option;
-   private OrderedSynchronizationHandler orderedSynchronizationHandler;
-
    private boolean forceAsyncReplication = false;
    private boolean forceSyncReplication = false;
 
@@ -90,7 +81,6 @@
    public TransactionContextImpl(Transaction tx) throws SystemException, RollbackException
    {
       ltx = tx;
-      orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
    }
 
    /**
@@ -100,7 +90,7 @@
     * would delegate to this method if a transaction is in scope.
     * <p/>
     *
-    * @param fqn fqn to look up
+    * @param key fqn to look up
     * @return a node, or null if it cannot be found.
     */
    public MVCCEntry lookupEntry(Object key)
@@ -150,7 +140,6 @@
 
    public void reset()
    {
-      orderedSynchronizationHandler = null;
       modificationList = null;
       localModifications = null;
       option = null;
@@ -316,16 +305,6 @@
       return this.option;
    }
 
-   public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
-   {
-      return orderedSynchronizationHandler;
-   }
-
-   public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
-   {
-      this.orderedSynchronizationHandler = orderedSynchronizationHandler;
-   }
-
    public boolean hasModifications()
    {
       return modificationList != null && !modificationList.isEmpty();

Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java	2008-12-03 13:41:59 UTC (rev 7244)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java	2008-12-03 15:19:08 UTC (rev 7245)
@@ -41,22 +41,12 @@
 import org.jboss.starobrno.jmx.annotations.ManagedOperation;
 import org.jboss.starobrno.lock.LockManager;
 import org.jboss.starobrno.notifications.Notifier;
-
 import org.jboss.starobrno.remoting.ReplicationException;
 import org.jboss.starobrno.transaction.GlobalTransaction;
-import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
 import org.jboss.starobrno.transaction.TransactionTable;
 
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import javax.transaction.*;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -675,14 +665,10 @@
    /**
     * Registers a sync hander against a tx.
     */
-   private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
+   private void registerHandler(Transaction tx, Synchronization sync, InvocationContext ctx) throws Exception
    {
-      OrderedSynchronizationHandler orderedHandler = ctx.getTransactionContext().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
-
-      if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
-
-      orderedHandler.registerAtHead(handler);// needs to be invoked first on TX commit
-
+      if (trace) log.trace("registering for TX completion: Synchronization (" + sync + ")");
+      tx.registerSynchronization(sync);
       notifier.notifyTransactionRegistered(tx, ctx);
    }
 

Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java	2008-12-03 13:41:59 UTC (rev 7244)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java	2008-12-03 15:19:08 UTC (rev 7245)
@@ -1,119 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.LinkedList;
-
-/**
- * Maintains a list of Synchronization handlers. Reason is that we have to
- * invoke certain handlers <em>before</em> others. See the description in
- * SyncTxUnitTestCase.testConcurrentPuts(). For example, for synchronous
- * replication, we have to execute the ReplicationInterceptor's
- * afterCompletion() <em>before</em> the TransactionInterceptor's.
- *
- * @author Bela Ban
- * @version $Id$
- */
-public class OrderedSynchronizationHandler implements Synchronization
-{
-   static final Log log = LogFactory.getLog(org.jboss.cache.interceptors.OrderedSynchronizationHandler.class);
-
-   private Transaction tx = null;
-   private final LinkedList<Synchronization> handlers = new LinkedList<Synchronization>();
-
-   public OrderedSynchronizationHandler(Transaction tx) throws SystemException, RollbackException
-   {
-      this.tx = tx;
-      tx.registerSynchronization(this);
-   }
-
-   public void registerAtHead(Synchronization handler)
-   {
-      register(handler, true);
-   }
-
-   public void registerAtTail(Synchronization handler)
-   {
-      register(handler, false);
-   }
-
-   void register(Synchronization handler, boolean head)
-   {
-      if (handler != null && !handlers.contains(handler))
-      {
-         if (head)
-            handlers.addFirst(handler);
-         else
-            handlers.addLast(handler);
-      }
-   }
-
-   public void beforeCompletion()
-   {
-      for (Synchronization sync : handlers)
-      {
-         sync.beforeCompletion();
-      }
-   }
-
-   public void afterCompletion(int status)
-   {
-      RuntimeException exceptionInAfterCompletion = null;
-      for (Synchronization sync : handlers)
-      {
-         try
-         {
-            sync.afterCompletion(status);
-         }
-         catch (Throwable t)
-         {
-            log.error("failed calling afterCompletion() on " + sync, t);
-            exceptionInAfterCompletion = (RuntimeException) t;
-         }
-      }
-
-      // throw the exception so the TM can deal with it.
-      if (exceptionInAfterCompletion != null) throw exceptionInAfterCompletion;
-   }
-
-   @Override
-   public String toString()
-   {
-      return "tx=" + getTxAsString() + ", handlers=" + handlers;
-   }
-
-   private String getTxAsString()
-   {
-      // JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
-      if (tx == null)
-         return null;
-
-      return tx.getClass().getName() + "@" + System.identityHashCode(tx);
-   }
-}
\ No newline at end of file




More information about the jbosscache-commits mailing list