1 25 package org.objectweb.easybeans.tests.common.ejbs.stateful.beanmanaged.transaction; 26 27 import java.sql.SQLException ; 28 29 import javax.ejb.Remote ; 30 import javax.ejb.Stateful ; 31 import javax.ejb.TransactionManagement ; 32 import javax.ejb.TransactionManagementType ; 33 import javax.naming.NamingException ; 34 import javax.transaction.HeuristicMixedException ; 35 import javax.transaction.HeuristicRollbackException ; 36 import javax.transaction.NotSupportedException ; 37 import javax.transaction.RollbackException ; 38 import javax.transaction.SystemException ; 39 import javax.transaction.UserTransaction ; 40 41 import org.objectweb.easybeans.tests.common.db.TableManager; 42 import org.objectweb.easybeans.tests.common.exception.RollbackAppRuntimeException; 43 import org.objectweb.easybeans.tests.common.exception.TransactionRuntimeException; 44 import org.objectweb.easybeans.tests.common.helper.TransactionHelper; 45 46 52 @Stateful 53 @TransactionManagement (TransactionManagementType.BEAN) 54 @Remote 55 public class SFSBBeanManagedException implements ItfBeanManagedException { 56 57 60 private UserTransaction utx = null; 61 62 65 private TableManager tableManager = null; 66 67 72 public void startup(final String dbName) throws NamingException { 73 tableManager = new TableManager(dbName); 74 } 75 92 public void insertTableWithAppException() throws NamingException , SQLException , NotSupportedException , SystemException , 93 IllegalStateException , SecurityException , HeuristicMixedException , HeuristicRollbackException , RollbackException { 94 utx = TransactionHelper.getUserTransaction(); 95 try { 96 utx.begin(); 97 tableManager.insertTable(TABLE); 98 throw new RollbackAppRuntimeException(new Throwable ("Applciation exception with rollback = true")); 99 } finally { 100 utx.commit(); 101 } 102 } 103 104 122 public void insertTableWithRuntimeException() throws NamingException , SQLException , NotSupportedException , SystemException , 123 IllegalStateException , SecurityException , HeuristicMixedException , HeuristicRollbackException , RollbackException { 124 utx = TransactionHelper.getUserTransaction(); 125 try { 126 utx.begin(); 127 tableManager.insertTable(TABLE); 128 throw new TransactionRuntimeException(null); 129 } finally { 130 utx.commit(); 131 } 132 } 133 134 138 public void emptyMethod(){ 139 140 } 141 } 142 | Popular Tags |