01: // TestMC2SLR.java
02: // Stateless Session bean
03:
04: package org.objectweb.jonas.jtests.beans.mcontext;
05:
06: import javax.ejb.CreateException;
07: import javax.ejb.SessionBean;
08: import javax.ejb.SessionContext;
09: import javax.xml.rpc.handler.MessageContext;
10:
11: import org.objectweb.jonas.common.Log;
12: import org.objectweb.util.monolog.api.BasicLevel;
13: import org.objectweb.util.monolog.api.Logger;
14:
15: /**
16: *
17: */
18: public class TestMC2SLR implements SessionBean {
19:
20: static private Logger logger = null;
21: SessionContext ejbContext;
22:
23: // ------------------------------------------------------------------
24: // SessionBean implementation
25: // ------------------------------------------------------------------
26:
27: public void setSessionContext(SessionContext ctx) {
28: if (logger == null) {
29: logger = Log.getLogger("org.objectweb.jonas_tests");
30: }
31: logger.log(BasicLevel.DEBUG, "");
32: ejbContext = ctx;
33: }
34:
35: public void ejbRemove() {
36: logger.log(BasicLevel.DEBUG, "");
37: }
38:
39: public void ejbCreate() throws CreateException {
40: logger.log(BasicLevel.DEBUG, "");
41: }
42:
43: public void ejbPassivate() {
44: logger.log(BasicLevel.DEBUG, "");
45: }
46:
47: public void ejbActivate() {
48: logger.log(BasicLevel.DEBUG, "");
49: }
50:
51: // ------------------------------------------------------------------
52: // TestMC2 implementation
53: // ------------------------------------------------------------------
54:
55: public boolean serviceEndpointMethodHasMessageContext() {
56: logger.log(BasicLevel.DEBUG, "");
57: return hasMessageContext();
58: }
59:
60: public boolean remoteMethodHasMessageContext() {
61: logger.log(BasicLevel.DEBUG, "");
62: return hasMessageContext();
63: }
64:
65: private boolean hasMessageContext() {
66: try {
67: MessageContext mc = ejbContext.getMessageContext();
68: if (mc != null) {
69: return true;
70: } else {
71: return false;
72: }
73: } catch (IllegalStateException ise) {
74: return false;
75: }
76: }
77:
78: }
|