1 package ejava.examples.jndidemo.ejb;
2
3 import javax.annotation.Resource;
4 import javax.ejb.SessionContext;
5 import javax.naming.Context;
6 import javax.naming.InitialContext;
7 import javax.naming.NamingException;
8 import javax.persistence.EntityManager;
9 import javax.sql.DataSource;
10
11 import ejava.util.jndi.JNDIUtil;
12
13
14
15
16
17
18
19
20
21
22
23 public class AidSchedulerEJB extends SchedulerBase
24 implements AidSchedulerLocal, AidSchedulerRemote {
25
26
27 private EntityManager em;
28
29 private DataSource ds;
30
31 private String message;
32
33 private HospitalLocal hospital;
34
35 @Resource
36 public void setSessionContext(SessionContext ctx) { this.ctx = ctx; }
37
38 public void init() {
39 log.info("******************* AidScheduler Created ******************");
40 log.debug("ctx=" + ctx);
41 log.debug("ejb/hospital=" + ctx.lookup("ejb/hospital"));
42 log.debug("message=" + message);
43 log.debug("em=" + em);
44 log.debug("ds=" + ds);
45 log.debug("hospital=" + hospital);
46
47 try {
48 Context enc = (Context) new InitialContext().lookup("java:comp");
49 log.debug(new JNDIUtil().dump(enc, "env"));
50 } catch (NamingException ex) { log.fatal("" + ex); }
51 }
52
53 public String getName() { return "AidScheduler"; }
54 }