1 9 package org.openuss.utility; 10 11 import java.io.*; 12 13 import java.rmi.RemoteException ; 14 15 import java.util.*; 16 17 19 import javax.naming.*; 20 21 import javax.rmi.*; 22 23 25 26 32 public class HomeInterfaceFactory { 33 private static Context initialContext = null; 35 36 39 public static Object create(Class homeClass, String homeName) { 40 if (initialContext == null) { 44 try { 46 initialContext = new InitialContext(); 47 } catch (Exception e) { 48 System.out.println("Error getting initial context from JNDI: " + 49 e.toString()); 50 } 51 } 52 53 Object home = null; 56 57 try { 58 home = PortableRemoteObject.narrow(initialContext.lookup(homeName), 59 homeClass); 60 } catch (Exception e) { 61 System.out.println("Error getting home object: " + e.toString()); 62 } 63 64 return home; 66 } 67 } | Popular Tags |