1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import javax.ejb.EJBException ; 29 import javax.ejb.EJBLocalHome ; 30 import javax.ejb.EJBLocalObject ; 31 import javax.ejb.RemoveException ; 32 33 import org.objectweb.jonas_ejb.lib.EJBInvocation; 34 35 import org.objectweb.util.monolog.api.BasicLevel; 36 37 41 public abstract class JEntityLocal extends JLocal { 42 43 protected JEntityFactory bf; 44 45 protected JEntitySwitch bs; 46 47 51 public JEntityLocal(JEntityFactory bf) { 52 super(bf); 53 if (TraceEjb.isDebugIc()) { 54 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 55 } 56 this.bf = bf; 57 } 58 59 63 public void setEntitySwitch(JEntitySwitch bs) { 64 if (TraceEjb.isDebugIc()) { 65 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 66 } 67 this.bs = bs; 68 } 69 70 75 79 public abstract void remove() throws RemoveException ; 80 81 84 public EJBLocalHome getEJBLocalHome() { 85 if (TraceEjb.isDebugIc()) { 86 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 87 } 88 return bf.getLocalHome(); 89 } 90 91 94 public Object getPrimaryKey() { 95 if (TraceEjb.isDebugIc()) { 96 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 97 } 98 if (bs == null) { 99 throw new EJBException ("No Primary Key yet"); 100 } 101 return bs.getPrimaryKey(); 102 } 103 104 111 public boolean isIdentical(EJBLocalObject obj) { 112 if (TraceEjb.isDebugIc()) { 113 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 114 } 115 boolean ret = false; 116 if (obj != null) { 117 String homeClassName = getEJBLocalHome().getClass().getName(); 119 String objHomeClassName = obj.getEJBLocalHome().getClass().getName(); 120 121 ret = ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey().equals(getPrimaryKey()))); 123 } 124 return ret; 125 } 126 127 133 public RequestCtx preInvoke(int txa) { 134 if (TraceEjb.isDebugIc()) { 135 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 136 } 137 return bf.preInvoke(txa); 138 } 139 140 145 public void checkSecurity(EJBInvocation ejbInv) { 146 if (TraceEjb.isDebugIc()) { 147 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 148 } 149 bf.checkSecurity(ejbInv); 150 } 151 152 157 public void postInvoke(RequestCtx rctx) { 158 if (TraceEjb.isDebugIc()) { 159 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 160 } 161 try { 162 bf.postInvoke(rctx); 163 } finally { 164 if (rctx.sysExc != null) { 165 bs.discardICtx(rctx.currTx); 166 } else { 167 bs.releaseICtx(rctx.currTx); 168 } 169 } 170 } 171 } | Popular Tags |