1 27 28 package org.objectweb.jonas_ejb.container; 29 30 import java.util.HashMap ; 31 import java.util.Map ; 32 33 import javax.ejb.EJBLocalHome ; 34 import javax.ejb.RemoveException ; 35 import javax.naming.NamingException ; 36 import javax.naming.Reference ; 37 import javax.naming.StringRefAddr ; 38 39 import org.objectweb.jonas_ejb.deployment.api.BeanDesc; 40 import org.objectweb.jonas_ejb.lib.EJBInvocation; 41 42 import org.objectweb.util.monolog.api.BasicLevel; 43 44 49 public abstract class JLocalHome implements EJBLocalHome { 50 51 protected BeanDesc dd; 52 53 protected JFactory bf; 54 55 protected static Map homeList = new HashMap (); 57 58 63 public JLocalHome(BeanDesc dd, JFactory bf) { 64 if (TraceEjb.isDebugIc()) { 65 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 66 } 67 this.dd = dd; 68 this.bf = bf; 69 } 70 71 75 79 public abstract void remove(Object primaryKey) throws RemoveException ; 80 81 85 89 protected void register() throws NamingException { 90 if (TraceEjb.isDebugIc()) { 91 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 92 } 93 String name = dd.getJndiLocalName(); 94 95 homeList.put(name, this); 97 98 Reference ref = new Reference ("org.objectweb.jonas_ejb.container.JLocalHome", 99 "org.objectweb.jonas_ejb.container.HomeFactory", null); 100 ref.add(new StringRefAddr ("bean.name", name)); 101 bf.getInitialContext().rebind(name, ref); 102 } 103 104 107 protected void unregister() throws NamingException { 108 if (TraceEjb.isDebugIc()) { 109 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 110 } 111 String name = dd.getJndiLocalName(); 112 bf.getInitialContext().unbind(name); 114 homeList.remove(name); 116 } 117 118 123 public static JLocalHome getLocalHome(String beanName) { 124 if (TraceEjb.isDebugIc()) { 125 TraceEjb.interp.log(BasicLevel.DEBUG, beanName); 126 } 127 JLocalHome lh = (JLocalHome) homeList.get(beanName); 128 return lh; 129 } 130 131 137 public RequestCtx preInvoke(int txa) { 138 if (TraceEjb.isDebugIc()) { 139 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 140 } 141 return bf.preInvoke(txa); 142 } 143 144 149 public void checkSecurity(EJBInvocation ejbInv) { 150 if (TraceEjb.isDebugIc()) { 151 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 152 } 153 bf.checkSecurity(ejbInv); 154 } 155 156 160 public void postInvoke(RequestCtx rctx) { 161 if (TraceEjb.isDebugIc()) { 162 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 163 } 164 bf.postInvoke(rctx); 165 } 166 167 } | Popular Tags |