1 16 17 package org.springframework.transaction.jta; 18 19 import javax.transaction.HeuristicMixedException ; 20 import javax.transaction.HeuristicRollbackException ; 21 import javax.transaction.NotSupportedException ; 22 import javax.transaction.RollbackException ; 23 import javax.transaction.SystemException ; 24 import javax.transaction.TransactionManager ; 25 import javax.transaction.UserTransaction ; 26 27 import org.springframework.util.Assert; 28 29 46 public class UserTransactionAdapter implements UserTransaction { 47 48 private final TransactionManager transactionManager; 49 50 51 55 public UserTransactionAdapter(TransactionManager transactionManager) { 56 Assert.notNull(transactionManager, "TransactionManager must not be null"); 57 this.transactionManager = transactionManager; 58 } 59 60 63 public final TransactionManager getTransactionManager() { 64 return this.transactionManager; 65 } 66 67 68 public void begin() throws NotSupportedException , SystemException { 69 this.transactionManager.begin(); 70 } 71 72 public void commit() 73 throws RollbackException , HeuristicMixedException , HeuristicRollbackException , 74 SecurityException , IllegalStateException , SystemException { 75 76 this.transactionManager.commit(); 77 } 78 79 public int getStatus() throws SystemException { 80 return this.transactionManager.getStatus(); 81 } 82 83 public void rollback() throws IllegalStateException , SecurityException , SystemException { 84 this.transactionManager.rollback(); 85 } 86 87 public void setRollbackOnly() throws IllegalStateException , SystemException { 88 this.transactionManager.setRollbackOnly(); 89 } 90 91 public void setTransactionTimeout(int timeout) throws SystemException { 92 this.transactionManager.setTransactionTimeout(timeout); 93 } 94 95 } 96 | Popular Tags |