Coverage Report - org.mule.util.xa.AbstractTransactionContext
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractTransactionContext
34%
12/35
0%
0/17
5.6
 
 1  
 /*
 2  
  * $Id: AbstractTransactionContext.java 11680 2008-05-02 23:50:27Z aguenther $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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 javax.transaction.Status;
 14  
 
 15  
 import org.safehaus.uuid.UUIDGenerator;
 16  
 
 17  
 public abstract class AbstractTransactionContext
 18  
 {
 19  
 
 20  2
     private static UUIDGenerator gen = UUIDGenerator.getInstance();
 21  
 
 22  20
     protected String id = gen.generateTimeBasedUUID().toString();
 23  
     protected long timeout;
 24  
     protected int status;
 25  
     protected boolean readOnly;
 26  
     protected boolean suspended;
 27  
     protected boolean finished;
 28  
 
 29  
     public AbstractTransactionContext()
 30  20
     {
 31  20
         status = Status.STATUS_NO_TRANSACTION;
 32  20
         suspended = false;
 33  20
         finished = false;
 34  20
         readOnly = true;
 35  20
     }
 36  
 
 37  
     public String toString()
 38  
     {
 39  0
         StringBuffer sb = new StringBuffer();
 40  0
         sb.append(id).append("[");
 41  0
         sb.append(getStatusString());
 42  0
         if (suspended)
 43  
         {
 44  0
             sb.append(", suspended");
 45  
         }
 46  0
         if (readOnly)
 47  
         {
 48  0
             sb.append(", readonly");
 49  
         }
 50  0
         if (finished)
 51  
         {
 52  0
             sb.append(", finished");
 53  
         }
 54  0
         sb.append("]");
 55  0
         return sb.toString();
 56  
     }
 57  
 
 58  
     private String getStatusString()
 59  
     {
 60  0
         switch (status)
 61  
         {
 62  
             case Status.STATUS_ACTIVE :
 63  0
                 return "active";
 64  
             case Status.STATUS_MARKED_ROLLBACK :
 65  0
                 return "marked rollback";
 66  
             case Status.STATUS_PREPARED :
 67  0
                 return "prepared";
 68  
             case Status.STATUS_COMMITTED :
 69  0
                 return "committed";
 70  
             case Status.STATUS_ROLLEDBACK :
 71  0
                 return "rolled back";
 72  
             case Status.STATUS_UNKNOWN :
 73  0
                 return "unknown";
 74  
             case Status.STATUS_NO_TRANSACTION :
 75  0
                 return "no transaction";
 76  
             case Status.STATUS_PREPARING :
 77  0
                 return "preparing";
 78  
             case Status.STATUS_COMMITTING :
 79  0
                 return "committing";
 80  
             case Status.STATUS_ROLLING_BACK :
 81  0
                 return "rolling back";
 82  
             default :
 83  0
                 return "undefined status";
 84  
         }
 85  
     }
 86  
 
 87  
     public synchronized void finalCleanUp() throws ResourceManagerException
 88  
     {
 89  
         // nothing to do (yet?)
 90  20
     }
 91  
 
 92  
     public synchronized void notifyFinish()
 93  
     {
 94  20
         finished = true;
 95  20
         notifyAll();
 96  20
     }
 97  
 
 98  
 }