1 25 package org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.resourceref; 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.checkResource; 38 39 import javax.annotation.Resource; 40 import javax.annotation.Resources; 41 import javax.ejb.ActivationConfigProperty ; 42 import javax.ejb.MessageDriven ; 43 import javax.ejb.MessageDrivenContext ; 44 import javax.jms.Message ; 45 import javax.jms.MessageListener ; 46 import javax.sql.DataSource ; 47 48 import org.objectweb.easybeans.log.JLog; 49 import org.objectweb.easybeans.log.JLogFactory; 50 import org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.simpleentry.MDBSimpleEntryEnv; 51 import org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertOperation; 52 import org.objectweb.easybeans.tests.common.jms.JMSManager; 53 54 60 @MessageDriven (name = "MDBResourceRef", messageListenerInterface = MessageListener .class, activationConfig = { 61 @ActivationConfigProperty (propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 62 @ActivationConfigProperty (propertyName = "destination", propertyValue = JMSManager.DEFAULT_QUEUE), 63 @ActivationConfigProperty (propertyName = "messageSelector", propertyValue = "TYPE = 'org.objectweb.easybeans.tests." 64 + "common.ejbs.mdb.containermanaged.resourceref.MDBResourceRef'")}) 65 @Resources({@Resource(name = "jdbc/ds00", type = javax.sql.DataSource .class)}) 66 @Resource(name = "jdbc/ds01", type = javax.sql.DataSource .class) 67 public class MDBResourceRef extends BaseInsertOperation { 68 69 72 private static JLog logger = JLogFactory.getLog(MDBResourceRef.class); 73 74 77 public static final String MESSAGE_TYPE = "org.objectweb.easybeans.tests.common.ejbs.mdb.containermanaged.resourceref." 78 + "MDBResourceRef"; 79 80 83 @Resource 84 private MessageDrivenContext ctx; 85 86 89 private DataSource dsMethodInjection; 90 91 94 @Resource(name = "jdbc/dsFieldInjection") 95 private DataSource dsFieldInjection; 96 97 100 private DataSource dsXMLFieldInjection; 101 102 105 private DataSource dsXMLMethodInjection; 106 107 111 @Resource(name = "jdbc/dsOverrideField") 112 private DataSource dsOverrideFieldInjection; 113 114 118 private DataSource dsOverrideMethodInjection; 119 120 124 @SuppressWarnings ("unused") 125 @Resource(name = "jdbc/dsMethodInjection") 126 private void setMethodInjection(final DataSource value) { 127 dsMethodInjection = value; 128 } 129 130 134 @SuppressWarnings ("unused") 135 private void setXMLMethodInjection(final DataSource value) { 136 dsXMLMethodInjection = value; 137 } 138 139 143 @SuppressWarnings ("unused") 144 @Resource(name = "jdbc/dsOverrideMethod") 145 private void setOverrideMethodInjection(final DataSource value) { 146 dsOverrideMethodInjection = value; 147 } 148 149 153 public void onMessage(final Message message) { 154 155 try { 157 checkResource(ctx, "jdbc/dsDeclaration00"); 158 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, ANNOTATION_RESOURCES_DECLARATION); 159 logger.debug("{0} is working properly.", ANNOTATION_RESOURCES_DECLARATION.toString()); 160 } catch (Exception e) { 161 logger.error("Error checking {0}: {1}", ANNOTATION_RESOURCES_DECLARATION.toString(), e.getMessage()); 162 } 163 try { 164 checkResource(ctx, "jdbc/dsDeclaration01"); 165 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, ANNOTATION_RESOURCE_DECLARATION); 166 logger.debug("{0} is working properly.", ANNOTATION_RESOURCE_DECLARATION.toString()); 167 } catch (Exception e) { 168 logger.error("Error checking {0}: {1}", ANNOTATION_RESOURCE_DECLARATION.toString(), e.getMessage()); 169 } 170 171 try { 173 checkResource(ctx, "jdbc/dsXMLDeclaration"); 174 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, XML_RESOURCE_DECLARATION); 175 logger.debug("{0} is working properly.", XML_RESOURCE_DECLARATION.toString()); 176 } catch (Exception e) { 177 logger.error("Error checking {0}: {1}", XML_RESOURCE_DECLARATION.toString(), e.getMessage()); 178 } 179 180 try { 182 183 checkResource(ctx, dsFieldInjection, "jdbc/dsFieldInjection"); 184 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, ANNOTATION_INJECTION_FIELD); 185 logger.debug("{0} is working properly.", ANNOTATION_INJECTION_FIELD.toString()); 186 } catch (Exception e) { 187 logger.error("Error checking {0}: {1}", ANNOTATION_INJECTION_FIELD.toString(), e.getMessage()); 188 } 189 190 try { 192 checkResource(ctx, dsMethodInjection, "jdbc/dsMethodInjection"); 193 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, ANNOTATION_INJECTION_METHOD); 194 logger.debug("{0} is working properly.", ANNOTATION_INJECTION_METHOD.toString()); 195 } catch (Exception e) { 196 logger.error("Error checking {0}: {1}", ANNOTATION_INJECTION_METHOD.toString(), e.getMessage()); 197 } 198 199 try { 201 checkResource(ctx, dsXMLFieldInjection, "jdbc/dsXMLFieldInjection"); 202 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, XML_INJECTION_FIELD); 203 logger.debug("{0} is working properly.", XML_INJECTION_FIELD.toString()); 204 } catch (Exception e) { 205 logger.error("Error checking {0}: {1}", XML_INJECTION_FIELD.toString(), e.getMessage()); 206 } 207 208 try { 210 checkResource(ctx, dsXMLMethodInjection, "jdbc/dsXMLMethodInjection"); 211 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, XML_INJECTION_METHOD); 212 logger.debug("{0} is working properly.", XML_INJECTION_METHOD.toString()); 213 } catch (Exception e) { 214 logger.error("Error checking {0}: {1}", XML_INJECTION_METHOD.toString(), e.getMessage()); 215 } 216 217 try { 219 checkResource(ctx, dsOverrideFieldInjection, "jdbc/dsOverrideFieldInjection"); 222 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, OVERRIDE_INJECTION_FIELD); 223 logger.debug("{0} is working properly.", OVERRIDE_INJECTION_FIELD.toString()); 224 } catch (Exception e) { 225 logger.error("Error checking {0}: {1}", OVERRIDE_INJECTION_FIELD.toString(), e.getMessage()); 226 } 227 228 try { 230 checkResource(ctx, dsOverrideMethodInjection, "jdbc/dsOverrideMethodInjection"); 233 super.log(MDBSimpleEntryEnv.class, ON_MESSAGE, MDBSimpleEntryEnv.class, OVERRIDE_INJECTION_METHOD); 234 logger.debug("{0} is working properly.", OVERRIDE_INJECTION_METHOD.toString()); 235 } catch (Exception e) { 236 logger.error("Error checking {0}: {1}", OVERRIDE_INJECTION_METHOD.toString(), e.getMessage()); 237 } 238 } 239 240 } 241 | Popular Tags |