1 10 11 package org.mule.util.xa; 12 13 import org.safehaus.uuid.UUIDGenerator; 14 15 import javax.transaction.Status ; 16 17 21 public class AbstractTransactionContext 22 { 23 24 private static UUIDGenerator gen = UUIDGenerator.getInstance(); 25 26 protected String id = gen.generateTimeBasedUUID().toString(); 27 protected long timeout; 28 protected int status; 29 protected boolean readOnly; 30 protected boolean suspended; 31 protected boolean finished; 32 33 public AbstractTransactionContext() 34 { 35 status = Status.STATUS_NO_TRANSACTION; 36 suspended = false; 37 finished = false; 38 readOnly = true; 39 } 40 41 public String toString() 42 { 43 StringBuffer sb = new StringBuffer (); 44 sb.append(id).append("["); 45 sb.append(getStatusString()); 46 if (suspended) 47 { 48 sb.append(", suspended"); 49 } 50 if (readOnly) 51 { 52 sb.append(", readonly"); 53 } 54 if (finished) 55 { 56 sb.append(", finished"); 57 } 58 sb.append("]"); 59 return sb.toString(); 60 } 61 62 private String getStatusString() 63 { 64 switch (status) 65 { 66 case Status.STATUS_ACTIVE : 67 return "active"; 68 case Status.STATUS_MARKED_ROLLBACK : 69 return "marked rollback"; 70 case Status.STATUS_PREPARED : 71 return "prepared"; 72 case Status.STATUS_COMMITTED : 73 return "committed"; 74 case Status.STATUS_ROLLEDBACK : 75 return "rolled back"; 76 case Status.STATUS_UNKNOWN : 77 return "unknown"; 78 case Status.STATUS_NO_TRANSACTION : 79 return "no transaction"; 80 case Status.STATUS_PREPARING : 81 return "preparing"; 82 case Status.STATUS_COMMITTING : 83 return "committing"; 84 case Status.STATUS_ROLLING_BACK : 85 return "rolling back"; 86 default : 87 return "undefined status"; 88 } 89 } 90 91 public synchronized void finalCleanUp() throws ResourceManagerException 92 { 93 } 95 96 public synchronized void notifyFinish() 97 { 98 finished = true; 99 notifyAll(); 100 } 101 102 } 103 | Popular Tags |