1 28 29 package com.caucho.naming; 30 31 import com.caucho.loader.EnvironmentLocal; 32 import com.caucho.util.L10N; 33 34 import javax.naming.Context ; 35 import javax.naming.NamingException ; 36 import javax.naming.spi.InitialContextFactory ; 37 import java.util.Hashtable ; 38 import java.util.logging.Logger ; 39 40 45 public class InitialContextFactoryImpl implements InitialContextFactory 46 { 47 private static Logger log 48 = Logger.getLogger(InitialContextFactoryImpl.class.getName()); 49 private static L10N L = new L10N(InitialContextFactoryImpl.class); 50 51 private static EnvironmentLocal<AbstractModel> _rootModel 52 = new EnvironmentLocal<AbstractModel>("caucho.naming.model.root"); 53 54 57 public InitialContextFactoryImpl() 58 { 59 } 60 61 64 public static AbstractModel getContextModel() 65 { 66 return _rootModel.get(); 67 } 68 69 72 public static void setContextModel(AbstractModel model) 73 { 74 _rootModel.set(model); 75 } 76 77 80 public Context getInitialContext(Hashtable <?,?> env) 81 throws NamingException 82 { 83 AbstractModel model = _rootModel.getLevel(); 84 85 if (model == null) { 86 model = _rootModel.get(); 87 88 if (model != null) 89 model = model.copy(); 90 else 91 model = new MemoryModel(); 92 93 _rootModel.set(model); 94 } 95 96 return new ContextImpl(model, env); 97 } 98 } 99 | Popular Tags |