1 25 26 package org.objectweb.easybeans.transaction.interceptors; 27 28 import javax.ejb.EJBException ; 29 import javax.ejb.EJBTransactionRequiredException ; 30 import javax.transaction.SystemException ; 31 import javax.transaction.Transaction ; 32 33 import org.objectweb.easybeans.api.EasyBeansInvocationContext; 34 import org.objectweb.easybeans.log.JLog; 35 import org.objectweb.easybeans.log.JLogFactory; 36 37 41 public class CMTMandatoryTransactionInterceptor extends AbsTransactionInterceptor { 42 43 46 private JLog logger = JLogFactory.getLog(CMTMandatoryTransactionInterceptor.class); 47 48 52 public CMTMandatoryTransactionInterceptor() { 53 super(); 54 } 55 56 65 @Override 66 public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception { 67 logger.debug("Calling Mandatory TX interceptor"); 68 69 Transaction transaction; 71 try { 72 transaction = getTransactionManager().getTransaction(); 73 } catch (SystemException se) { 74 throw new EJBException ("Cannot get the current transaction on transaction manager.", se); 75 } 76 77 logger.debug("Transaction found = {0}", transaction); 78 79 88 if (transaction == null) { 89 logger.warn("Mandatory as transaction attribute and not in transaction"); 90 throw new EJBTransactionRequiredException ("Client should call with a transaction context in MANDATORY mode."); 91 } 92 93 try { 96 return invocationContext.proceed(); 97 } catch (Exception e) { 98 handleContextClientTransaction(invocationContext, e); 101 102 return null; 104 } 105 } 106 107 } 108 | Popular Tags |