001: // WsClient1SLR.java
002: // Stateless Session bean
003:
004: package org.objectweb.jonas.jtests.beans.wsclient;
005:
006: import java.rmi.RemoteException;
007: import javax.ejb.CreateException;
008: import javax.ejb.SessionBean;
009: import javax.ejb.SessionContext;
010: import javax.naming.InitialContext;
011: import javax.naming.NamingException;
012: import javax.xml.namespace.QName;
013: import javax.xml.rpc.Call;
014: import javax.xml.rpc.Service;
015: import javax.xml.rpc.ServiceException;
016: import org.objectweb.jonas.common.Log;
017: import org.objectweb.util.monolog.api.BasicLevel;
018: import org.objectweb.util.monolog.api.Logger;
019:
020: /**
021: *
022: */
023: public class WsClient1SLR implements SessionBean {
024:
025: static private Logger logger = null;
026: SessionContext ejbContext;
027:
028: Service service;
029:
030: // ------------------------------------------------------------------
031: // SessionBean implementation
032: // ------------------------------------------------------------------
033:
034: public void setSessionContext(SessionContext ctx) {
035: if (logger == null) {
036: logger = Log.getLogger("org.objectweb.jonas_tests");
037: }
038: logger.log(BasicLevel.DEBUG, "");
039: ejbContext = ctx;
040: }
041:
042: public void ejbRemove() {
043: logger.log(BasicLevel.DEBUG, "");
044: }
045:
046: public void ejbCreate() throws CreateException {
047: logger.log(BasicLevel.DEBUG, "");
048: }
049:
050: public void ejbPassivate() {
051: logger.log(BasicLevel.DEBUG, "");
052: }
053:
054: public void ejbActivate() {
055: logger.log(BasicLevel.DEBUG, "");
056: }
057:
058: // ------------------------------------------------------------------
059: // WsClient1 implementation
060: // ------------------------------------------------------------------
061:
062: public boolean lookupServiceJNDI() {
063: logger.log(BasicLevel.DEBUG, "lookupServiceJNDI");
064: service = null;
065: try {
066: InitialContext ic = new InitialContext();
067: service = (Service) ic.lookup("ws/XMethodsService");
068: } catch (NamingException ne) {
069: logger.log(BasicLevel.ERROR,
070: "looking ws/XMethodsService : " + ne.getMessage());
071: return false;
072: }
073: return (service != null);
074: }
075:
076: public boolean lookupServiceName() {
077: logger.log(BasicLevel.DEBUG, "lookupServiceName");
078: service = null;
079: try {
080: InitialContext ic = new InitialContext();
081: service = (Service) ic
082: .lookup("java:comp/env/service/XMethods");
083: } catch (NamingException ne) {
084: logger.log(BasicLevel.ERROR,
085: "looking java:comp/env/service/XMethods : "
086: + ne.getMessage());
087: return false;
088: }
089: return (service != null);
090: }
091:
092: public void getAllServiceNames() throws ServiceException,
093: RemoteException {
094: logger.log(BasicLevel.DEBUG, "getAllServiceNames");
095:
096: lookupServiceName();
097: Call call = service.createCall(new QName("XMethodsQuerySoap"),
098: new QName("getAllServiceNames"));
099: call.invoke(new Object[] {});
100:
101: logger.log(BasicLevel.DEBUG, "Call is OK");
102: }
103: }
|