KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > wsclient > WsClient1SLR


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

4 package org.objectweb.jonas.jtests.beans.wsclient;
5
6
7
8 import java.rmi.RemoteException JavaDoc;
9 import javax.ejb.CreateException JavaDoc;
10 import javax.ejb.SessionBean JavaDoc;
11 import javax.ejb.SessionContext JavaDoc;
12 import javax.naming.InitialContext JavaDoc;
13 import javax.naming.NamingException JavaDoc;
14 import javax.xml.namespace.QName JavaDoc;
15 import javax.xml.rpc.Call JavaDoc;
16 import javax.xml.rpc.Service JavaDoc;
17 import javax.xml.rpc.ServiceException JavaDoc;
18 import org.objectweb.jonas.common.Log;
19 import org.objectweb.util.monolog.api.BasicLevel;
20 import org.objectweb.util.monolog.api.Logger;
21
22
23 /**
24  *
25  */

26 public class WsClient1SLR implements SessionBean JavaDoc {
27
28     static private Logger logger = null;
29     SessionContext JavaDoc ejbContext;
30
31     Service JavaDoc service;
32
33     // ------------------------------------------------------------------
34
// SessionBean implementation
35
// ------------------------------------------------------------------
36

37
38     public void setSessionContext(SessionContext JavaDoc ctx) {
39         if (logger == null) {
40             logger = Log.getLogger("org.objectweb.jonas_tests");
41         }
42         logger.log(BasicLevel.DEBUG, "");
43         ejbContext = ctx;
44     }
45         
46
47     public void ejbRemove() {
48         logger.log(BasicLevel.DEBUG, "");
49     }
50         
51
52     public void ejbCreate() throws CreateException JavaDoc {
53         logger.log(BasicLevel.DEBUG, "");
54     }
55
56     public void ejbPassivate() {
57         logger.log(BasicLevel.DEBUG, "");
58     }
59
60     public void ejbActivate() {
61         logger.log(BasicLevel.DEBUG, "");
62     }
63     
64     // ------------------------------------------------------------------
65
// WsClient1 implementation
66
// ------------------------------------------------------------------
67

68     public boolean lookupServiceJNDI() {
69         logger.log(BasicLevel.DEBUG, "lookupServiceJNDI");
70         service = null;
71         try {
72             InitialContext JavaDoc ic = new InitialContext JavaDoc();
73             service = (Service JavaDoc) ic.lookup("ws/XMethodsService");
74         } catch (NamingException JavaDoc ne) {
75             logger.log(BasicLevel.ERROR, "looking ws/XMethodsService : " + ne.getMessage());
76             return false;
77         }
78         return (service != null);
79     }
80
81     public boolean lookupServiceName() {
82         logger.log(BasicLevel.DEBUG, "lookupServiceName");
83         service = null;
84         try {
85             InitialContext JavaDoc ic = new InitialContext JavaDoc();
86             service = (Service JavaDoc) ic.lookup("java:comp/env/service/XMethods");
87         } catch (NamingException JavaDoc ne) {
88             logger.log(BasicLevel.ERROR, "looking java:comp/env/service/XMethods : " + ne.getMessage());
89             return false;
90         }
91         return (service != null);
92     }
93
94     public void getAllServiceNames() throws ServiceException JavaDoc, RemoteException JavaDoc {
95         logger.log(BasicLevel.DEBUG, "getAllServiceNames");
96
97         lookupServiceName();
98         Call JavaDoc call = service.createCall(new QName JavaDoc("XMethodsQuerySoap"),
99                                    new QName JavaDoc("getAllServiceNames"));
100         call.invoke(new Object JavaDoc[] {});
101
102         logger.log(BasicLevel.DEBUG, "Call is OK");
103     }
104 }
105
106
Popular Tags