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

Manik Surtani msurtani at jboss.com
Sat Dec 30 14:48:47 EST 2006


  User: msurtani
  Date: 06/12/30 14:48:47

  Modified:    src/org/jboss/cache/transaction   DummyUserTransaction.java
                        DummyBaseTransactionManager.java
  Log:
  Genericised, autoboxed
  
  Revision  Changes    Path
  1.5       +33 -18    JBossCache/src/org/jboss/cache/transaction/DummyUserTransaction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DummyUserTransaction.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/transaction/DummyUserTransaction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- DummyUserTransaction.java	20 Feb 2006 19:34:46 -0000	1.4
  +++ DummyUserTransaction.java	30 Dec 2006 19:48:47 -0000	1.5
  @@ -3,29 +3,38 @@
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  -import javax.transaction.*;
  +import javax.transaction.HeuristicMixedException;
  +import javax.transaction.HeuristicRollbackException;
  +import javax.transaction.NotSupportedException;
  +import javax.transaction.RollbackException;
  +import javax.transaction.Status;
  +import javax.transaction.Synchronization;
  +import javax.transaction.SystemException;
  +import javax.transaction.UserTransaction;
   import java.util.ArrayList;
   import java.util.List;
   
   /**
    * @author bela
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    *          Date: May 15, 2003
    *          Time: 4:20:17 PM
    */
  -public class DummyUserTransaction implements UserTransaction, java.io.Serializable {
  -   int status=Status.STATUS_UNKNOWN;
  -   static final Log logger_=LogFactory.getLog(DummyUserTransaction.class);
  +public class DummyUserTransaction implements UserTransaction, java.io.Serializable
  +{
  +   int status = Status.STATUS_UNKNOWN;
  +   static final Log logger_ = LogFactory.getLog(DummyUserTransaction.class);
      DummyTransactionManager tm_;
      private static final long serialVersionUID = -6568400755677046127L;         
   
      /**
       * List<Synchronization>
       */
  -   List l=new ArrayList();
  +   List<Synchronization> l = new ArrayList<Synchronization>();
   
  -   public DummyUserTransaction(DummyTransactionManager tm) {
  -      tm_=tm;
  +   public DummyUserTransaction(DummyTransactionManager tm)
  +   {
  +      tm_ = tm;
      }
   
   
  @@ -38,9 +47,10 @@
       * @throws SystemException       If the transaction service fails in an
       *                               unexpected way.
       */
  -   public void begin() throws NotSupportedException, SystemException {
  +   public void begin() throws NotSupportedException, SystemException
  +   {
         tm_.begin();
  -      status=Status.STATUS_ACTIVE;
  +      status = Status.STATUS_ACTIVE;
      }
   
      /**
  @@ -61,10 +71,11 @@
       */
      public void commit()
              throws RollbackException, HeuristicMixedException,
  -           HeuristicRollbackException, SecurityException, SystemException {
  +           HeuristicRollbackException, SecurityException, SystemException
  +   {
   
         tm_.commit();
  -      status=Status.STATUS_COMMITTED;
  +      status = Status.STATUS_COMMITTED;
      }
   
      /**
  @@ -77,9 +88,10 @@
       * @throws SystemException       If the transaction service fails in an
       *                               unexpected way.
       */
  -   public void rollback() throws IllegalStateException, SystemException {
  +   public void rollback() throws IllegalStateException, SystemException
  +   {
         tm_.rollback();
  -      status=Status.STATUS_ROLLEDBACK;
  +      status = Status.STATUS_ROLLEDBACK;
      }
   
      /**
  @@ -90,7 +102,8 @@
       * @throws SystemException       If the transaction service fails in an
       *                               unexpected way.
       */
  -   public void setRollbackOnly() throws IllegalStateException, SystemException {
  +   public void setRollbackOnly() throws IllegalStateException, SystemException
  +   {
         tm_.setRollbackOnly();
      }
   
  @@ -102,7 +115,8 @@
       * @throws SystemException If the transaction service fails in an
       *                         unexpected way.
       */
  -   public int getStatus() throws SystemException {
  +   public int getStatus() throws SystemException
  +   {
         return tm_.getStatus();
      }
   
  @@ -116,7 +130,8 @@
       * @throws SystemException If the transaction service fails in an
       *                         unexpected way.
       */
  -   public void setTransactionTimeout(int seconds) throws SystemException {
  +   public void setTransactionTimeout(int seconds) throws SystemException
  +   {
         throw new SystemException("not supported");
      }
   
  
  
  
  1.4       +101 -67   JBossCache/src/org/jboss/cache/transaction/DummyBaseTransactionManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DummyBaseTransactionManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/transaction/DummyBaseTransactionManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- DummyBaseTransactionManager.java	9 Mar 2006 23:11:05 -0000	1.3
  +++ DummyBaseTransactionManager.java	30 Dec 2006 19:48:47 -0000	1.4
  @@ -1,62 +1,79 @@
   package org.jboss.cache.transaction;
   
  -import javax.transaction.*;
  +import javax.transaction.HeuristicMixedException;
  +import javax.transaction.HeuristicRollbackException;
  +import javax.transaction.InvalidTransactionException;
  +import javax.transaction.NotSupportedException;
  +import javax.transaction.RollbackException;
  +import javax.transaction.Status;
  +import javax.transaction.SystemException;
  +import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
   
   /**
    * @author bela
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    *          Date: May 15, 2003
    *          Time: 4:11:37 PM
    */
  -public class DummyBaseTransactionManager implements TransactionManager, java.io.Serializable {
  -   static ThreadLocal thread_local=new ThreadLocal();
  +public class DummyBaseTransactionManager implements TransactionManager, java.io.Serializable
  +{
  +   static ThreadLocal<Transaction> thread_local = new ThreadLocal<Transaction>();
       private static final long serialVersionUID = -6716097342564237376l;
   
      /**
       * Starts a new transaction, and associate it with the calling thread.
       *
  -    * @throws javax.transaction.NotSupportedException If the calling thread is already
  +    * @throws javax.transaction.NotSupportedException
  +    *          If the calling thread is already
       *                               associated with a transaction, and nested transactions are
       *                               not supported.
  -    * @throws javax.transaction.SystemException       If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *          If the transaction service fails in an
       *                               unexpected way.
       */
  -   public void begin() throws NotSupportedException, SystemException {
  +   public void begin() throws NotSupportedException, SystemException
  +   {
         Transaction currentTx;
  -      if((currentTx=getTransaction()) != null)
  +      if ((currentTx = getTransaction()) != null)
            throw new NotSupportedException(Thread.currentThread() +
                                            " is already associated with a transaction (" + currentTx + ")");
  -      DummyTransaction tx=new DummyTransaction(this);
  +      DummyTransaction tx = new DummyTransaction(this);
         setTransaction(tx);
      }
   
      /**
       * Commit the transaction associated with the calling thread.
       *
  -    * @throws javax.transaction.RollbackException          If the transaction was marked for rollback
  +    * @throws javax.transaction.RollbackException
  +    *                               If the transaction was marked for rollback
       *                                    only, the transaction is rolled back and this exception is
       *                                    thrown.
       * @throws IllegalStateException      If the calling thread is not associated
       *                                    with a transaction.
  -    * @throws javax.transaction.SystemException            If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *                               If the transaction service fails in an
       *                                    unexpected way.
  -    * @throws javax.transaction.HeuristicMixedException    If a heuristic decision was made and
  +    * @throws javax.transaction.HeuristicMixedException
  +    *                               If a heuristic decision was made and
       *                                    some some parts of the transaction have been committed while
       *                                    other parts have been rolled back.
  -    * @throws javax.transaction.HeuristicRollbackException If a heuristic decision to roll
  +    * @throws javax.transaction.HeuristicRollbackException
  +    *                               If a heuristic decision to roll
       *                                    back the transaction was made.
       * @throws SecurityException          If the caller is not allowed to commit this
       *                                    transaction.
       */
      public void commit() throws RollbackException, HeuristicMixedException,
              HeuristicRollbackException, SecurityException,
  -           IllegalStateException, SystemException {
  +           IllegalStateException, SystemException
  +   {
         int status;
  -      Transaction tx=getTransaction();
  -      if(tx == null)
  +      Transaction tx = getTransaction();
  +      if (tx == null)
            throw new IllegalStateException("thread not associated with transaction");
  -      status=tx.getStatus();
  -      if(status == Status.STATUS_MARKED_ROLLBACK)
  +      status = tx.getStatus();
  +      if (status == Status.STATUS_MARKED_ROLLBACK)
            throw new RollbackException();
         tx.commit();
   
  @@ -74,13 +91,15 @@
       *                               {@link javax.transaction.Status#STATUS_PREPARED prepared state}.
       * @throws SecurityException     If the caller is not allowed to roll back
       *                               this transaction.
  -    * @throws javax.transaction.SystemException       If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *                               If the transaction service fails in an
       *                               unexpected way.
       */
      public void rollback() throws IllegalStateException, SecurityException,
  -           SystemException {
  -      Transaction tx=getTransaction();
  -      if(tx == null)
  +           SystemException
  +   {
  +      Transaction tx = getTransaction();
  +      if (tx == null)
            throw new IllegalStateException("no transaction associated with thread");
         tx.rollback();
   
  @@ -97,12 +116,14 @@
       *                               calling thread is not associated with a transaction, or
       *                               because it is in the
       *                               {@link javax.transaction.Status#STATUS_PREPARED prepared state}.
  -    * @throws javax.transaction.SystemException       If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *                               If the transaction service fails in an
       *                               unexpected way.
       */
  -   public void setRollbackOnly() throws IllegalStateException, SystemException {
  -      Transaction tx=getTransaction();
  -      if(tx == null)
  +   public void setRollbackOnly() throws IllegalStateException, SystemException
  +   {
  +      Transaction tx = getTransaction();
  +      if (tx == null)
            throw new IllegalStateException("no transaction associated with calling thread");
         tx.setRollbackOnly();
      }
  @@ -114,11 +135,13 @@
       *         {@link javax.transaction.Status} constants. If no transaction is associated
       *         with the calling thread,
       *         {@link javax.transaction.Status#STATUS_NO_TRANSACTION} is returned.
  -    * @throws javax.transaction.SystemException If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *          If the transaction service fails in an
       *                         unexpected way.
       */
  -   public int getStatus() throws SystemException {
  -      Transaction tx=getTransaction();
  +   public int getStatus() throws SystemException
  +   {
  +      Transaction tx = getTransaction();
         return tx != null ? tx.getStatus() : Status.STATUS_NO_TRANSACTION;
      }
   
  @@ -128,11 +151,13 @@
       * @return The transaction associated with the calling thread, or
       *         <code>null</code> if the calling thread is not associated
       *         with a transaction.
  -    * @throws javax.transaction.SystemException If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *          If the transaction service fails in an
       *                         unexpected way.
       */
  -   public Transaction getTransaction() throws SystemException {
  -      return (Transaction)thread_local.get();
  +   public Transaction getTransaction() throws SystemException
  +   {
  +      return thread_local.get();
      }
   
      /**
  @@ -142,10 +167,12 @@
       * @param seconds The new timeout value, in seconds. If this parameter
       *                is <code>0</code>, the timeout value is reset to the default
       *                value.
  -    * @throws javax.transaction.SystemException If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *          If the transaction service fails in an
       *                         unexpected way.
       */
  -   public void setTransactionTimeout(int seconds) throws SystemException {
  +   public void setTransactionTimeout(int seconds) throws SystemException
  +   {
         throw new SystemException("not supported");
      }
   
  @@ -158,11 +185,13 @@
       * @return The transaction that the calling thread was associated with,
       *         or <code>null</code> if the calling thread was not associated
       *         with a transaction.
  -    * @throws javax.transaction.SystemException If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *          If the transaction service fails in an
       *                         unexpected way.
       */
  -   public Transaction suspend() throws SystemException {
  -      Transaction retval=getTransaction();
  +   public Transaction suspend() throws SystemException
  +   {
  +      Transaction retval = getTransaction();
         setTransaction(null);
         return retval;
      }
  @@ -172,22 +201,27 @@
       * transaction.
       *
       * @param tx The transaction to be associated with the calling thread.
  -    * @throws javax.transaction.InvalidTransactionException If the argument does not represent
  +    * @throws javax.transaction.InvalidTransactionException
  +    *                               If the argument does not represent
       *                                     a valid transaction.
       * @throws IllegalStateException       If the calling thread is already
       *                                     associated with a transaction.
  -    * @throws javax.transaction.SystemException             If the transaction service fails in an
  +    * @throws javax.transaction.SystemException
  +    *                               If the transaction service fails in an
       *                                     unexpected way.
       */
  -   public void resume(Transaction tx) throws InvalidTransactionException, IllegalStateException, SystemException {
  +   public void resume(Transaction tx) throws InvalidTransactionException, IllegalStateException, SystemException
  +   {
         setTransaction(tx);
      }
   
      /**
       * Just used for unit tests
  +    *
       * @param tx
       */
  -   public void setTransaction(Transaction tx) {
  +   public void setTransaction(Transaction tx)
  +   {
         thread_local.set(tx);
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list