1 55 package org.lateralnz.panther.naming; 56 57 import java.util.Hashtable ; 58 import java.util.HashMap ; 59 import javax.naming.*; 60 61 import org.apache.log4j.Logger; 62 63 import org.lateralnz.common.util.Constants; 64 import org.lateralnz.common.util.StringUtils; 65 import org.lateralnz.panther.util.EJBRef; 66 67 71 public class WLocalContext extends LocalContext implements Context, Constants, Referenceable { 72 public static final String NAMING_FACTORY_INITIAL = "panther.naming.factory.initial"; 73 74 private static final Logger log = Logger.getLogger(WLocalContext.class.getName()); 75 76 Context ctx = null; 77 78 public WLocalContext(HashMap objects, Hashtable environ) { 79 super(objects, environ); 80 } 81 82 public WLocalContext(Hashtable ht) throws NamingException { 83 super(ht); 84 String tmp = (String )ht.get(NAMING_FACTORY_INITIAL); 85 if (StringUtils.isEmpty(tmp)) { 86 tmp = System.getProperty(NAMING_FACTORY_INITIAL); 87 } 88 if (StringUtils.isEmpty(tmp)) { 89 throw new NamingException("missing '" + NAMING_FACTORY_INITIAL + "'"); 90 } 91 ht.put(Context.INITIAL_CONTEXT_FACTORY, tmp); 92 ctx = new InitialContext(ht); 93 } 94 95 public LocalContext create(HashMap objects, Hashtable environ) { 96 return new WLocalContext(objects, environ); 97 } 98 99 public Object addToEnvironment(String name, Object obj) throws NamingException { 100 ctx.addToEnvironment(name, obj); 101 return super.addToEnvironment(name, obj); 102 } 103 104 public void bind(Name name, Object obj) throws NamingException { 105 bind(name.toString(), obj); 106 } 107 108 public void bind(String name, Object obj) throws NamingException { 109 ctx.bind(name, obj); 110 super.bind(name, obj); 111 } 112 113 public void close() throws NamingException { 114 super.close(); 115 ctx = null; 116 } 117 118 public Context createSubcontext(String name) throws NamingException { 119 Context sub = ctx.createSubcontext(name); 120 WLocalContext wctx = (WLocalContext)super.createSubcontext(name); 121 wctx.ctx = sub; 122 return wctx; 123 } 124 125 public void destroySubcontext(Name name) throws NamingException { 126 destroySubcontext(name.toString()); 127 } 128 129 public void destroySubcontext(String name) throws NamingException { 130 ctx.destroySubcontext(name); 131 super.destroySubcontext(name); 132 } 133 134 public void rebind(String name, Object obj) throws NamingException { 135 ctx.rebind(name, obj); 136 super.rebind(name, obj); 137 } 138 139 public Object removeFromEnvironment(String name) throws NamingException { 140 ctx.removeFromEnvironment(name); 141 return super.removeFromEnvironment(name); 142 } 143 144 public void rename(String name1, String name2) throws NamingException { 145 ctx.rename(name1, name2); 146 super.rename(name1, name2); 147 } 148 149 public void unbind(String name) throws NamingException { 150 ctx.unbind(name); 151 super.unbind(name); 152 } 153 154 }
| Popular Tags
|