1 22 package org.jboss.ejb3.test.bmt; 23 24 import javax.annotation.Resource; 25 import javax.ejb.Stateful ; 26 import javax.ejb.TransactionManagement ; 27 import javax.ejb.TransactionManagementType ; 28 import javax.transaction.TransactionManager ; 29 import javax.transaction.UserTransaction ; 30 import javax.transaction.Transaction ; 31 import org.jboss.annotation.JndiInject; 32 33 37 public class DeploymentDescriptorStatefulBean implements DeploymentDescriptorStatefulLocal 38 { 39 @Resource UserTransaction ut; 40 @JndiInject(jndiName="java:/TransactionManager") TransactionManager tm; 41 42 public Transaction beginNoEnd() throws Exception 43 { 44 if (tm.getTransaction() != null) throw new TestException("THERE IS AN EXISTING TRANSACTION"); 45 ut.begin(); 46 return tm.getTransaction(); 47 } 48 49 public void endCommit(Transaction old) throws Exception 50 { 51 if (old != tm.getTransaction()) throw new TestException("No matching TX"); 52 ut.commit(); 53 } 54 55 public void endRollback(Transaction old) throws Exception 56 { 57 if (old != tm.getTransaction()) throw new TestException("No matching TX"); 58 ut.rollback(); 59 } 60 61 public void beginCommitEnd() throws Exception 62 { 63 if (tm.getTransaction() != null) throw new TestException("THERE IS AN EXISTING TRANSACTION"); 64 ut.begin(); 65 ut.commit(); 66 } 67 68 public void beginRollbackEnd() throws Exception 69 { 70 if (tm.getTransaction() != null) throw new TestException("THERE IS AN EXISTING TRANSACTION"); 71 ut.begin(); 72 ut.rollback(); 73 } 74 75 } 76 | Popular Tags |