1 22 package org.jboss.test.hibernate.ejb.interfaces; 23 24 27 public class ProfileServiceUtil 28 { 29 30 private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException { 31 javax.naming.InitialContext initialContext = new javax.naming.InitialContext (environment); 33 try { 34 Object objRef = initialContext.lookup(jndiName); 35 if (narrowTo.isInstance(java.rmi.Remote .class)) 37 return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo); 38 else 39 return objRef; 40 } finally { 41 initialContext.close(); 42 } 43 } 44 45 47 51 public static org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome getHome() throws javax.naming.NamingException 52 { 53 return (org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome) lookupHome(null, org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome.JNDI_NAME, org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome.class); 54 } 55 56 61 public static org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome getHome( java.util.Hashtable environment ) throws javax.naming.NamingException 62 { 63 return (org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome) lookupHome(environment, org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome.JNDI_NAME, org.jboss.test.hibernate.ejb.interfaces.ProfileServiceHome.class); 64 } 65 66 } | Popular Tags |