01: package org.jboss.ejb3.test.service;
02:
03: import javax.annotation.Resource;
04: import javax.jms.Topic;
05: import javax.jms.TopicConnectionFactory;
06:
07: import org.jboss.annotation.ejb.Depends;
08: import org.jboss.annotation.ejb.Management;
09: import org.jboss.annotation.ejb.Service;
10: import org.jboss.logging.Logger;
11:
12: /**
13: * Test EJBTHREE-587
14: *
15: * @version <tt>$Revision: 60233 $</tt>
16: * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
17: */
18: @Service(objectName="jboss.ejb3.bugs:service=TestResourceInjectionService")
19: @Management(TestResourceInjectionServiceIF.class)
20: @Depends("jboss.mq.destination:name=myTestTopic,service=Topic")
21: public class TestResourceInjectionService implements
22: TestResourceInjectionServiceIF {
23:
24: private static Logger log = Logger
25: .getLogger(TestResourceInjectionService.class);
26:
27: public boolean testedSuccessful = false;
28:
29: @Resource(mappedName="topic/myTestTopic")
30: private Topic testTopic;
31:
32: @Resource(mappedName="ConnectionFactory")
33: private TopicConnectionFactory topicConnectionFactory;
34:
35: public boolean getTestedSuccessful() {
36: return testedSuccessful;
37: }
38:
39: public boolean getTestedSuccessfulNow() {
40: boolean success = true;
41: if (testTopic == null) {
42: log.warn("Dependent resource injection 'testTopic' failed");
43: success = false;
44: }
45:
46: if (topicConnectionFactory == null) {
47: log
48: .warn("Dependent resource injection 'topicConnectionFactory' failed");
49: success = false;
50: }
51: return success;
52: }
53:
54: // - Service life cycle --------------------------------------------------------
55:
56: public void create() throws Exception {
57: log.info("TestResourceInjectionService.create()");
58: // EJBTHREE-655: resource injection isn't done yet
59: }
60:
61: public void start() throws Exception {
62: log.info("TestResourceInjectionService.start()");
63: testedSuccessful = true;
64: if (testTopic == null) {
65: log.warn("Dependent resource injection 'testTopic' failed");
66: testedSuccessful = false;
67: }
68:
69: if (topicConnectionFactory == null) {
70: log
71: .warn("Dependent resource injection 'topicConnectionFactory' failed");
72: testedSuccessful = false;
73: }
74: }
75:
76: public void stop() {
77: log.info("TestResourceInjectionService.stop()");
78: }
79:
80: public void destroy() {
81: log.info("TestResourceInjectionService.destroy()");
82: }
83:
84: }
|