01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: MDBCMTRequired.java 692 2006-06-20 09:17:57Z studzine $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.transaction;
25:
26: import javax.ejb.ActivationConfigProperty;
27: import javax.ejb.EJB;
28: import javax.ejb.MessageDriven;
29: import javax.ejb.TransactionAttribute;
30: import javax.ejb.TransactionAttributeType;
31: import javax.jms.Message;
32: import javax.jms.MessageListener;
33:
34: import org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType;
35: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertCallbackEvent;
36: import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.inheritance.ItfCMTInheritance;
37: import org.ow2.easybeans.tests.common.jms.JMSManager;
38: import org.ow2.util.log.Log;
39: import org.ow2.util.log.LogFactory;
40:
41: /**
42: * This message-driven bean is used to test the container-managed transaction
43: * demarcation with transaction attribute NOT_SUPPORTED.
44: * @author Eduardo Studzinski Estima de Castro
45: * @author Gisele Pinheiro Souza
46: */
47: @MessageDriven(activationConfig={@ActivationConfigProperty(propertyName="destination",propertyValue=JMSManager.DEFAULT_QUEUE),@ActivationConfigProperty(propertyName="destinationType",propertyValue="javax.jms.Queue"),@ActivationConfigProperty(propertyName="messageSelector",propertyValue="TYPE = 'org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.transaction.MDBCMTNotSupported'")})
48: @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
49: public class MDBCMTNotSupported extends BaseInsertCallbackEvent
50: implements MessageListener {
51:
52: /**
53: * Message type.
54: */
55: public static final String MESSAGE_TYPE = "org.ow2.easybeans.tests.common.ejbs."
56: + "mdb.containermanaged.transaction.MDBCMTNotSupported";
57:
58: /**
59: * Logger.
60: */
61: private static Log logger = LogFactory
62: .getLog(MDBCMTNotSupported.class);
63:
64: /**
65: * Bean.
66: */
67: @EJB(beanName="SLSBCMTInheritance")
68: private ItfCMTInheritance bean;
69:
70: /**
71: * Manages a message.
72: * @param message msg
73: */
74: public void onMessage(final Message message) {
75: try {
76: // This method is NOT_SUPPORTED and the dummyMethod1 is NEVER, so everything must work.
77: logger.debug("Invoking dummyMethod1.");
78: bean.dummyMethod1();
79: super .log(MDBCMTNotSupported.class,
80: CallbackType.ON_MESSAGE, MDBCMTNotSupported.class);
81: logger.debug("Invoking dummyMethod1 finished.");
82: } catch (Exception e) {
83: logger.error(
84: "Error invoking dummyMethod1. Exception = {0}", e
85: .getCause());
86: }
87: }
88:
89: }
|