1 45 package org.openejb.core.transaction; 46 47 import javax.ejb.EnterpriseBean ; 48 49 import org.openejb.ApplicationException; 50 51 52 71 public class TxManditory extends TransactionPolicy { 72 73 public TxManditory(TransactionContainer container){ 74 this(); 75 this.container = container; 76 } 77 78 public TxManditory(){ 79 policyType = Mandatory; 80 } 81 82 public String policyToString() { 83 return "TX_Mandatory: "; 84 } 85 public void beforeInvoke(EnterpriseBean instance, TransactionContext context) throws org.openejb.SystemException, org.openejb.ApplicationException{ 86 87 try { 88 89 context.clientTx = getTxMngr().getTransaction(); 90 91 if ( context.clientTx == null ){ 92 throw new ApplicationException(new javax.transaction.TransactionRequiredException ()); 94 } 95 96 context.currentTx = context.clientTx; 97 98 } catch ( javax.transaction.SystemException se ) { 99 logger.error("Exception during getTransaction()", se); 100 throw new org.openejb.SystemException(se); 101 } 102 } 103 104 public void afterInvoke(EnterpriseBean instance, TransactionContext context) throws org.openejb.ApplicationException, org.openejb.SystemException{ 105 } 107 108 109 124 public void handleApplicationException( Throwable appException, TransactionContext context) throws ApplicationException{ 125 throw new ApplicationException( appException ); 127 } 128 129 164 public void handleSystemException( Throwable sysException, EnterpriseBean instance, TransactionContext context) throws org.openejb.ApplicationException, org.openejb.SystemException{ 165 166 167 logSystemException( sysException ); 168 169 170 markTxRollbackOnly( context.currentTx ); 171 172 173 discardBeanInstance( instance, context.callContext ); 174 175 176 throwTxExceptionToServer( sysException ); 177 } 178 179 180 } 181 182 | Popular Tags |