KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > service > TestResourceInjectionService


1 package org.jboss.ejb3.test.service;
2
3 import javax.annotation.Resource;
4 import javax.jms.Topic JavaDoc;
5 import javax.jms.TopicConnectionFactory JavaDoc;
6
7 import org.jboss.annotation.ejb.Management;
8 import org.jboss.annotation.ejb.Service;
9 import org.jboss.logging.Logger;
10
11 /**
12  * Test EJBTHREE-587
13  *
14  * @version <tt>$Revision: 57005 $</tt>
15  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
16  */

17 @Service(objectName = "jboss.ejb3.bugs:service=TestResourceInjectionService")
18 @Management(TestResourceInjectionServiceIF.class)
19 public class TestResourceInjectionService implements TestResourceInjectionServiceIF {
20
21     private static Logger log = Logger.getLogger(TestResourceInjectionService.class);
22     
23     public boolean testedSuccessful = false;
24
25     @Resource(mappedName = "topic/testTopic")
26     private Topic JavaDoc testTopic;
27     
28     @Resource(mappedName = "ConnectionFactory")
29     private TopicConnectionFactory JavaDoc topicConnectionFactory;
30     
31     public boolean getTestedSuccessful() {
32         return testedSuccessful;
33     }
34
35     public boolean getTestedSuccessfulNow() {
36        boolean success = true;
37        if(testTopic == null)
38        {
39            log.warn("Dependent resource injection 'testTopic' failed");
40            success = false;
41        }
42        
43        if(topicConnectionFactory == null)
44        {
45            log.warn("Dependent resource injection 'topicConnectionFactory' failed");
46            success = false;
47        }
48        return success;
49     }
50    
51 // - Service life cycle --------------------------------------------------------
52

53     public void create() throws Exception JavaDoc {
54         log.info("TestResourceInjectionService.create()");
55         // EJBTHREE-655: resource injection isn't done yet
56
}
57     
58     public void start() throws Exception JavaDoc {
59         log.info("TestResourceInjectionService.start()");
60         testedSuccessful = true;
61         if(testTopic == null)
62         {
63             log.warn("Dependent resource injection 'testTopic' failed");
64             testedSuccessful = false;
65         }
66         
67         if(topicConnectionFactory == null)
68         {
69             log.warn("Dependent resource injection 'topicConnectionFactory' failed");
70             testedSuccessful = false;
71         }
72     }
73     
74     public void stop() {
75         log.info("TestResourceInjectionService.stop()");
76     }
77     
78     public void destroy() {
79         log.info("TestResourceInjectionService.destroy()");
80     }
81     
82 }
83
Popular Tags