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 public class AidSchedulerEJB extends SchedulerBase
22 implements AidSchedulerLocal, AidSchedulerRemote {
23
24
25 private EntityManager em;
26
27 private DataSource ds;
28
29 private String message;
30
31 private HospitalLocal hospital;
32
33 @Resource
34 public void setSessionContext(SessionContext ctx) { this.ctx = ctx; }
35
36 public void init() {
37 log.info("******************* AidScheduler Created ******************");
38 log.debug("ctx=" + ctx);
39 log.debug("ejb/hospital=" + ctx.lookup("ejb/hospital"));
40 log.debug("message=" + message);
41 log.debug("em=" + em);
42 log.debug("ds=" + ds);
43 log.debug("hospital=" + hospital);
44
45 try {
46 Context enc = (Context) new InitialContext().lookup("java:comp");
47 log.debug(new JNDIUtil().dump(enc, "env"));
48 } catch (NamingException ex) { log.error("" + ex); }
49 }
50
51 public String getName() { return "AidScheduler"; }
52 }