1 25 package org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.lifecallback; 26 27 import javax.annotation.PostConstruct; 28 import javax.annotation.PreDestroy; 29 import javax.ejb.ActivationConfigProperty ; 30 import javax.ejb.MessageDriven ; 31 import javax.interceptor.Interceptors; 32 import javax.jms.Message ; 33 import javax.jms.MessageListener ; 34 35 import org.objectweb.easybeans.log.JLog; 36 import org.objectweb.easybeans.log.JLogFactory; 37 import org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType; 38 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertCallbackEvent; 39 import org.objectweb.easybeans.tests.common.interceptors.lifecycle.predestroy.PreDestroyLogger00; 40 import org.objectweb.easybeans.tests.common.jms.JMSManager; 41 42 48 @MessageDriven (messageListenerInterface = MessageListener .class, activationConfig = { 49 @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 50 @ActivationConfigProperty (propertyName = "destination", propertyValue = JMSManager.DEFAULT_QUEUE), 51 @ActivationConfigProperty (propertyName = "messageSelector", propertyValue = 52 "TYPE = 'org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.lifecallback.MDBLifecycle00'")}) 53 @Interceptors({PostConstructMDB.class, PreDestroyLogger00.class}) 54 public class MDBLifecycle00 extends BaseInsertCallbackEvent { 55 56 59 private boolean externalInvoked; 60 61 64 private boolean internalInvoked; 65 66 69 private static JLog logger = JLogFactory.getLog(MDBLifecycle00.class); 70 71 74 public static final String MESSAGE_TYPE = "org.objectweb.easybeans.tests." 75 + "common.ejbs.mdb.containermanaged.lifecallback.MDBLifecycle00"; 76 77 80 @SuppressWarnings ("unused") 81 @PostConstruct 82 private void postConstruct00() { 83 internalInvoked = true; 84 } 85 86 90 public void setStatusPostConstruct(final boolean b) { 91 externalInvoked = b; 92 } 93 94 97 @SuppressWarnings ("unused") 98 @PreDestroy 99 private void preDestroy00() { 100 super.log(MDBLifecycle00.class, CallbackType.PRE_DESTROY, MDBLifecycle00.class); 101 logger.debug("{0} was invoked.", CallbackType.PRE_DESTROY.toString()); 102 } 103 104 108 public void onMessage(final Message message) { 109 if (externalInvoked) { 110 super.log(MDBLifecycle00.class, CallbackType.POST_CONSTRUCT, PostConstructMDB.class); 111 logger.debug("Internal PostConstruct was invoked."); 112 } 113 if (internalInvoked) { 114 super.log(MDBLifecycle00.class, CallbackType.POST_CONSTRUCT, MDBLifecycle00.class); 115 logger.debug("Internal PostConstruct was invoked."); 116 } 117 } 118 119 } 120 | Popular Tags |