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 JSessionLocal extends JLocal { 42 43 protected JSessionFactory bf; 44 45 protected JSessionSwitch bs; 46 47 51 public JSessionLocal(JSessionFactory bf) { 52 super(bf); 53 if (TraceEjb.isDebugIc()) { 54 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 55 } 56 this.bf = bf; 57 } 58 59 64 public abstract void remove() throws RemoveException ; 65 66 69 public EJBLocalHome getEJBLocalHome() { 70 return bf.getLocalHome(); 71 } 72 73 77 public Object getPrimaryKey() throws EJBException { 78 throw new EJBException ("Session bean has no primary key"); 79 } 80 81 90 public boolean isIdentical(EJBLocalObject obj) { 91 if (TraceEjb.isDebugIc()) { 92 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 93 } 94 boolean ret = false; 95 JSessionFactory sf = bf; 96 if (sf.isStateful()) { 97 if (obj != null) { 99 ret = obj.equals(this); 100 } 101 } else { 102 if (obj != null) { 105 try { 106 JSessionLocal ejb2 = (JSessionLocal) obj; 108 JSessionSwitch bs2 = ejb2.getSessionSwitch(); 109 JSessionFactory bf2 = bs2.getBeanFactory(); 110 ret = bf2.equals(sf); 111 } catch (Exception e) { 112 TraceEjb.logger.log(BasicLevel.WARN, "exception:" + e); 113 throw new EJBException ("isIdentical failed", e); 114 } 115 } 116 } 117 return ret; 118 } 119 120 124 128 public void setSessionSwitch(JSessionSwitch bs) { 129 if (TraceEjb.isDebugIc()) { 130 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 131 } 132 this.bs = bs; 133 } 134 135 138 public JSessionSwitch getSessionSwitch() { 139 return bs; 140 } 141 142 148 public RequestCtx preInvoke(int txa) { 149 if (TraceEjb.isDebugIc()) { 150 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 151 } 152 RequestCtx rctx = bf.preInvoke(txa); 153 bs.setMustCommit(rctx.mustCommit); bs.enlistConnections(rctx.currTx); return rctx; 156 } 157 158 163 public void checkSecurity(EJBInvocation ejbInv) { 164 if (TraceEjb.isDebugIc()) { 165 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 166 } 167 bf.checkSecurity(ejbInv); 168 } 169 170 175 public void postInvoke(RequestCtx rctx) { 176 if (TraceEjb.isDebugIc()) { 177 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 178 } 179 bs.delistConnections(rctx.currTx); 180 bs.saveBeanTx(); 182 try { 183 bf.postInvoke(rctx); 184 } finally { 185 if (rctx.sysExc != null) { 186 bs.discardICtx(rctx.currTx); 187 } else { 188 bs.releaseICtx(rctx.currTx); 189 } 190 } 191 } 192 193 } 194 | Popular Tags |