KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > mcontext > TestMC1SLL


1 // TestMC1SLL.java
2
// Stateless Session bean
3

4 package org.objectweb.jonas.jtests.beans.mcontext;
5
6 import javax.ejb.CreateException JavaDoc;
7 import javax.ejb.SessionBean JavaDoc;
8 import javax.ejb.SessionContext JavaDoc;
9 import javax.xml.rpc.handler.MessageContext JavaDoc;
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  */

19 public class TestMC1SLL implements SessionBean JavaDoc {
20
21     static private Logger logger = null;
22     SessionContext JavaDoc ejbContext;
23
24     // ------------------------------------------------------------------
25
// SessionBean implementation
26
// ------------------------------------------------------------------
27

28
29     public void setSessionContext(SessionContext JavaDoc ctx) {
30         if (logger == null) {
31             logger = Log.getLogger("org.objectweb.jonas_tests");
32         }
33         logger.log(BasicLevel.DEBUG, "");
34         ejbContext = ctx;
35     }
36         
37
38     public void ejbRemove() {
39         logger.log(BasicLevel.DEBUG, "");
40     }
41         
42
43     public void ejbCreate() throws CreateException JavaDoc {
44         logger.log(BasicLevel.DEBUG, "");
45     }
46
47     public void ejbPassivate() {
48         logger.log(BasicLevel.DEBUG, "");
49     }
50
51     public void ejbActivate() {
52         logger.log(BasicLevel.DEBUG, "");
53     }
54     
55     // ------------------------------------------------------------------
56
// TestMC1 implementation
57
// ------------------------------------------------------------------
58

59     public boolean serviceEndpointMethodHasMessageContext() {
60         logger.log(BasicLevel.DEBUG, "");
61         return hasMessageContext();
62     }
63
64     public boolean localMethodHasMessageContext() {
65         logger.log(BasicLevel.DEBUG, "");
66         return hasMessageContext();
67     }
68
69     private boolean hasMessageContext() {
70         try {
71             MessageContext JavaDoc mc = ejbContext.getMessageContext();
72             if (mc != null) {
73                 return true;
74             } else {
75                 return false;
76             }
77         } catch(IllegalStateException JavaDoc ise) {
78             return false;
79         }
80     }
81
82 }
83
84
Popular Tags