00001
00026 package org.objectweb.jonas_ejb.container;
00027
00028 import javax.ejb.EJBException;
00029 import javax.ejb.EJBLocalHome;
00030 import javax.ejb.EJBLocalObject;
00031 import javax.ejb.RemoveException;
00032
00033 import org.objectweb.jonas_ejb.lib.EJBInvocation;
00034
00035 import org.objectweb.util.monolog.api.BasicLevel;
00036
00041 public abstract class JEntityLocal extends JLocal {
00042
00043 protected JEntityFactory bf;
00044
00045 protected JEntitySwitch bs;
00046
00051 public JEntityLocal(JEntityFactory bf) {
00052 super(bf);
00053 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00054 this.bf = bf;
00055 }
00056
00061 public void setEntitySwitch(JEntitySwitch bs) {
00062 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00063 this.bs = bs;
00064 }
00065
00066
00067
00068
00069
00070
00075 public abstract void remove() throws RemoveException;
00076
00080 public EJBLocalHome getEJBLocalHome() {
00081 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00082 return bf.getLocalHome();
00083 }
00084
00088 public Object getPrimaryKey() {
00089 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00090 if (bs == null) {
00091 throw new EJBException("No Primary Key yet");
00092 }
00093 return bs.getPrimaryKey();
00094 }
00095
00103 public boolean isIdentical(EJBLocalObject obj) {
00104 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00105 boolean ret = false;
00106 if (obj != null) {
00107
00108 String homeClassName = getEJBLocalHome().getClass().getName();
00109 String objHomeClassName = obj.getEJBLocalHome().getClass().getName();
00110
00111
00112 ret = ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey().equals(getPrimaryKey())));
00113 }
00114 return ret;
00115 }
00116
00123 public RequestCtx preInvoke(int txa) {
00124 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00125 return bf.preInvoke(txa);
00126 }
00127
00133 public void checkSecurity(EJBInvocation ejbInv) {
00134 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00135 bf.checkSecurity(ejbInv);
00136 }
00137
00143 public void postInvoke(RequestCtx rctx) {
00144 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00145 try {
00146 bf.postInvoke(rctx);
00147 } finally {
00148 if (rctx.sysExc != null) {
00149 bs.discardICtx(rctx.currTx);
00150 } else {
00151 bs.releaseICtx(rctx.currTx);
00152 }
00153 }
00154 }
00155 }