1 /* 2 * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.jndi.toolkit.ctx; 27 28 import javax.naming.*; 29 import javax.naming.directory.*; 30 import javax.naming.spi.ResolveResult; 31 32 /** 33 * Direct subclasses of AtomicDirContext must provide implementations for 34 * the abstract a_ DirContext methods, and override the a_ Context methods 35 * (which are no longer abstract because they have been overriden by 36 * PartialCompositeDirContext with dummy implementations). 37 * 38 * If the subclass implements the notion of implicit nns, 39 * it must override the a_*_nns DirContext and Context methods as well. 40 * 41 * @author Rosanna Lee 42 * 43 */ 44 45 public abstract class AtomicDirContext extends ComponentDirContext { 46 47 protected AtomicDirContext() { 48 _contextType = _ATOMIC; 49 } 50 51 // ------ Abstract methods whose implementations come from subclass 52 53 protected abstract Attributes a_getAttributes(String name, String[] attrIds, 54 Continuation cont) 55 throws NamingException; 56 57 protected abstract void a_modifyAttributes(String name, int mod_op, 58 Attributes attrs, 59 Continuation cont) 60 throws NamingException; 61 62 protected abstract void a_modifyAttributes(String name, 63 ModificationItem[] mods, 64 Continuation cont) 65 throws NamingException; 66 67 protected abstract void a_bind(String name, Object obj, 68 Attributes attrs, 69 Continuation cont) 70 throws NamingException; 71 72 protected abstract void a_rebind(String name, Object obj, 73 Attributes attrs, 74 Continuation cont) 75 throws NamingException; 76 77 protected abstract DirContext a_createSubcontext(String name, 78 Attributes attrs, 79 Continuation cont) 80 throws NamingException; 81 82 protected abstract NamingEnumeration a_search(Attributes matchingAttributes, 83 String[] attributesToReturn, 84 Continuation cont) 85 throws NamingException; 86 87 protected abstract NamingEnumeration a_search(String name, 88 String filterExpr, 89 Object[] filterArgs, 90 SearchControls cons, Continuation cont) 91 throws NamingException; 92 93 protected abstract NamingEnumeration a_search(String name, 94 String filter, 95 SearchControls cons, Continuation cont) 96 throws NamingException; 97 98 protected abstract DirContext a_getSchema(Continuation cont) 99 throws NamingException; 100 101 protected abstract DirContext a_getSchemaClassDefinition(Continuation cont) 102 throws NamingException; 103 104 // ------ Methods that need to be overridden by subclass 105 106 // default implementations of a_*_nns methods 107 108 // The following methods are called when the DirContext methods 109 // are invoked with a name that has a trailing slash. 110 // For naming systems that support implicit nns, 111 // the trailing slash signifies the implicit nns. 112 // For such naming systems, override these a_*_nns methods. 113 // 114 // For naming systems that support junctions (explicit nns), 115 // the trailing slash is meaningless because a junction does not 116 // have an implicit nns. The default implementation here 117 // throws a NameNotFoundException for such names. 118 // If a context wants to accept a trailing slash as having 119 // the same meaning as the same name without a trailing slash, 120 // then it should override these a_*_nns methods. 121 122 protected Attributes a_getAttributes_nns(String name, 123 String[] attrIds, 124 Continuation cont) 125 throws NamingException { 126 a_processJunction_nns(name, cont); 127 return null; 128 } 129 130 protected void a_modifyAttributes_nns(String name, int mod_op, 131 Attributes attrs, 132 Continuation cont) 133 throws NamingException { 134 a_processJunction_nns(name, cont); 135 } 136 137 protected void a_modifyAttributes_nns(String name, 138 ModificationItem[] mods, 139 Continuation cont) 140 throws NamingException { 141 a_processJunction_nns(name, cont); 142 } 143 144 protected void a_bind_nns(String name, Object obj, 145 Attributes attrs, 146 Continuation cont) 147 throws NamingException { 148 a_processJunction_nns(name, cont); 149 } 150 151 protected void a_rebind_nns(String name, Object obj, 152 Attributes attrs, 153 Continuation cont) 154 throws NamingException { 155 a_processJunction_nns(name, cont); 156 } 157 158 protected DirContext a_createSubcontext_nns(String name, 159 Attributes attrs, 160 Continuation cont) 161 throws NamingException { 162 a_processJunction_nns(name, cont); 163 return null; 164 } 165 166 protected NamingEnumeration a_search_nns(Attributes matchingAttributes, 167 String[] attributesToReturn, 168 Continuation cont) 169 throws NamingException { 170 a_processJunction_nns(cont); 171 return null; 172 } 173 174 protected NamingEnumeration a_search_nns(String name, 175 String filterExpr, 176 Object[] filterArgs, 177 SearchControls cons, 178 Continuation cont) 179 throws NamingException { 180 a_processJunction_nns(name, cont); 181 return null; 182 } 183 184 protected NamingEnumeration a_search_nns(String name, 185 String filter, 186 SearchControls cons, 187 Continuation cont) 188 throws NamingException { 189 a_processJunction_nns(name, cont); 190 return null; 191 } 192 193 protected DirContext a_getSchema_nns(Continuation cont) throws NamingException { 194 a_processJunction_nns(cont); 195 return null; 196 } 197 198 protected DirContext a_getSchemaDefinition_nns(Continuation cont) 199 throws NamingException { 200 a_processJunction_nns(cont); 201 return null; 202 } 203 204 // ------- implementations of c_ DirContext methods using corresponding 205 // ------- a_ and a_*_nns methods 206 207 protected Attributes c_getAttributes(Name name, String[] attrIds, 208 Continuation cont) 209 throws NamingException { 210 if (resolve_to_penultimate_context(name, cont)) 211 return a_getAttributes(name.toString(), attrIds, cont); 212 return null; 213 } 214 215 protected void c_modifyAttributes(Name name, int mod_op, 216 Attributes attrs, Continuation cont) 217 throws NamingException { 218 if (resolve_to_penultimate_context(name, cont)) 219 a_modifyAttributes(name.toString(), mod_op, attrs, cont); 220 } 221 222 protected void c_modifyAttributes(Name name, ModificationItem[] mods, 223 Continuation cont) 224 throws NamingException { 225 if (resolve_to_penultimate_context(name, cont)) 226 a_modifyAttributes(name.toString(), mods, cont); 227 } 228 229 protected void c_bind(Name name, Object obj, 230 Attributes attrs, Continuation cont) 231 throws NamingException { 232 if (resolve_to_penultimate_context(name, cont)) 233 a_bind(name.toString(), obj, attrs, cont); 234 } 235 236 protected void c_rebind(Name name, Object obj, 237 Attributes attrs, Continuation cont) 238 throws NamingException { 239 if (resolve_to_penultimate_context(name, cont)) 240 a_rebind(name.toString(), obj, attrs, cont); 241 } 242 243 protected DirContext c_createSubcontext(Name name, 244 Attributes attrs, 245 Continuation cont) 246 throws NamingException { 247 if (resolve_to_penultimate_context(name, cont)) 248 return a_createSubcontext(name.toString(), 249 attrs, cont); 250 return null; 251 } 252 253 protected NamingEnumeration c_search(Name name, 254 Attributes matchingAttributes, 255 String[] attributesToReturn, 256 Continuation cont) 257 throws NamingException { 258 if (resolve_to_context(name, cont)) 259 return a_search(matchingAttributes, attributesToReturn, cont); 260 return null; 261 } 262 263 protected NamingEnumeration c_search(Name name, 264 String filter, 265 SearchControls cons, Continuation cont) 266 throws NamingException { 267 if (resolve_to_penultimate_context(name, cont)) 268 return a_search(name.toString(), filter, cons, cont); 269 return null; 270 } 271 272 protected NamingEnumeration c_search(Name name, 273 String filterExpr, 274 Object[] filterArgs, 275 SearchControls cons, Continuation cont) 276 throws NamingException { 277 if (resolve_to_penultimate_context(name, cont)) 278 return a_search(name.toString(), filterExpr, filterArgs, cons, cont); 279 return null; 280 } 281 282 protected DirContext c_getSchema(Name name, Continuation cont) 283 throws NamingException { 284 if (resolve_to_context(name, cont)) 285 return a_getSchema(cont); 286 return null; 287 } 288 289 protected DirContext c_getSchemaClassDefinition(Name name, Continuation cont) 290 throws NamingException { 291 if (resolve_to_context(name, cont)) 292 return a_getSchemaClassDefinition(cont); 293 return null; 294 } 295 296 /* equivalent to methods in DirContext interface for nns */ 297 298 protected Attributes c_getAttributes_nns(Name name, String[] attrIds, 299 Continuation cont) 300 throws NamingException { 301 if (resolve_to_penultimate_context_nns(name, cont)) 302 return a_getAttributes_nns(name.toString(), attrIds, cont); 303 return null; 304 } 305 306 protected void c_modifyAttributes_nns(Name name, int mod_op, 307 Attributes attrs, Continuation cont) 308 throws NamingException { 309 if (resolve_to_penultimate_context_nns(name, cont)) 310 a_modifyAttributes_nns(name.toString(), mod_op, attrs, cont); 311 } 312 313 protected void c_modifyAttributes_nns(Name name, ModificationItem[] mods, 314 Continuation cont) 315 throws NamingException { 316 if (resolve_to_penultimate_context_nns(name, cont)) 317 a_modifyAttributes_nns(name.toString(), mods, cont); 318 } 319 320 protected void c_bind_nns(Name name, Object obj, 321 Attributes attrs, Continuation cont) 322 throws NamingException { 323 if (resolve_to_penultimate_context_nns(name, cont)) 324 a_bind_nns(name.toString(), obj, attrs, cont); 325 } 326 327 protected void c_rebind_nns(Name name, Object obj, 328 Attributes attrs, Continuation cont) 329 throws NamingException { 330 if (resolve_to_penultimate_context_nns(name, cont)) 331 a_rebind_nns(name.toString(), obj, attrs, cont); 332 } 333 334 protected DirContext c_createSubcontext_nns(Name name, 335 Attributes attrs, 336 Continuation cont) 337 throws NamingException { 338 if (resolve_to_penultimate_context_nns(name, cont)) 339 return a_createSubcontext_nns(name.toString(), attrs, cont); 340 return null; 341 } 342 343 protected NamingEnumeration c_search_nns(Name name, 344 Attributes matchingAttributes, 345 String[] attributesToReturn, 346 Continuation cont) 347 throws NamingException { 348 resolve_to_nns_and_continue(name, cont); 349 return null; 350 } 351 352 protected NamingEnumeration c_search_nns(Name name, 353 String filter, 354 SearchControls cons, Continuation cont) 355 throws NamingException { 356 if (resolve_to_penultimate_context_nns(name, cont)) 357 return a_search_nns(name.toString(), filter, cons, cont); 358 return null; 359 } 360 361 protected NamingEnumeration c_search_nns(Name name, 362 String filterExpr, 363 Object[] filterArgs, 364 SearchControls cons, 365 Continuation cont) 366 throws NamingException { 367 if (resolve_to_penultimate_context_nns(name, cont)) 368 return a_search_nns(name.toString(), filterExpr, filterArgs, 369 cons, cont); 370 return null; 371 } 372 373 protected DirContext c_getSchema_nns(Name name, Continuation cont) 374 throws NamingException { 375 resolve_to_nns_and_continue(name, cont); 376 return null; 377 } 378 379 protected DirContext c_getSchemaClassDefinition_nns(Name name, Continuation cont) 380 throws NamingException { 381 resolve_to_nns_and_continue(name, cont); 382 return null; 383 } 384 }