1 16 17 package org.apache.naming.core; 18 19 import java.util.Enumeration ; 20 import java.util.Hashtable ; 21 22 import javax.naming.CompositeName ; 23 import javax.naming.InvalidNameException ; 24 import javax.naming.Name ; 25 import javax.naming.NameParser ; 26 import javax.naming.NamingException ; 27 import javax.naming.OperationNotSupportedException ; 28 import javax.naming.directory.Attributes ; 29 import javax.naming.directory.DirContext ; 30 31 import org.apache.tomcat.util.IntrospectionUtils; 32 33 36 62 public class BaseNaming { 63 64 67 public BaseNaming() { 68 this.env=new Hashtable (); 69 } 70 71 74 public BaseNaming(Hashtable env) { 75 this.env=new Hashtable (); 76 if (env != null ) { 77 Enumeration envEntries = env.keys(); 78 while (envEntries.hasMoreElements()) { 79 String entryName = (String ) envEntries.nextElement(); 80 Object entryValue=env.get(entryName); 81 this.env.put(entryName, entryValue); 82 try { 83 IntrospectionUtils.setAttribute( this, entryName, entryValue ); 87 } catch(Exception ex ) { 88 System.out.println("Unsuported property " + entryName + " " + ex.getMessage()); 89 } 90 } 91 } 92 } 93 94 96 99 protected Hashtable env; 100 101 106 protected final NameParser nameParser = new NameParserImpl(); 107 108 112 protected String urlPrefix=""; 113 114 117 public void setURLPrefix( String s ) { 120 urlPrefix=s; 121 } 122 123 private boolean cached; 124 private int cacheTTL; 125 private int cacheObjectMaxSize; 126 127 public boolean isCached() { 128 return cached; 129 } 130 131 public void setCached(boolean cached) { 132 this.cached = cached; 133 } 134 135 public int getCacheTTL() { 136 return cacheTTL; 137 } 138 139 public void setCacheTTL(int cacheTTL) { 140 this.cacheTTL = cacheTTL; 141 } 142 143 public int getCacheObjectMaxSize() { 144 return cacheObjectMaxSize; 145 } 146 147 public void setCacheObjectMaxSize(int cacheObjectMaxSize) { 148 this.cacheObjectMaxSize = cacheObjectMaxSize; 149 } 150 151 154 156 161 public Object lookup(Name name, boolean resolveLinks) 162 throws NamingException 163 { 164 throw new OperationNotSupportedException (); 165 } 166 167 175 public void bind(Name name, Object obj, Attributes attrs, boolean rebind ) 176 throws NamingException 177 { 178 throw new OperationNotSupportedException (); 179 } 180 181 183 public void unbind(Name name, boolean isContext) 184 throws NamingException 185 { 186 throw new OperationNotSupportedException (); 187 } 188 189 193 194 205 public Enumeration getChildren() throws NamingException { 206 return null; 207 } 208 209 public DirContext createSubcontext(Name name, Attributes attrs) 210 throws NamingException 211 { 212 throw new OperationNotSupportedException (); 214 } 215 216 219 public Object getAttribute( Name name, String attName ) 220 throws NamingException 221 { 222 throw new OperationNotSupportedException (); 223 } 224 225 public void setAttribute( Name name, String attName, Object value ) 226 throws NamingException 227 { 228 throw new OperationNotSupportedException (); 229 } 230 231 public String [] getAttributeNames(Name name ) 232 throws NamingException 233 { 234 throw new OperationNotSupportedException (); 235 } 236 237 238 241 244 protected boolean isWritable(Name name) { 245 return true; 246 } 248 249 250 253 protected void checkWritable(Name n) 254 throws NamingException 255 { 256 if (!isWritable(n)) 257 throw new NamingException ("read only"); 258 } 259 260 protected Name string2Name(String s ) throws InvalidNameException { 261 return new CompositeName ( s ); 264 } 269 270 272 275 public void allocate() { 276 ; } 278 279 280 283 public void release() { 284 ; } 286 287 public void recycle() { 288 } 290 291 293 306 public void execute() { 307 } 308 } 309 310
| Popular Tags
|