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.EJBException ; 32 import javax.ejb.EJBHome ; 33 import javax.ejb.EJBObject ; 34 35 import org.objectweb.carol.rmi.exception.RmiUtility; 36 37 import org.objectweb.jonas_ejb.lib.EJBInvocation; 38 39 import org.objectweb.util.monolog.api.BasicLevel; 40 41 46 public abstract class JEntityRemote extends JRemote implements Remote { 47 48 protected JEntityFactory ebf; 49 50 protected JEntitySwitch bs; 51 52 56 public JEntityRemote(JEntityFactory bf) throws RemoteException { 57 super(bf); 58 if (TraceEjb.isDebugIc()) { 59 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 60 } 61 this.ebf = bf; 62 } 63 64 68 public void setEntitySwitch(JEntitySwitch bs) { 69 if (TraceEjb.isDebugIc()) { 70 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 71 } 72 this.bs = bs; 73 } 74 75 80 83 public EJBHome getEJBHome() { 84 if (TraceEjb.isDebugIc()) { 85 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 86 } 87 88 96 97 return ebf.getHome(); 98 99 107 108 } 109 110 114 public Object getPrimaryKey() { 115 if (TraceEjb.isDebugIc()) { 116 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 117 } 118 126 127 if (bs == null) { 128 throw new EJBException ("No Primary Key yet"); 129 } 130 return bs.getPrimaryKey(); 131 132 140 141 } 142 143 150 public boolean isIdentical(EJBObject obj) throws RemoteException { 151 if (TraceEjb.isDebugIc()) { 152 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 153 } 154 155 try { 156 157 boolean ret = false; 158 159 if (obj != null) { String homeClassName = getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName(); 161 String objHomeClassName = obj.getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName(); 162 163 ret = ((obj.equals(this)) || ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey() 165 .equals(getPrimaryKey())))); 166 } 167 168 return ret; 169 170 } catch (RemoteException e) { 171 RmiUtility.rethrowRmiException(e); 173 throw e; 175 } 176 177 } 178 179 183 189 public RequestCtx preInvoke(int txa) throws RemoteException { 190 if (TraceEjb.isDebugIc()) { 191 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 192 } 193 return bf.preInvokeRemote(txa); 194 } 195 196 201 public void checkSecurity(EJBInvocation ejbInv) { 202 if (TraceEjb.isDebugIc()) { 203 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 204 } 205 bf.checkSecurity(ejbInv); 206 } 207 208 213 public void postInvoke(RequestCtx rctx) throws RemoteException { 214 if (TraceEjb.isDebugIc()) { 215 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 216 } 217 try { 218 bf.postInvokeRemote(rctx); 219 } finally { 220 if (rctx.sysExc != null) { 221 bs.discardICtx(rctx.currTx); 222 } else { 223 bs.releaseICtx(rctx.currTx); 224 } 225 } 226 } 227 228 } | Popular Tags |