Coverage Report - org.mule.util.xa.AbstractTransactionContext
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractTransactionContext
0%
0/34
0%
0/17
5.6
 
 1  
 /*
 2  
  * $Id: AbstractTransactionContext.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util.xa;
 12  
 
 13  
 import org.mule.util.UUID;
 14  
 
 15  
 import javax.transaction.Status;
 16  
 
 17  
 public abstract class AbstractTransactionContext
 18  
 {
 19  0
     protected String id = UUID.getUUID();
 20  
     protected long timeout;
 21  
     protected int status;
 22  
     protected boolean readOnly;
 23  
     protected boolean suspended;
 24  
     protected boolean finished;
 25  
 
 26  
     public AbstractTransactionContext()
 27  0
     {
 28  0
         status = Status.STATUS_NO_TRANSACTION;
 29  0
         suspended = false;
 30  0
         finished = false;
 31  0
         readOnly = true;
 32  0
     }
 33  
 
 34  
     public String toString()
 35  
     {
 36  0
         StringBuffer sb = new StringBuffer();
 37  0
         sb.append(id).append("[");
 38  0
         sb.append(getStatusString());
 39  0
         if (suspended)
 40  
         {
 41  0
             sb.append(", suspended");
 42  
         }
 43  0
         if (readOnly)
 44  
         {
 45  0
             sb.append(", readonly");
 46  
         }
 47  0
         if (finished)
 48  
         {
 49  0
             sb.append(", finished");
 50  
         }
 51  0
         sb.append("]");
 52  0
         return sb.toString();
 53  
     }
 54  
 
 55  
     private String getStatusString()
 56  
     {
 57  0
         switch (status)
 58  
         {
 59  
             case Status.STATUS_ACTIVE :
 60  0
                 return "active";
 61  
             case Status.STATUS_MARKED_ROLLBACK :
 62  0
                 return "marked rollback";
 63  
             case Status.STATUS_PREPARED :
 64  0
                 return "prepared";
 65  
             case Status.STATUS_COMMITTED :
 66  0
                 return "committed";
 67  
             case Status.STATUS_ROLLEDBACK :
 68  0
                 return "rolled back";
 69  
             case Status.STATUS_UNKNOWN :
 70  0
                 return "unknown";
 71  
             case Status.STATUS_NO_TRANSACTION :
 72  0
                 return "no transaction";
 73  
             case Status.STATUS_PREPARING :
 74  0
                 return "preparing";
 75  
             case Status.STATUS_COMMITTING :
 76  0
                 return "committing";
 77  
             case Status.STATUS_ROLLING_BACK :
 78  0
                 return "rolling back";
 79  
             default :
 80  0
                 return "undefined status";
 81  
         }
 82  
     }
 83  
 
 84  
     public synchronized void finalCleanUp() throws ResourceManagerException
 85  
     {
 86  
         // nothing to do (yet?)
 87  0
     }
 88  
 
 89  
     public synchronized void notifyFinish()
 90  
     {
 91  0
         finished = true;
 92  0
         notifyAll();
 93  0
     }
 94  
 
 95  
 }