00001
00026 package org.objectweb.jonas_ejb.container;
00027
00028 import java.rmi.Remote;
00029 import java.rmi.RemoteException;
00030
00031 import javax.ejb.EJBException;
00032 import javax.ejb.EJBHome;
00033 import javax.ejb.EJBObject;
00034
00035 import org.objectweb.carol.rmi.exception.RmiUtility;
00036
00037 import org.objectweb.jonas_ejb.lib.EJBInvocation;
00038
00039 import org.objectweb.util.monolog.api.BasicLevel;
00040
00046 public abstract class JEntityRemote extends JRemote implements Remote {
00047
00048 protected JEntityFactory ebf;
00049
00050 protected JEntitySwitch bs;
00051
00056 public JEntityRemote(JEntityFactory bf) throws RemoteException {
00057 super(bf);
00058 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00059 this.ebf = bf;
00060 }
00061
00066 public void setEntitySwitch(JEntitySwitch bs) {
00067 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00068 this.bs = bs;
00069 }
00070
00071
00072
00073
00074
00075
00079 public EJBHome getEJBHome() {
00080 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 return ebf.getHome();
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 }
00103
00108 public Object getPrimaryKey() {
00109 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 if (bs == null) {
00120 throw new EJBException("No Primary Key yet");
00121 }
00122 return bs.getPrimaryKey();
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 }
00134
00142 public boolean isIdentical(EJBObject obj) throws RemoteException {
00143 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00144
00145 try {
00146
00147 boolean ret = false;
00148
00149 if (obj != null) {
00150 String homeClassName = getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName();
00151 String objHomeClassName = obj.getEJBHome().getEJBMetaData().getHomeInterfaceClass().getName();
00152
00153
00154 ret = ((obj.equals(this)) || ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey()
00155 .equals(getPrimaryKey()))));
00156 }
00157
00158 return ret;
00159
00160 } catch (RemoteException e) {
00161
00162 RmiUtility.rethrowRmiException(e);
00163
00164 throw e;
00165 }
00166
00167 }
00168
00169
00170
00171
00172
00179 public RequestCtx preInvoke(int txa) throws RemoteException {
00180 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00181 return bf.preInvokeRemote(txa);
00182 }
00183
00189 public void checkSecurity(EJBInvocation ejbInv) {
00190 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00191 bf.checkSecurity(ejbInv);
00192 }
00193
00199 public void postInvoke(RequestCtx rctx) throws RemoteException {
00200 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00201 try {
00202 bf.postInvokeRemote(rctx);
00203 } finally {
00204 if (rctx.sysExc != null) {
00205 bs.discardICtx(rctx.currTx);
00206 } else {
00207 bs.releaseICtx(rctx.currTx);
00208 }
00209 }
00210 }
00211
00212 }