1 16 17 package org.apache.naming.modules.java; 18 19 import java.util.Hashtable ; 20 21 import javax.naming.Context ; 22 import javax.naming.Name ; 23 import javax.naming.NamingException ; 24 import javax.naming.spi.InitialContextFactory ; 25 import javax.naming.spi.ObjectFactory ; 26 27 import org.apache.naming.modules.memory.MemoryNamingContext; 28 29 45 46 public class javaURLContextFactory implements ObjectFactory , InitialContextFactory 47 { 48 49 50 52 53 55 56 public static final String MAIN = "initialContext"; 57 58 59 61 62 65 protected static Context initialContext = null; 66 67 68 70 71 73 74 77 public Object getObjectInstance(Object obj, Name name, Context nameCtx, 78 Hashtable environment) 79 throws NamingException { 80 if ((ContextBindings.isThreadBound()) || 81 (ContextBindings.isClassLoaderBound())) { 82 return new SelectorContext(environment); 83 } else { 84 return null; 85 } 86 } 87 88 89 92 public Context getInitialContext(Hashtable environment) 93 throws NamingException { 94 if (ContextBindings.isThreadBound() || 95 (ContextBindings.isClassLoaderBound())) { 96 return new SelectorContext(environment, true); 98 } else { 99 if (initialContext == null) 101 initialContext = new MemoryNamingContext(environment); 102 return initialContext; 103 } 104 } 105 106 107 } 108 109 | Popular Tags |