1 22 package org.jboss.ejb3.tx; 23 24 import java.io.IOException ; 25 import java.io.ObjectInput ; 26 import java.io.ObjectOutput ; 27 import javax.transaction.HeuristicMixedException ; 28 import javax.transaction.HeuristicRollbackException ; 29 import javax.transaction.NotSupportedException ; 30 import javax.transaction.RollbackException ; 31 import javax.transaction.SystemException ; 32 import javax.transaction.Transaction ; 33 import javax.transaction.TransactionManager ; 34 import javax.transaction.UserTransaction ; 35 import org.jboss.logging.Logger; 36 37 43 public final class UserTransactionImpl implements UserTransaction , java.io.Externalizable 44 { 45 protected static Logger log = Logger.getLogger(UserTransactionImpl.class); 46 47 51 private TransactionManager tm; 52 53 public UserTransactionImpl() 54 { 55 if (log.isDebugEnabled()) 56 log.debug("new UserTx: " + this); 57 this.tm = TxUtil.getTransactionManager(); 58 } 59 60 public void begin() 61 throws NotSupportedException , SystemException 62 { 63 tm.begin(); 65 66 Transaction tx = tm.getTransaction(); 67 if (log.isDebugEnabled()) 68 log.debug("UserTx begin: " + tx); 69 70 } 71 72 public void commit() 73 throws RollbackException , HeuristicMixedException , HeuristicRollbackException , 74 SecurityException , IllegalStateException , SystemException 75 { 76 Transaction tx = tm.getTransaction(); 77 if (log.isDebugEnabled()) 78 log.debug("UserTx commit: " + tx); 79 80 tm.commit(); 81 } 82 83 public void rollback() 84 throws IllegalStateException , SecurityException , SystemException 85 { 86 Transaction tx = tm.getTransaction(); 87 if (log.isDebugEnabled()) 88 log.debug("UserTx rollback: " + tx); 89 tm.rollback(); 90 } 91 92 public void setRollbackOnly() 93 throws IllegalStateException , SystemException 94 { 95 Transaction tx = tm.getTransaction(); 96 if (log.isDebugEnabled()) 97 log.debug("UserTx setRollbackOnly: " + tx); 98 99 tm.setRollbackOnly(); 100 } 101 102 public int getStatus() 103 throws SystemException 104 { 105 return tm.getStatus(); 106 } 107 108 112 public void setTransactionTimeout(int seconds) 113 throws SystemException 114 { 115 tm.setTransactionTimeout(seconds); 116 } 117 118 public void writeExternal(ObjectOutput out) throws IOException 119 { 120 } 122 123 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 124 { 125 this.tm = TxUtil.getTransactionManager(); 126 } 127 128 } 129 | Popular Tags |