1 package ejava.examples.jndidemo.ejb;
2
3 import javax.annotation.PostConstruct;
4
5 import javax.annotation.Resource;
6
7 import javax.ejb.SessionContext;
8 import javax.ejb.Stateless;
9 import javax.enterprise.inject.Any;
10 import javax.enterprise.inject.Instance;
11 import javax.inject.Inject;
12 import javax.persistence.EntityManager;
13 import javax.sql.DataSource;
14
15 import ejava.examples.jndidemo.Cook;
16 import ejava.examples.jndidemo.JndiDemo;
17 import ejava.examples.jndidemo.CookQualifier;
18 import ejava.examples.jndidemo.Scheduler;
19 import ejava.examples.jndidemo.dao.JPASchedulerDAOImpl;
20 import ejava.examples.jndidemo.dao.SchedulerDAO;
21
22 @Stateless
23 public class TrainSchedulerEJB
24 extends SchedulerBase implements TrainSchedulerRemote {
25
26 public String getName() { return TrainSchedulerEJB.class.getSimpleName(); }
27
28
29
30
31 @Inject @JndiDemo
32 private EntityManager em;
33
34
35
36
37 @Inject @JndiDemo
38 private DataSource ds;
39
40
41
42
43 @Inject
44 protected SchedulerDAO schedulerDAO;
45
46
47
48
49 @Inject
50 protected JPASchedulerDAOImpl jpaSchedulerDAOImpl;
51
52
53
54
55 @Inject @Cook
56 protected Scheduler cook;
57
58
59
60
61
62 @Inject @Any
63 protected Instance<Scheduler> anyCook;
64
65
66
67
68 protected Scheduler cook2;
69
70
71
72
73 @Inject @JndiDemo
74 String message;
75
76 @Resource
77 protected void setSessionContext(SessionContext ctx) {
78 super.ctx = ctx;
79 }
80
81 @PostConstruct
82 public void init() {
83 log.info("******************* TrainScheduler Created ******************");
84 log.debug("ctx=" + ctx);
85 log.debug("em=" + em);
86 log.debug("ds=" + ds);
87 log.debug("message=" + message);
88 log.debug("cook=" + cook);
89 cook2 = anyCook.select(new CookQualifier()).get();
90 log.debug("cook2=" + cook2);
91 log.debug("schedulerDAO=" + schedulerDAO);
92 log.debug("jpaSchedulerDAOImpl=" + jpaSchedulerDAOImpl);
93 }
94 }