1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.rmi.Remote ; 29 import java.rmi.RemoteException ; 30 31 import javax.ejb.EJBHome ; 32 import javax.ejb.EJBObject ; 33 import javax.ejb.Handle ; 34 import javax.ejb.RemoveException ; 35 import javax.rmi.PortableRemoteObject ; 36 37 import org.objectweb.carol.rmi.exception.RmiUtility; 38 import org.objectweb.carol.util.configuration.ConfigurationRepository; 39 40 import org.objectweb.jonas_ejb.lib.EJBInvocation; 41 import org.objectweb.jonas_ejb.svc.JHandleIIOP; 42 43 import org.objectweb.util.monolog.api.BasicLevel; 44 45 50 public abstract class JSessionRemote extends JRemote implements Remote { 51 52 53 56 protected JSessionSwitch bs; 57 58 63 public JSessionRemote(JSessionFactory bf) throws RemoteException { 64 super((JFactory) bf); 65 if (TraceEjb.isDebugIc()) { 66 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 67 } 68 } 69 70 75 80 public abstract void remove() throws RemoteException , RemoveException ; 81 82 85 public EJBHome getEJBHome() { 86 94 95 return bf.getHome(); 96 97 105 106 } 107 108 112 public Object getPrimaryKey() throws RemoteException { 113 114 try { 115 throw new RemoteException ("Session bean has no primary key"); 116 } catch (RemoteException e) { 117 RmiUtility.rethrowRmiException(e); 119 throw e; 121 } 122 } 123 124 131 public boolean isIdentical(EJBObject obj) throws RemoteException { 132 if (TraceEjb.isDebugIc()) { 133 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 134 } 135 try { 136 boolean ret = false; 137 JSessionFactory sf = (JSessionFactory) bf; 138 if (sf.isStateful()) { 139 if (obj != null) { 141 ret = ((obj.equals(PortableRemoteObject.toStub(this))) || (obj.equals(this))); 142 } 143 } else { 144 String myhome = getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName(); 147 if (obj != null) { 148 ret = obj.getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName().equals(myhome); 149 } 150 } 151 return ret; 152 } catch (RemoteException e) { 153 RmiUtility.rethrowRmiException(e); 156 throw e; 158 } 159 } 160 161 168 public Handle getHandle() throws RemoteException { 169 if (TraceEjb.isDebugIc()) { 170 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 171 } 172 173 181 String protocol = ConfigurationRepository.getCurrentConfiguration().getProtocol().getName(); 184 if (TraceEjb.interp.isLoggable(BasicLevel.DEBUG)) { 185 TraceEjb.interp.log(BasicLevel.DEBUG, "Current protocol = " + protocol); 186 } 187 188 if (protocol.equals("iiop")) { 189 return new JHandleIIOP(this); 190 } else { 191 return new JSessionHandle(this); 192 } 193 194 202 203 } 204 205 209 213 public void setSessionSwitch(JSessionSwitch bs) { 214 if (TraceEjb.isDebugIc()) { 215 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 216 } 217 this.bs = bs; 218 } 219 220 223 public JSessionSwitch getSessionSwitch() { 224 return bs; 225 } 226 227 234 public RequestCtx preInvoke(int txa) throws RemoteException { 235 if (TraceEjb.isDebugIc()) { 236 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 237 } 238 RequestCtx rctx = bf.preInvokeRemote(txa); 239 bs.setMustCommit(rctx.mustCommit); bs.enlistConnections(rctx.currTx); return rctx; 242 } 243 244 249 public void checkSecurity(EJBInvocation ejbInv) { 250 if (TraceEjb.isDebugIc()) { 251 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 252 } 253 bf.checkSecurity(ejbInv); 254 } 255 256 262 public void postInvoke(RequestCtx rctx) throws RemoteException { 263 if (TraceEjb.isDebugIc()) { 264 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 265 } 266 bs.delistConnections(rctx.currTx); 267 bs.saveBeanTx(); 269 try { 270 bf.postInvokeRemote(rctx); 271 } finally { 272 if (rctx.sysExc != null) { 273 bs.discardICtx(rctx.currTx); 274 } else { 275 bs.releaseICtx(rctx.currTx); 276 } 277 } 278 } 279 280 } 281 | Popular Tags |