1 22 package org.jnp.interfaces; 23 24 import java.util.Hashtable ; 25 import javax.naming.Context ; 26 import javax.naming.Name ; 27 import javax.naming.NamingException ; 28 import javax.naming.Reference ; 29 import javax.naming.spi.InitialContextFactory ; 30 import javax.naming.spi.ObjectFactory ; 31 32 38 public class LocalOnlyContextFactory 39 implements InitialContextFactory , ObjectFactory 40 { 41 public Context getInitialContext(Hashtable env) 43 throws NamingException 44 { 45 if (NamingContext.localServer == null) throw new NamingException ("Local server is not initialized"); 46 return new NamingContext(env, null, NamingContext.localServer); 47 } 48 49 public Object getObjectInstance(Object obj, 51 Name name, 52 Context nameCtx, 53 Hashtable environment) 54 throws Exception 55 { 56 Context ctx = getInitialContext(environment); 57 Reference ref = (Reference )obj; 58 return ctx.lookup((String )ref.get("URL").getContent()); 59 } 60 61 } 62 | Popular Tags |