1 25 package org.objectweb.jonas_ejb.container; 26 27 import java.rmi.NoSuchObjectException ; 28 import java.rmi.Remote ; 29 import java.rmi.RemoteException ; 30 31 import javax.ejb.EJBException ; 32 import javax.naming.NamingException ; 33 import javax.rmi.PortableRemoteObject ; 34 import javax.xml.rpc.ServiceException ; 35 import javax.xml.rpc.handler.MessageContext ; 36 import javax.xml.rpc.server.ServiceLifecycle ; 37 38 import org.objectweb.jonas.common.Log; 39 import org.objectweb.jonas_ejb.deployment.api.MethodDesc; 40 import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc; 41 import org.objectweb.jonas_ejb.lib.EJBInvocation; 42 43 import org.objectweb.util.monolog.api.BasicLevel; 44 import org.objectweb.util.monolog.api.Logger; 45 46 52 public class JServiceEndpoint extends PortableRemoteObject implements Remote , ServiceLifecycle { 53 54 57 protected static Logger logger = null; 58 59 62 protected JSessionSwitch bs; 63 64 67 protected JStatelessFactory bf; 68 69 private MessageContext messageContext = null; 70 71 74 public JServiceEndpoint(JStatelessFactory sf) throws RemoteException { 75 super(); 76 logger = Log.getLogger(Log.JONAS_WS_EJBPROVIDER_PREFIX); 77 if (logger.isLoggable(BasicLevel.DEBUG)) { 78 logger.log(BasicLevel.DEBUG, ""); 79 } 80 bf = sf; 81 } 82 83 87 91 public void setMessageContext(MessageContext msgctx) { 92 messageContext = msgctx; 93 } 94 95 99 public MessageContext getMessageContext() { 100 return messageContext; 101 } 102 103 107 public void setSessionSwitch(JSessionSwitch bs) { 108 if (logger.isLoggable(BasicLevel.DEBUG)) { 109 logger.log(BasicLevel.DEBUG, ""); 110 } 111 this.bs = bs; 112 } 113 114 120 public RequestCtx preInvoke(int txa) throws RemoteException { 121 if (logger.isLoggable(BasicLevel.DEBUG)) { 122 logger.log(BasicLevel.DEBUG, ""); 123 } 124 return bf.preInvokeRemote(txa); 125 } 126 127 132 public void checkSecurity(EJBInvocation ejbInv) { 133 if (logger.isLoggable(BasicLevel.DEBUG)) { 134 logger.log(BasicLevel.DEBUG, ""); 135 } 136 bf.checkSecurity(ejbInv); 137 } 138 139 144 public void postInvoke(RequestCtx rctx) throws RemoteException { 145 if (logger.isLoggable(BasicLevel.DEBUG)) { 146 logger.log(BasicLevel.DEBUG, ""); 147 } 148 try { 149 bf.postInvokeRemote(rctx); 150 } finally { 151 bs.releaseICtx(rctx.currTx); 153 } 154 } 155 156 160 163 public void init(Object arg0) throws ServiceException { 164 if (logger.isLoggable(BasicLevel.DEBUG)) { 165 logger.log(BasicLevel.DEBUG, ""); 166 } 167 } 168 169 172 public void destroy() { 173 if (logger.isLoggable(BasicLevel.DEBUG)) { 174 logger.log(BasicLevel.DEBUG, ""); 175 } 176 RequestCtx rctx = null; 177 try { 178 rctx = bf.preInvoke(MethodDesc.TX_NOT_SET); 179 bf.checkSecurity(null); 180 } catch (Exception e) { 181 logger.log(BasicLevel.ERROR, "preInvoke failed: ", e); 182 return; 183 } 184 try { 185 JSessionContext bctx = bs.getICtx(rctx.currTx); 186 bctx.setRemoved(); 187 } catch (Exception e) { 188 rctx.sysExc = e; 189 logger.log(BasicLevel.ERROR, "EJB exception thrown:", e); 190 } catch (Error e) { 191 rctx.sysExc = e; 192 logger.log(BasicLevel.ERROR, "error thrown:", e); 193 } finally { 194 try { 195 bf.postInvoke(rctx); 196 } catch (Exception e) { 197 logger.log(BasicLevel.ERROR, "exception on postInvoke: ", e); 198 } 199 } 200 201 } 202 203 } | Popular Tags |