src/share/classes/com/sun/jndi/toolkit/ctx/AtomicDirContext.java

Print this page




  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 


  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


 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


 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 


 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);


  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 
  31 /**
  32  * Direct subclasses of AtomicDirContext must provide implementations for
  33  * the abstract a_ DirContext methods, and override the a_ Context methods
  34  * (which are no longer abstract because they have been overriden by
  35  * PartialCompositeDirContext with dummy implementations).
  36  *
  37  * If the subclass implements the notion of implicit nns,
  38  * it must override the a_*_nns DirContext and Context methods as well.
  39  *
  40  * @author Rosanna Lee
  41  *
  42  */
  43 
  44 public abstract class AtomicDirContext extends ComponentDirContext {
  45 
  46     protected AtomicDirContext() {
  47         _contextType = _ATOMIC;
  48     }
  49 


  61     protected abstract void a_modifyAttributes(String name,
  62                                                ModificationItem[] mods,
  63                                                Continuation cont)
  64         throws NamingException;
  65 
  66     protected abstract void a_bind(String name, Object obj,
  67                                    Attributes attrs,
  68                                    Continuation cont)
  69         throws NamingException;
  70 
  71     protected abstract void a_rebind(String name, Object obj,
  72                                      Attributes attrs,
  73                                      Continuation cont)
  74         throws NamingException;
  75 
  76     protected abstract DirContext a_createSubcontext(String name,
  77                                                     Attributes attrs,
  78                                                     Continuation cont)
  79         throws NamingException;
  80 
  81     protected abstract NamingEnumeration<SearchResult> a_search(
  82                                                   Attributes matchingAttributes,
  83                                                   String[] attributesToReturn,
  84                                                   Continuation cont)
  85         throws NamingException;
  86 
  87     protected abstract NamingEnumeration<SearchResult> a_search(
  88                                                   String name,
  89                                                   String filterExpr,
  90                                                   Object[] filterArgs,
  91                                                   SearchControls cons,
  92                                                   Continuation cont)
  93         throws NamingException;
  94 
  95     protected abstract NamingEnumeration<SearchResult> a_search(
  96                                                   String name,
  97                                                   String filter,
  98                                                   SearchControls cons,
  99                                                   Continuation cont)
 100         throws NamingException;
 101 
 102     protected abstract DirContext a_getSchema(Continuation cont)
 103         throws NamingException;
 104 
 105     protected abstract DirContext a_getSchemaClassDefinition(Continuation cont)
 106         throws NamingException;
 107 
 108 // ------ Methods that need to be overridden by subclass
 109 
 110     //  default implementations of a_*_nns methods
 111 
 112     // The following methods are called when the DirContext methods
 113     // are invoked with a name that has a trailing slash.
 114     // For naming systems that support implicit nns,
 115     // the trailing slash signifies the implicit nns.
 116     // For such naming systems, override these a_*_nns methods.
 117     //
 118     // For naming systems that support junctions (explicit nns),
 119     // the trailing slash is meaningless because a junction does not


 150                               Continuation cont)
 151         throws NamingException  {
 152             a_processJunction_nns(name, cont);
 153         }
 154 
 155     protected void a_rebind_nns(String name, Object obj,
 156                                 Attributes attrs,
 157                                 Continuation cont)
 158         throws NamingException  {
 159             a_processJunction_nns(name, cont);
 160         }
 161 
 162     protected DirContext a_createSubcontext_nns(String name,
 163                                                Attributes attrs,
 164                                                Continuation cont)
 165         throws NamingException  {
 166             a_processJunction_nns(name, cont);
 167             return null;
 168         }
 169 
 170     protected NamingEnumeration<SearchResult> a_search_nns(
 171                                              Attributes matchingAttributes,
 172                                              String[] attributesToReturn,
 173                                              Continuation cont)
 174         throws NamingException {
 175             a_processJunction_nns(cont);
 176             return null;
 177         }
 178 
 179     protected NamingEnumeration<SearchResult> a_search_nns(String name,
 180                                                            String filterExpr,
 181                                                            Object[] filterArgs,
 182                                                            SearchControls cons,
 183                                                            Continuation cont)
 184         throws NamingException {
 185             a_processJunction_nns(name, cont);
 186             return null;
 187         }
 188 
 189     protected NamingEnumeration<SearchResult> a_search_nns(String name,
 190                                                            String filter,
 191                                                            SearchControls cons,
 192                                                            Continuation cont)
 193         throws NamingException  {
 194             a_processJunction_nns(name, cont);
 195             return null;
 196         }
 197 
 198     protected DirContext a_getSchema_nns(Continuation cont) throws NamingException {
 199         a_processJunction_nns(cont);
 200         return null;
 201     }
 202 
 203     protected DirContext a_getSchemaDefinition_nns(Continuation cont)
 204         throws NamingException {
 205             a_processJunction_nns(cont);
 206             return null;
 207         }
 208 
 209 // ------- implementations of c_ DirContext methods using corresponding


 238                 a_bind(name.toString(), obj, attrs, cont);
 239         }
 240 
 241     protected void c_rebind(Name name, Object obj,
 242                             Attributes attrs, Continuation cont)
 243         throws NamingException  {
 244             if (resolve_to_penultimate_context(name, cont))
 245                 a_rebind(name.toString(), obj, attrs, cont);
 246         }
 247 
 248     protected DirContext c_createSubcontext(Name name,
 249                                            Attributes attrs,
 250                                            Continuation cont)
 251         throws NamingException  {
 252             if (resolve_to_penultimate_context(name, cont))
 253                 return a_createSubcontext(name.toString(),
 254                                           attrs, cont);
 255             return null;
 256         }
 257 
 258     protected NamingEnumeration<SearchResult> c_search(Name name,
 259                                          Attributes matchingAttributes,
 260                                          String[] attributesToReturn,
 261                                          Continuation cont)
 262         throws NamingException  {
 263             if (resolve_to_context(name, cont))
 264                 return a_search(matchingAttributes, attributesToReturn, cont);
 265             return null;
 266         }
 267 
 268     protected NamingEnumeration<SearchResult> c_search(Name name,
 269                                                        String filter,
 270                                                        SearchControls cons,
 271                                                        Continuation cont)
 272         throws NamingException {
 273             if (resolve_to_penultimate_context(name, cont))
 274                 return a_search(name.toString(), filter, cons, cont);
 275             return null;
 276         }
 277 
 278     protected NamingEnumeration<SearchResult> c_search(Name name,
 279                                                        String filterExpr,
 280                                                        Object[] filterArgs,
 281                                                        SearchControls cons,
 282                                                        Continuation cont)
 283         throws NamingException  {
 284             if (resolve_to_penultimate_context(name, cont))
 285                 return a_search(name.toString(), filterExpr, filterArgs, cons, cont);
 286             return null;
 287         }
 288 
 289     protected DirContext c_getSchema(Name name, Continuation cont)
 290         throws NamingException  {
 291             if (resolve_to_context(name, cont))
 292                 return a_getSchema(cont);
 293             return null;
 294         }
 295 
 296     protected DirContext c_getSchemaClassDefinition(Name name, Continuation cont)
 297         throws NamingException  {
 298             if (resolve_to_context(name, cont))
 299                 return a_getSchemaClassDefinition(cont);
 300             return null;
 301         }
 302 


 330             if (resolve_to_penultimate_context_nns(name, cont))
 331                 a_bind_nns(name.toString(), obj, attrs, cont);
 332         }
 333 
 334     protected void c_rebind_nns(Name name, Object obj,
 335                                 Attributes attrs, Continuation cont)
 336         throws NamingException  {
 337             if (resolve_to_penultimate_context_nns(name, cont))
 338                 a_rebind_nns(name.toString(), obj, attrs, cont);
 339         }
 340 
 341     protected DirContext c_createSubcontext_nns(Name name,
 342                                                Attributes attrs,
 343                                                Continuation cont)
 344         throws NamingException  {
 345             if (resolve_to_penultimate_context_nns(name, cont))
 346                 return a_createSubcontext_nns(name.toString(), attrs, cont);
 347             return null;
 348         }
 349 
 350     protected NamingEnumeration<SearchResult> c_search_nns(
 351                                          Name name,
 352                                          Attributes matchingAttributes,
 353                                          String[] attributesToReturn,
 354                                          Continuation cont)
 355         throws NamingException  {
 356             resolve_to_nns_and_continue(name, cont);
 357             return null;
 358         }
 359 
 360     protected NamingEnumeration<SearchResult> c_search_nns(Name name,
 361                                                            String filter,
 362                                                            SearchControls cons,
 363                                                            Continuation cont)
 364         throws NamingException {
 365             if (resolve_to_penultimate_context_nns(name, cont))
 366                 return a_search_nns(name.toString(), filter, cons, cont);
 367             return null;
 368         }
 369 
 370     protected NamingEnumeration<SearchResult> c_search_nns(Name name,
 371                                                            String filterExpr,
 372                                                            Object[] filterArgs,
 373                                                            SearchControls cons,
 374                                                            Continuation cont)
 375         throws NamingException  {
 376             if (resolve_to_penultimate_context_nns(name, cont))
 377                 return a_search_nns(name.toString(), filterExpr, filterArgs,
 378                                     cons, cont);
 379             return null;
 380         }
 381 
 382     protected DirContext c_getSchema_nns(Name name, Continuation cont)
 383         throws NamingException  {
 384             resolve_to_nns_and_continue(name, cont);
 385             return null;
 386         }
 387 
 388     protected DirContext c_getSchemaClassDefinition_nns(Name name, Continuation cont)
 389         throws NamingException  {
 390             resolve_to_nns_and_continue(name, cont);