1 25 package org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref; 26 27 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE; 28 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_FIELD; 29 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_METHOD; 30 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCES_DECLARATION; 31 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCE_DECLARATION; 32 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_FIELD; 33 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_METHOD; 34 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_FIELD; 35 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_METHOD; 36 import static org.objectweb.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_RESOURCE_DECLARATION; 37 import static org.objectweb.easybeans.tests.common.helper.ContextHelper.checkBeanRef; 38 39 import javax.annotation.Resource; 40 import javax.ejb.ActivationConfigProperty ; 41 import javax.ejb.EJB ; 42 import javax.ejb.EJBs ; 43 import javax.ejb.MessageDriven ; 44 import javax.ejb.MessageDrivenContext ; 45 import javax.jms.Message ; 46 import javax.jms.MessageListener ; 47 48 import org.objectweb.easybeans.log.JLog; 49 import org.objectweb.easybeans.log.JLogFactory; 50 import org.objectweb.easybeans.tests.common.ejbs.base.ItfOneMethod01; 51 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertOperation; 52 import org.objectweb.easybeans.tests.common.jms.JMSManager; 53 54 65 @MessageDriven (messageListenerInterface = MessageListener .class, activationConfig = { 66 @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 67 @ActivationConfigProperty (propertyName = "destination", propertyValue = JMSManager.DEFAULT_QUEUE), 68 @ActivationConfigProperty (propertyName = "messageSelector", propertyValue = "TYPE = 'org.objectweb.easybeans.tests." 69 + "common.ejbs.mdb.containermanaged.ejbref.MDBEjbRef'")}) 70 71 @EJBs ({ 72 @EJB (name = "ejb/beanDeclaration00", beanInterface=ItfOneMethod01.class, beanName="EJBInjectionBean"), 73 @EJB (name = "ejb/beanDeclaration01", beanInterface=ItfOneMethod01.class, beanName="EJBInjectionBean") 74 }) 75 @EJB (name = "ejb/beanDeclaration02", beanInterface=ItfOneMethod01.class, beanName="EJBInjectionBean") 76 public class MDBEjbRef extends BaseInsertOperation{ 77 78 81 public static final String MESSAGE_TYPE = "org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref." 82 + "MDBEjbRef"; 83 84 87 private static JLog logger = JLogFactory.getLog(MDBEjbRef.class); 88 89 92 @SuppressWarnings ("unused") 93 @EJB (name="ejb/beanFieldInjection", beanName = "EJBInjectionBean") 94 private ItfOneMethod01 beanFieldInjection; 95 96 99 @SuppressWarnings ("unused") 100 @EJB (name="ejb/beanOverrideField", beanName = "EJBInjectionBean") 101 private ItfOneMethod01 beanOverrideFieldInjection; 102 103 106 private ItfOneMethod01 beanMethodInjection; 107 108 111 private ItfOneMethod01 beanXMLMethodInjection; 112 113 116 private ItfOneMethod01 beanXMLFieldInjection; 117 118 121 private ItfOneMethod01 beanOverrideMethodInjection; 122 123 127 @EJB (name = "ejb/beanMethodInjection", beanName = "EJBInjectionBean") 128 public void setMethodInjection(final ItfOneMethod01 b){ 129 beanMethodInjection = b; 130 } 131 132 136 public void setXMLMethodInjection(final ItfOneMethod01 b){ 137 beanXMLMethodInjection = b; 138 } 139 140 144 @EJB (name = "ejb/beanOverrideMethod", beanName = "EJBInjectionBean") 145 public void setOverrideMethodInjection(final ItfOneMethod01 b){ 146 beanOverrideMethodInjection = b; 147 } 148 149 152 @Resource 153 private MessageDrivenContext ctx; 154 155 159 public void onMessage(final Message message) { 160 161 try { 163 checkBeanRef(ctx, "ejb/beanDeclaration00", ItfOneMethod01.class); 164 checkBeanRef(ctx, "ejb/beanDeclaration01", ItfOneMethod01.class); 165 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, ANNOTATION_RESOURCES_DECLARATION); 166 logger.debug("{0} is working properly.", ANNOTATION_RESOURCES_DECLARATION.toString()); 167 } catch (Exception e) { 168 logger.debug("Error checking {0}: {1}", ANNOTATION_RESOURCES_DECLARATION.toString(), e.getMessage()); 169 } 170 try { 171 checkBeanRef(ctx, "ejb/beanDeclaration02", ItfOneMethod01.class); 172 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, ANNOTATION_RESOURCE_DECLARATION); 173 logger.debug("{0} is working properly.", ANNOTATION_RESOURCE_DECLARATION.toString()); 174 } catch (Exception e) { 175 logger.debug("Error checking {0}: {1}", ANNOTATION_RESOURCE_DECLARATION.toString(), e.getMessage()); 176 } 177 178 try { 180 checkBeanRef(ctx, "ejb/beanXMLDeclaration", ItfOneMethod01.class); 181 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, XML_RESOURCE_DECLARATION); 182 logger.debug("{0} is working properly.", XML_RESOURCE_DECLARATION.toString()); 183 } catch (Exception e) { 184 logger.debug("Error checking {0}: {1}", XML_RESOURCE_DECLARATION.toString(), e.getMessage()); 185 } 186 187 try { 189 assert beanFieldInjection.getBool(); 190 checkBeanRef(ctx, "ejb/beanFieldInjection", ItfOneMethod01.class); 191 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, ANNOTATION_INJECTION_FIELD); 192 logger.debug("{0} is working properly.", ANNOTATION_INJECTION_FIELD.toString()); 193 } catch (Exception e) { 194 logger.debug("Error checking {0}: {1}", ANNOTATION_INJECTION_FIELD.toString(), e.getMessage()); 195 } 196 197 try { 199 assert beanMethodInjection.getBool(); 200 checkBeanRef(ctx, "ejb/beanMethodInjection", ItfOneMethod01.class); 201 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, ANNOTATION_INJECTION_METHOD); 202 logger.debug("{0} is working properly.", ANNOTATION_INJECTION_METHOD.toString()); 203 } catch (Exception e) { 204 logger.debug("Error checking {0}: {1}", ANNOTATION_INJECTION_METHOD.toString(), e.getMessage()); 205 } 206 207 try { 209 assert beanXMLFieldInjection.getBool(); 210 checkBeanRef(ctx, "ejb/beanXMLFieldInjection", ItfOneMethod01.class); 211 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, XML_INJECTION_FIELD); 212 logger.debug("{0} is working properly.", XML_INJECTION_FIELD.toString()); 213 } catch (Exception e) { 214 logger.debug("Error checking {0}: {1}", XML_INJECTION_FIELD.toString(), e.getMessage()); 215 } 216 217 try { 219 assert beanXMLMethodInjection.getBool(); 220 checkBeanRef(ctx, "ejb/beanXMLMethodInjection", ItfOneMethod01.class); 221 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, XML_INJECTION_METHOD); 222 logger.debug("{0} is working properly.", XML_INJECTION_METHOD.toString()); 223 } catch (Exception e) { 224 logger.debug("Error checking {0}: {1}", XML_INJECTION_METHOD.toString(), e.getMessage()); 225 } 226 227 try { 229 assert beanOverrideFieldInjection.getBool(); 231 checkBeanRef(ctx, "ejb/beanOverrideFieldInjection", ItfOneMethod01.class); 232 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, OVERRIDE_INJECTION_FIELD); 233 logger.debug("{0} is working properly.", OVERRIDE_INJECTION_FIELD.toString()); 234 } catch (Exception e) { 235 logger.debug("Error checking {0}: {1}", OVERRIDE_INJECTION_FIELD.toString(), e.getMessage()); 236 } 237 238 try { 240 assert beanOverrideMethodInjection.getBool(); 242 checkBeanRef(ctx, "ejb/beanOverrideMethodInjection", ItfOneMethod01.class); 243 super.log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class, OVERRIDE_INJECTION_METHOD); 244 logger.debug("{0} is working properly.", OVERRIDE_INJECTION_METHOD.toString()); 245 } catch (Exception e) { 246 logger.debug("Error checking {0}: {1}", OVERRIDE_INJECTION_METHOD.toString(), e.getMessage()); 247 } 248 } 249 } 250 | Popular Tags |