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