[jboss-cvs] jboss-jms/src/main/org/jboss/messaging/core/tx ...

Timothy Fox tim.fox at jboss.com
Thu Jul 20 10:04:02 EDT 2006


  User: timfox  
  Date: 06/07/20 10:04:02

  Modified:    src/main/org/jboss/messaging/core/tx  Transaction.java
  Log:
  http://jira.jboss.com/jira/browse/JBMESSAGING-440
  
  Revision  Changes    Path
  1.19      +26 -4     jboss-jms/src/main/org/jboss/messaging/core/tx/Transaction.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Transaction.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/messaging/core/tx/Transaction.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- Transaction.java	29 Apr 2006 02:45:01 -0000	1.18
  +++ Transaction.java	20 Jul 2006 14:04:02 -0000	1.19
  @@ -148,12 +148,20 @@
         return (TxCallback)keyedCallbackMap.get(key);
      }
         
  -   public void commit() throws Exception
  +   public synchronized void commit() throws Exception
      {
         if (state == STATE_ROLLBACK_ONLY)
         {
            throw new TransactionException("Transaction marked rollback only, cannot commit");
         }
  +      if (state == STATE_COMMITTED)
  +      {
  +         throw new TransactionException("Transaction already committed, cannot commit");
  +      }
  +      if (state == STATE_ROLLEDBACK)
  +      {
  +         throw new TransactionException("Transaction already rolled back, cannot commit");
  +      }
   
         if (trace) { log.trace("executing before commit hooks " + this); }
          
  @@ -195,8 +203,13 @@
         if (trace) { log.trace("commit process complete " + this); }
      }
      
  -   public void prepare() throws Exception
  +   public synchronized void prepare() throws Exception
  +   {
  +      if (state != STATE_ACTIVE)
      {
  +         throw new TransactionException("Transaction not active, cannot prepare");
  +      }
  +      
         if (trace) { log.trace("executing before prepare hooks " + this); }
         
         List cb = new ArrayList(callbacks);
  @@ -229,8 +242,17 @@
         if (trace) { log.trace("prepare process complete " + this); }
      }
      
  -   public void rollback() throws Exception
  +   public synchronized void rollback() throws Exception
  +   {
  +      if (state == STATE_COMMITTED)
  +      {
  +         throw new TransactionException("Transaction already committed, cannot rollback");
  +      }
  +      if (state == STATE_ROLLEDBACK)
      {
  +         throw new TransactionException("Transaction already rolled back, cannot rollback");
  +      }
  +      
         if (trace) { log.trace("executing before rollback hooks " + this); }
         
         boolean onePhase = state != STATE_PREPARED;
  @@ -263,7 +285,7 @@
         if (trace) { log.trace("rollback process complete " + this); }
      }
   
  -   public void setRollbackOnly() throws Exception
  +   public synchronized void setRollbackOnly() throws Exception
      {
         if (trace) { log.trace("setting rollback_only on " + this); }
   
  
  
  



More information about the jboss-cvs-commits mailing list