1
10package rba;
11
12import javax.ejb.CreateException;
13import javax.ejb.SessionBean;
14import javax.ejb.SessionContext;
15import javax.naming.InitialContext;
16import javax.naming.NamingException;
17
18public class HelloBean implements SessionBean {
19
20 private SessionContext ctx;
21 private int tradeLimit;
22
23 private void log(String s) {
24 System.out.println(s);
25 }
26
27 public void ejbActivate() {
28 log("HelloBean.ejbActivate called");
29 }
30
31 public void ejbRemove() {
32 log("HelloBean.ejbRemove called");
33 }
34
35 public void ejbPassivate() {
36 log("HelloBean.ejbPassivate called");
37 }
38
39 public void setSessionContext(SessionContext ctx) {
40 log("HelloBean.setSessionContext called");
41 this.ctx = ctx;
42
43 }
44
45 public void ejbCreate () throws CreateException {
46 log("HelloBean.ejbCreate called");
47 }
48
49 public String hello(String sub) {
50 log("HelloBean.hello(" + sub + ")...");
51 log("Prinicpal = " + ctx.getCallerPrincipal());
52
53 return "Hello, " + sub + " !!";
54 }
55}
56
57
58
59
60
61
62
63
64