1 package org.hibernate.test.tm; 3 4 import java.util.Properties ; 5 6 import javax.transaction.HeuristicMixedException ; 7 import javax.transaction.HeuristicRollbackException ; 8 import javax.transaction.InvalidTransactionException ; 9 import javax.transaction.NotSupportedException ; 10 import javax.transaction.RollbackException ; 11 import javax.transaction.SystemException ; 12 import javax.transaction.Transaction ; 13 import javax.transaction.TransactionManager ; 14 15 import org.hibernate.connection.ConnectionProvider; 16 import org.hibernate.connection.ConnectionProviderFactory; 17 18 21 public class DummyTransactionManager implements TransactionManager { 22 23 public static DummyTransactionManager INSTANCE; 24 25 private DummyTransaction current; 26 ConnectionProvider connections; 27 28 public DummyTransactionManager(Properties props) { 29 connections = ConnectionProviderFactory.newConnectionProvider(); 30 } 31 32 public void begin() throws NotSupportedException , SystemException { 33 current = new DummyTransaction(this); 34 current.begin(); 35 } 36 37 public void commit() throws RollbackException , HeuristicMixedException , 38 HeuristicRollbackException , SecurityException , 39 IllegalStateException , SystemException { 40 current.commit(); 41 } 42 43 44 public int getStatus() throws SystemException { 45 return current.getStatus(); 46 } 47 48 public Transaction getTransaction() throws SystemException { 49 return current; 50 } 51 52 public void resume(Transaction tx) throws InvalidTransactionException , 53 IllegalStateException , SystemException { 54 current = (DummyTransaction) tx; 55 } 56 57 public void rollback() throws IllegalStateException , SecurityException , 58 SystemException { 59 current.rollback(); 60 61 } 62 63 public void setRollbackOnly() throws IllegalStateException , SystemException { 64 current.setRollbackOnly(); 65 } 66 67 public void setTransactionTimeout(int t) throws SystemException { 68 } 69 70 public Transaction suspend() throws SystemException { 71 Transaction result = current; 72 current = null; 73 return result; 74 } 75 76 public DummyTransaction getCurrent() { 77 return current; 78 } 79 80 void endCurrent(DummyTransaction tx) { 81 if (current==tx) current=null; 82 } 83 84 } 85 | Popular Tags |