JServiceEndpoint.java

00001 
00025 package org.objectweb.jonas_ejb.container;
00026 
00027 import java.rmi.NoSuchObjectException;
00028 import java.rmi.Remote;
00029 import java.rmi.RemoteException;
00030 
00031 import javax.ejb.EJBException;
00032 import javax.naming.NamingException;
00033 import javax.rmi.PortableRemoteObject;
00034 import javax.xml.rpc.ServiceException;
00035 import javax.xml.rpc.handler.MessageContext;
00036 import javax.xml.rpc.server.ServiceLifecycle;
00037 
00038 import org.objectweb.jonas.common.Log;
00039 import org.objectweb.jonas_ejb.deployment.api.MethodDesc;
00040 import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc;
00041 import org.objectweb.jonas_ejb.lib.EJBInvocation;
00042 
00043 import org.objectweb.util.monolog.api.BasicLevel;
00044 import org.objectweb.util.monolog.api.Logger;
00045 
00052 public class JServiceEndpoint extends PortableRemoteObject implements Remote, ServiceLifecycle {
00053 
00057     protected static Logger logger = null;
00058 
00062     protected JSessionSwitch bs;
00063 
00067     protected JStatelessFactory bf;
00068 
00069     private MessageContext messageContext = null;
00070 
00074     public JServiceEndpoint(JStatelessFactory sf) throws RemoteException {
00075         super();
00076         logger = Log.getLogger(Log.JONAS_WS_EJBPROVIDER_PREFIX);
00077         logger.log(BasicLevel.DEBUG, "");
00078         bf = sf;
00079     }
00080 
00081     // ---------------------------------------------------------------
00082     // other public methods
00083     // ---------------------------------------------------------------
00084 
00089     public void setMessageContext(MessageContext msgctx) {
00090         messageContext = msgctx;
00091     }
00092     
00097     public MessageContext getMessageContext() {
00098         return messageContext;
00099     }
00100     
00105     public void setSessionSwitch(JSessionSwitch bs) {
00106         logger.log(BasicLevel.DEBUG, "");
00107         this.bs = bs;
00108     }
00109 
00116     public RequestCtx preInvoke(int txa) throws RemoteException {
00117         logger.log(BasicLevel.DEBUG, "");
00118         return bf.preInvokeRemote(txa);
00119     }
00120 
00126     public void checkSecurity(EJBInvocation ejbInv) {
00127         logger.log(BasicLevel.DEBUG, "");
00128         bf.checkSecurity(ejbInv);
00129     }
00130 
00136     public void postInvoke(RequestCtx rctx) throws RemoteException {
00137         logger.log(BasicLevel.DEBUG, "");
00138         try {
00139             bf.postInvokeRemote(rctx);
00140         } finally {
00141             // put instance in the pool for future reuse.
00142             bs.releaseICtx(rctx.currTx);
00143         }
00144     }
00145 
00146     // --------------------------------------------------------------------
00147     // ServiceLifeCycle implementation
00148     // --------------------------------------------------------------------
00149     
00153     public void init(Object arg0) throws ServiceException {
00154         logger.log(BasicLevel.DEBUG, "");
00155     }
00156     
00160     public void destroy() {
00161         logger.log(BasicLevel.DEBUG, "");
00162         RequestCtx rctx = null;
00163         try {
00164             rctx = bf.preInvoke(MethodDesc.TX_NOT_SET);
00165             bf.checkSecurity(null);
00166         } catch (Exception e) {
00167             logger.log(BasicLevel.ERROR, "preInvoke failed: ", e);
00168             return;
00169         }
00170         try {
00171             JSessionContext bctx = bs.getICtx(rctx.currTx);
00172             bctx.setRemoved();
00173         } catch (Exception e) {
00174             rctx.sysExc = e;
00175             logger.log(BasicLevel.ERROR, "EJB exception thrown:", e);
00176         } catch (Error e) {
00177             rctx.sysExc = e;
00178             logger.log(BasicLevel.ERROR, "error thrown:", e);
00179         } finally {
00180             try {
00181                 bf.postInvoke(rctx);
00182             } catch (Exception e) {
00183                 logger.log(BasicLevel.ERROR, "exception on postInvoke: ", e);
00184             }
00185         }
00186         
00187     }
00188     
00189 }

Generated on Tue Feb 15 15:05:41 2005 for JOnAS by  doxygen 1.3.9.1