1 25 package org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction; 26 27 import javax.annotation.Resource; 28 import javax.ejb.ActivationConfigProperty ; 29 import javax.ejb.EJB ; 30 import javax.ejb.EJBException ; 31 import javax.ejb.MessageDriven ; 32 import javax.ejb.TransactionManagement ; 33 import javax.ejb.TransactionManagementType ; 34 import javax.jms.Message ; 35 import javax.jms.MessageListener ; 36 import javax.transaction.UserTransaction ; 37 38 import org.objectweb.easybeans.log.JLog; 39 import org.objectweb.easybeans.log.JLogFactory; 40 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType; 41 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertCallbackEvent; 42 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.ItfCMTInheritance; 43 import org.objectweb.easybeans.tests.common.jms.JMSManager; 44 45 51 @MessageDriven (activationConfig = { 52 @ActivationConfigProperty (propertyName = "destination", propertyValue = JMSManager.DEFAULT_QUEUE), 53 @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 54 @ActivationConfigProperty (propertyName = "messageSelector", propertyValue = 55 "TYPE = 'org.objectweb.easybeans.tests.common.ejbs.mdb.beanmanaged.transaction.MDBBMTransaction'")}) 56 @TransactionManagement (value = TransactionManagementType.BEAN) 57 public class MDBBMTransaction extends BaseInsertCallbackEvent implements MessageListener { 58 59 62 public static final String MESSAGE_TYPE = "org.objectweb.easybeans.tests.common.ejbs." 63 + "mdb.beanmanaged.transaction.MDBBMTransaction"; 64 65 68 private static JLog logger = JLogFactory.getLog(MDBBMTransaction.class); 69 70 73 @EJB (beanName = "SLSBCMTInheritance") 74 private ItfCMTInheritance bean; 75 76 79 @Resource 80 private UserTransaction utx; 81 82 86 public void onMessage(final Message message) { 87 try { 88 logger.debug("Invoking dummyMethod1."); 90 utx.begin(); 91 bean.dummyMethod1(); 92 utx.commit(); 93 logger.debug("Invoking dummyMethod1 should throw an EJBException."); 94 } catch (EJBException e) { 95 logger.debug("MDB is OK."); 96 super.log(MDBBMTransaction.class, CallbackType.ON_MESSAGE, MDBBMTransaction.class); 97 } catch (Exception e) { 98 logger.error("Error. Exception = {0}", e.getCause()); 99 } 100 } 101 102 } 103 | Popular Tags |