1 17 18 19 package org.apache.naming.resources; 20 21 import java.util.Hashtable ; 22 23 import javax.naming.Context ; 24 import javax.naming.Name ; 25 import javax.naming.NameParser ; 26 import javax.naming.NamingEnumeration ; 27 import javax.naming.NamingException ; 28 import javax.naming.directory.Attributes ; 29 import javax.naming.directory.DirContext ; 30 import javax.naming.directory.ModificationItem ; 31 import javax.naming.directory.SearchControls ; 32 33 import org.apache.naming.NameParserImpl; 34 import org.apache.naming.StringManager; 35 36 42 43 public abstract class BaseDirContext implements DirContext { 44 45 46 48 49 51 52 55 public BaseDirContext() { 56 this.env = new Hashtable (); 57 } 58 59 60 63 public BaseDirContext(Hashtable env) { 64 this.env = env; 65 } 66 67 68 70 71 74 protected String docBase = null; 75 76 77 80 protected Hashtable env; 81 82 83 86 protected StringManager sm = StringManager.getManager(Constants.Package); 87 88 89 92 protected final NameParser nameParser = new NameParserImpl(); 93 94 95 98 protected boolean cached = true; 99 100 101 104 protected int cacheTTL = 5000; 106 107 110 protected int cacheMaxSize = 10240; 112 113 115 116 119 public String getDocBase() { 120 return (this.docBase); 121 } 122 123 124 134 public void setDocBase(String docBase) { 135 136 if (docBase == null) 138 throw new IllegalArgumentException 139 (sm.getString("resources.null")); 140 141 this.docBase = docBase; 143 144 } 145 146 147 150 public void setCached(boolean cached) { 151 this.cached = cached; 152 } 153 154 155 158 public boolean isCached() { 159 return cached; 160 } 161 162 163 166 public void setCacheTTL(int cacheTTL) { 167 this.cacheTTL = cacheTTL; 168 } 169 170 171 174 public int getCacheTTL() { 175 return cacheTTL; 176 } 177 178 179 182 public int getCacheMaxSize() { 183 return cacheMaxSize; 184 } 185 186 187 190 public void setCacheMaxSize(int cacheMaxSize) { 191 this.cacheMaxSize = cacheMaxSize; 192 } 193 194 195 197 198 201 public void allocate() { 202 ; } 204 205 206 209 public void release() { 210 ; } 212 213 214 216 217 227 public Object lookup(Name name) 228 throws NamingException { 229 return lookup(name.toString()); 230 } 231 232 233 240 public abstract Object lookup(String name) 241 throws NamingException ; 242 243 244 256 public void bind(Name name, Object obj) 257 throws NamingException { 258 bind(name.toString(), obj); 259 } 260 261 262 272 public void bind(String name, Object obj) 273 throws NamingException { 274 bind(name, obj, null); 275 } 276 277 278 293 public void rebind(Name name, Object obj) 294 throws NamingException { 295 rebind(name.toString(), obj); 296 } 297 298 299 308 public void rebind(String name, Object obj) 309 throws NamingException { 310 rebind(name, obj, null); 311 } 312 313 314 328 public void unbind(Name name) 329 throws NamingException { 330 unbind(name.toString()); 331 } 332 333 334 342 public abstract void unbind(String name) 343 throws NamingException ; 344 345 346 357 public void rename(Name oldName, Name newName) 358 throws NamingException { 359 rename(oldName.toString(), newName.toString()); 360 } 361 362 363 372 public abstract void rename(String oldName, String newName) 373 throws NamingException ; 374 375 376 389 public NamingEnumeration list(Name name) 390 throws NamingException { 391 return list(name.toString()); 392 } 393 394 395 404 public abstract NamingEnumeration list(String name) 405 throws NamingException ; 406 407 408 421 public NamingEnumeration listBindings(Name name) 422 throws NamingException { 423 return listBindings(name.toString()); 424 } 425 426 427 436 public abstract NamingEnumeration listBindings(String name) 437 throws NamingException ; 438 439 440 465 public void destroySubcontext(Name name) 466 throws NamingException { 467 destroySubcontext(name.toString()); 468 } 469 470 471 480 public abstract void destroySubcontext(String name) 481 throws NamingException ; 482 483 484 497 public Context createSubcontext(Name name) 498 throws NamingException { 499 return createSubcontext(name.toString()); 500 } 501 502 503 513 public Context createSubcontext(String name) 514 throws NamingException { 515 return createSubcontext(name, null); 516 } 517 518 519 529 public Object lookupLink(Name name) 530 throws NamingException { 531 return lookupLink(name.toString()); 532 } 533 534 535 544 public abstract Object lookupLink(String name) 545 throws NamingException ; 546 547 548 562 public NameParser getNameParser(Name name) 563 throws NamingException { 564 return new NameParserImpl(); 565 } 566 567 568 576 public NameParser getNameParser(String name) 577 throws NamingException { 578 return new NameParserImpl(); 579 } 580 581 582 597 public Name composeName(Name name, Name prefix) 598 throws NamingException { 599 prefix = (Name ) prefix.clone(); 600 return prefix.addAll(name); 601 } 602 603 604 612 public String composeName(String name, String prefix) 613 throws NamingException { 614 return prefix + "/" + name; 615 } 616 617 618 627 public Object addToEnvironment(String propName, Object propVal) 628 throws NamingException { 629 return env.put(propName, propVal); 630 } 631 632 633 640 public Object removeFromEnvironment(String propName) 641 throws NamingException { 642 return env.remove(propName); 643 } 644 645 646 656 public Hashtable getEnvironment() 657 throws NamingException { 658 return env; 659 } 660 661 662 672 public void close() 673 throws NamingException { 674 env.clear(); 675 } 676 677 678 695 public abstract String getNameInNamespace() 696 throws NamingException ; 697 698 699 701 702 710 public Attributes getAttributes(Name name) 711 throws NamingException { 712 return getAttributes(name.toString()); 713 } 714 715 716 723 public Attributes getAttributes(String name) 724 throws NamingException { 725 return getAttributes(name, null); 726 } 727 728 729 741 public Attributes getAttributes(Name name, String [] attrIds) 742 throws NamingException { 743 return getAttributes(name.toString(), attrIds); 744 } 745 746 747 757 public abstract Attributes getAttributes(String name, String [] attrIds) 758 throws NamingException ; 759 760 761 775 public void modifyAttributes(Name name, int mod_op, Attributes attrs) 776 throws NamingException { 777 modifyAttributes(name.toString(), mod_op, attrs); 778 } 779 780 781 793 public abstract void modifyAttributes 794 (String name, int mod_op, Attributes attrs) 795 throws NamingException ; 796 797 798 812 public void modifyAttributes(Name name, ModificationItem [] mods) 813 throws NamingException { 814 modifyAttributes(name.toString(), mods); 815 } 816 817 818 829 public abstract void modifyAttributes(String name, ModificationItem [] mods) 830 throws NamingException ; 831 832 833 848 public void bind(Name name, Object obj, Attributes attrs) 849 throws NamingException { 850 bind(name.toString(), obj, attrs); 851 } 852 853 854 865 public abstract void bind(String name, Object obj, Attributes attrs) 866 throws NamingException ; 867 868 869 887 public void rebind(Name name, Object obj, Attributes attrs) 888 throws NamingException { 889 rebind(name.toString(), obj, attrs); 890 } 891 892 893 904 public abstract void rebind(String name, Object obj, Attributes attrs) 905 throws NamingException ; 906 907 908 925 public DirContext createSubcontext(Name name, Attributes attrs) 926 throws NamingException { 927 return createSubcontext(name.toString(), attrs); 928 } 929 930 931 942 public abstract DirContext createSubcontext(String name, Attributes attrs) 943 throws NamingException ; 944 945 946 959 public DirContext getSchema(Name name) 960 throws NamingException { 961 return getSchema(name.toString()); 962 } 963 964 965 973 public abstract DirContext getSchema(String name) 974 throws NamingException ; 975 976 977 988 public DirContext getSchemaClassDefinition(Name name) 989 throws NamingException { 990 return getSchemaClassDefinition(name.toString()); 991 } 992 993 994 1005 public abstract DirContext getSchemaClassDefinition(String name) 1006 throws NamingException ; 1007 1008 1009 1026 public NamingEnumeration search(Name name, Attributes matchingAttributes, 1027 String [] attributesToReturn) 1028 throws NamingException { 1029 return search(name.toString(), matchingAttributes, attributesToReturn); 1030 } 1031 1032 1033 1049 public abstract NamingEnumeration search 1050 (String name, Attributes matchingAttributes, 1051 String [] attributesToReturn) 1052 throws NamingException ; 1053 1054 1055 1070 public NamingEnumeration search(Name name, Attributes matchingAttributes) 1071 throws NamingException { 1072 return search(name.toString(), matchingAttributes); 1073 } 1074 1075 1076 1089 public abstract NamingEnumeration search 1090 (String name, Attributes matchingAttributes) 1091 throws NamingException ; 1092 1093 1094 1113 public NamingEnumeration search 1114 (Name name, String filter, SearchControls cons) 1115 throws NamingException { 1116 return search(name.toString(), filter, cons); 1117 } 1118 1119 1120 1139 public abstract NamingEnumeration search(String name, String filter, 1140 SearchControls cons) 1141 throws NamingException ; 1142 1143 1144 1168 public NamingEnumeration search(Name name, String filterExpr, 1169 Object [] filterArgs, SearchControls cons) 1170 throws NamingException { 1171 return search(name.toString(), filterExpr, filterArgs, cons); 1172 } 1173 1174 1175 1199 public abstract NamingEnumeration search 1200 (String name, String filterExpr, 1201 Object [] filterArgs, SearchControls cons) 1202 throws NamingException ; 1203 1204 1205 1207 1208} 1209 1210 | Popular Tags |