JLocalHome.java

00001 
00028 package org.objectweb.jonas_ejb.container;
00029 
00030 import java.util.HashMap;
00031 import java.util.Map;
00032 
00033 import javax.ejb.EJBException;
00034 import javax.ejb.EJBLocalHome;
00035 import javax.ejb.RemoveException;
00036 import javax.naming.NamingException;
00037 import javax.naming.Reference;
00038 import javax.naming.StringRefAddr;
00039 
00040 import org.objectweb.jonas_ejb.deployment.api.BeanDesc;
00041 import org.objectweb.jonas_ejb.lib.EJBInvocation;
00042 
00043 import org.objectweb.util.monolog.api.BasicLevel;
00044 
00050 public abstract class JLocalHome implements EJBLocalHome {
00051 
00052     protected BeanDesc dd;
00053 
00054     protected JFactory bf;
00055 
00056     // The static table of all JLocalHome objects
00057     protected static Map homeList = new HashMap();
00058 
00064     public JLocalHome(BeanDesc dd, JFactory bf) {
00065         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00066         this.dd = dd;
00067         this.bf = bf;
00068     }
00069 
00070     // ---------------------------------------------------------------
00071     // EJBLocalHome Implementation
00072     // ---------------------------------------------------------------
00073 
00078     public abstract void remove(Object primaryKey) throws RemoveException;
00079 
00080     // ---------------------------------------------------------------
00081     // other public methods
00082     // ---------------------------------------------------------------
00083 
00088     protected void register() throws NamingException {
00089         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00090         String name = dd.getJndiLocalName();
00091 
00092         // Keep it in the static list for later retrieving.
00093         homeList.put(name, this);
00094 
00095         Reference ref = new Reference("org.objectweb.jonas_ejb.container.JLocalHome",
00096                 "org.objectweb.jonas_ejb.container.HomeFactory", null);
00097         ref.add(new StringRefAddr("bean.name", name));
00098         bf.getInitialContext().rebind(name, ref);
00099     }
00100 
00104     protected void unregister() throws NamingException {
00105         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00106         String name = dd.getJndiLocalName();
00107         // unregister in default InitialContext
00108         bf.getInitialContext().unbind(name);
00109         // remove from the static list
00110         homeList.remove(name);
00111     }
00112 
00118     public static JLocalHome getLocalHome(String beanName) {
00119         TraceEjb.interp.log(BasicLevel.DEBUG, beanName);
00120         JLocalHome lh = (JLocalHome) homeList.get(beanName);
00121         return lh;
00122     }
00123 
00130     public RequestCtx preInvoke(int txa) {
00131         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00132         return bf.preInvoke(txa);
00133     }
00134 
00140      public void checkSecurity(EJBInvocation ejbInv) {
00141          TraceEjb.interp.log(BasicLevel.DEBUG, "");
00142          bf.checkSecurity(ejbInv);
00143      }
00144      
00149     public void postInvoke(RequestCtx rctx) {
00150         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00151         bf.postInvoke(rctx);
00152     }
00153 
00154 }

Generated on Tue Feb 15 15:05:38 2005 for JOnAS by  doxygen 1.3.9.1