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

Print this page




  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 import javax.naming.spi.ResolveResult;
  32 
  33 /* Direct subclasses of ComponentDirContext must provide implementations for
  34  * the abstract c_ DirContext methods, and override the c_ Context methods
  35  * (which are no longer abstract because they have been overriden by
  36  * AtomicContext, the direct superclass of PartialDSCompositeContext).
  37  *
  38  * If the subclass is supports implicit nns, it must override all the
  39  * c_*_nns methods corresponding to those in DirContext and Context.
  40  * See ComponentContext for details.
  41  *
  42  * @author Rosanna Lee
  43  */
  44 
  45 public abstract class ComponentDirContext extends PartialCompositeDirContext {
  46 
  47     protected ComponentDirContext () {
  48         _contextType = _COMPONENT;
  49     }
  50 
  51 // ------ Abstract methods whose implementations are provided by subclass
  52 


  64     protected abstract void c_modifyAttributes(Name name,
  65                                             ModificationItem[] mods,
  66                                             Continuation cont)
  67         throws NamingException;
  68 
  69     protected abstract void c_bind(Name name, Object obj,
  70                                    Attributes attrs,
  71                                    Continuation cont)
  72         throws NamingException;
  73 
  74     protected abstract void c_rebind(Name name, Object obj,
  75                                      Attributes attrs,
  76                                      Continuation cont)
  77         throws NamingException;
  78 
  79     protected abstract DirContext c_createSubcontext(Name name,
  80                                                     Attributes attrs,
  81                                                     Continuation cont)
  82         throws NamingException;
  83 
  84     protected abstract NamingEnumeration c_search(Name name,

  85                                                Attributes matchingAttributes,
  86                                                String[] attributesToReturn,
  87                                                Continuation cont)
  88         throws NamingException;
  89 
  90     protected abstract NamingEnumeration c_search(Name name,

  91                                                String filter,
  92                                                SearchControls cons,
  93                                                Continuation cont)
  94         throws NamingException;
  95 
  96     protected abstract NamingEnumeration c_search(Name name,

  97                                                   String filterExpr,
  98                                                   Object[] filterArgs,
  99                                                   SearchControls cons,
 100                                                   Continuation cont)
 101         throws NamingException;
 102 
 103     protected abstract DirContext c_getSchema(Name name, Continuation cont)
 104         throws NamingException;
 105 
 106     protected abstract DirContext c_getSchemaClassDefinition(Name name,
 107                                                             Continuation cont)
 108         throws NamingException;
 109 
 110 // ------- default implementations of c_*_nns methods from DirContext
 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 c_*_nns methods.


 155         throws NamingException  {
 156             c_processJunction_nns(name, cont);
 157         }
 158 
 159     protected void c_rebind_nns(Name name,
 160                                 Object obj,
 161                                 Attributes attrs,
 162                                 Continuation cont)
 163         throws NamingException  {
 164             c_processJunction_nns(name, cont);
 165         }
 166 
 167     protected DirContext c_createSubcontext_nns(Name name,
 168                                                Attributes attrs,
 169                                                Continuation cont)
 170         throws NamingException  {
 171             c_processJunction_nns(name, cont);
 172             return null;
 173         }
 174 
 175     protected NamingEnumeration c_search_nns(Name name,

 176                                           Attributes matchingAttributes,
 177                                           String[] attributesToReturn,
 178                                           Continuation cont)
 179         throws NamingException {
 180             c_processJunction_nns(name, cont);
 181             return null;
 182         }
 183 
 184     protected NamingEnumeration c_search_nns(Name name,

 185                                           String filter,
 186                                           SearchControls cons,
 187                                           Continuation cont)
 188         throws NamingException  {
 189             c_processJunction_nns(name, cont);
 190             return null;
 191         }
 192 
 193     protected NamingEnumeration c_search_nns(Name name,

 194                                              String filterExpr,
 195                                              Object[] filterArgs,
 196                                              SearchControls cons,
 197                                              Continuation cont)
 198         throws NamingException  {
 199             c_processJunction_nns(name, cont);
 200             return null;
 201         }
 202 
 203     protected DirContext c_getSchema_nns(Name name, Continuation cont)
 204         throws NamingException {
 205             c_processJunction_nns(name, cont);
 206             return null;
 207         }
 208 
 209     protected DirContext c_getSchemaClassDefinition_nns(Name name, Continuation cont)
 210         throws NamingException {
 211             c_processJunction_nns(name, cont);
 212             return null;
 213         }


 328         throws NamingException {
 329         HeadTail res = p_resolveIntermediate(name, cont);
 330         DirContext answer = null;
 331         switch (res.getStatus()) {
 332             case TERMINAL_NNS_COMPONENT:
 333                 answer = c_createSubcontext_nns(res.getHead(), attrs, cont);
 334                 break;
 335 
 336             case TERMINAL_COMPONENT:
 337                 answer = c_createSubcontext(res.getHead(), attrs, cont);
 338                 break;
 339 
 340             default:
 341                 /* USE_CONTINUATION */
 342                 /* cont already set or exception thrown */
 343                 break;
 344             }
 345         return answer;
 346     }
 347 
 348     protected NamingEnumeration p_search(Name name,

 349                                       Attributes matchingAttributes,
 350                                       String[] attributesToReturn,
 351                                       Continuation cont)
 352         throws NamingException {
 353         HeadTail res = p_resolveIntermediate(name, cont);
 354         NamingEnumeration answer = null;
 355         switch (res.getStatus()) {
 356             case TERMINAL_NNS_COMPONENT:
 357                 answer = c_search_nns(res.getHead(), matchingAttributes,
 358                                       attributesToReturn, cont);
 359                 break;
 360 
 361             case TERMINAL_COMPONENT:
 362                 answer = c_search(res.getHead(), matchingAttributes,
 363                                   attributesToReturn, cont);
 364                 break;
 365 
 366             default:
 367                 /* USE_CONTINUATION */
 368                 /* cont already set or exception thrown */
 369                 break;
 370             }
 371         return answer;
 372     }
 373 
 374     protected NamingEnumeration p_search(Name name,
 375                                       String filter,
 376                                       SearchControls cons, Continuation cont)

 377         throws NamingException {
 378         HeadTail res = p_resolveIntermediate(name, cont);
 379         NamingEnumeration answer = null;
 380         switch (res.getStatus()) {
 381             case TERMINAL_NNS_COMPONENT:
 382                 answer = c_search_nns(res.getHead(), filter, cons, cont);
 383                 break;
 384 
 385             case TERMINAL_COMPONENT:
 386                 answer = c_search(res.getHead(), filter, cons, cont);
 387                 break;
 388 
 389             default:
 390                 /* USE_CONTINUATION */
 391                 /* cont already set or exception thrown */
 392                 break;
 393             }
 394         return answer;
 395     }
 396 
 397     protected NamingEnumeration p_search(Name name,
 398                                          String filterExpr,
 399                                          Object[] filterArgs,
 400                                          SearchControls cons,
 401                                          Continuation cont)
 402             throws NamingException {
 403         HeadTail res = p_resolveIntermediate(name, cont);
 404         NamingEnumeration answer = null;
 405         switch (res.getStatus()) {
 406             case TERMINAL_NNS_COMPONENT:
 407                 answer = c_search_nns(res.getHead(),
 408                                       filterExpr, filterArgs, cons, cont);
 409                 break;
 410 
 411             case TERMINAL_COMPONENT:
 412                 answer = c_search(res.getHead(), filterExpr, filterArgs, cons, cont);
 413                 break;
 414 
 415             default:
 416                 /* USE_CONTINUATION */
 417                 /* cont already set or exception thrown */
 418                 break;
 419             }
 420         return answer;
 421     }
 422 
 423     protected DirContext p_getSchema(Name name, Continuation cont)
 424         throws NamingException  {




  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 /* Direct subclasses of ComponentDirContext must provide implementations for
  32  * the abstract c_ DirContext methods, and override the c_ Context methods
  33  * (which are no longer abstract because they have been overriden by
  34  * AtomicContext, the direct superclass of PartialDSCompositeContext).
  35  *
  36  * If the subclass is supports implicit nns, it must override all the
  37  * c_*_nns methods corresponding to those in DirContext and Context.
  38  * See ComponentContext for details.
  39  *
  40  * @author Rosanna Lee
  41  */
  42 
  43 public abstract class ComponentDirContext extends PartialCompositeDirContext {
  44 
  45     protected ComponentDirContext () {
  46         _contextType = _COMPONENT;
  47     }
  48 
  49 // ------ Abstract methods whose implementations are provided by subclass
  50 


  62     protected abstract void c_modifyAttributes(Name name,
  63                                             ModificationItem[] mods,
  64                                             Continuation cont)
  65         throws NamingException;
  66 
  67     protected abstract void c_bind(Name name, Object obj,
  68                                    Attributes attrs,
  69                                    Continuation cont)
  70         throws NamingException;
  71 
  72     protected abstract void c_rebind(Name name, Object obj,
  73                                      Attributes attrs,
  74                                      Continuation cont)
  75         throws NamingException;
  76 
  77     protected abstract DirContext c_createSubcontext(Name name,
  78                                                     Attributes attrs,
  79                                                     Continuation cont)
  80         throws NamingException;
  81 
  82     protected abstract NamingEnumeration<SearchResult> c_search(
  83                             Name name,
  84                             Attributes matchingAttributes,
  85                             String[] attributesToReturn,
  86                             Continuation cont)
  87         throws NamingException;
  88 
  89     protected abstract NamingEnumeration<SearchResult> c_search(
  90                             Name name,
  91                             String filter,
  92                             SearchControls cons,
  93                             Continuation cont)
  94         throws NamingException;
  95 
  96     protected abstract NamingEnumeration<SearchResult> c_search(
  97                             Name name,
  98                             String filterExpr,
  99                             Object[] filterArgs,
 100                             SearchControls cons,
 101                             Continuation cont)
 102         throws NamingException;
 103 
 104     protected abstract DirContext c_getSchema(Name name, Continuation cont)
 105         throws NamingException;
 106 
 107     protected abstract DirContext c_getSchemaClassDefinition(Name name,
 108                                                             Continuation cont)
 109         throws NamingException;
 110 
 111 // ------- default implementations of c_*_nns methods from DirContext
 112 
 113     // The following methods are called when the DirContext methods
 114     // are invoked with a name that has a trailing slash.
 115     // For naming systems that support implicit nns,
 116     // the trailing slash signifies the implicit nns.
 117     // For such naming systems, override these c_*_nns methods.


 156         throws NamingException  {
 157             c_processJunction_nns(name, cont);
 158         }
 159 
 160     protected void c_rebind_nns(Name name,
 161                                 Object obj,
 162                                 Attributes attrs,
 163                                 Continuation cont)
 164         throws NamingException  {
 165             c_processJunction_nns(name, cont);
 166         }
 167 
 168     protected DirContext c_createSubcontext_nns(Name name,
 169                                                Attributes attrs,
 170                                                Continuation cont)
 171         throws NamingException  {
 172             c_processJunction_nns(name, cont);
 173             return null;
 174         }
 175 
 176     protected NamingEnumeration<SearchResult> c_search_nns(
 177                         Name name,
 178                         Attributes matchingAttributes,
 179                         String[] attributesToReturn,
 180                         Continuation cont)
 181         throws NamingException {
 182             c_processJunction_nns(name, cont);
 183             return null;
 184         }
 185 
 186     protected NamingEnumeration<SearchResult> c_search_nns(
 187                         Name name,
 188                         String filter,
 189                         SearchControls cons,
 190                         Continuation cont)
 191         throws NamingException  {
 192             c_processJunction_nns(name, cont);
 193             return null;
 194         }
 195 
 196     protected NamingEnumeration<SearchResult> c_search_nns(
 197                         Name name,
 198                         String filterExpr,
 199                         Object[] filterArgs,
 200                         SearchControls cons,
 201                         Continuation cont)
 202         throws NamingException  {
 203             c_processJunction_nns(name, cont);
 204             return null;
 205         }
 206 
 207     protected DirContext c_getSchema_nns(Name name, Continuation cont)
 208         throws NamingException {
 209             c_processJunction_nns(name, cont);
 210             return null;
 211         }
 212 
 213     protected DirContext c_getSchemaClassDefinition_nns(Name name, Continuation cont)
 214         throws NamingException {
 215             c_processJunction_nns(name, cont);
 216             return null;
 217         }


 332         throws NamingException {
 333         HeadTail res = p_resolveIntermediate(name, cont);
 334         DirContext answer = null;
 335         switch (res.getStatus()) {
 336             case TERMINAL_NNS_COMPONENT:
 337                 answer = c_createSubcontext_nns(res.getHead(), attrs, cont);
 338                 break;
 339 
 340             case TERMINAL_COMPONENT:
 341                 answer = c_createSubcontext(res.getHead(), attrs, cont);
 342                 break;
 343 
 344             default:
 345                 /* USE_CONTINUATION */
 346                 /* cont already set or exception thrown */
 347                 break;
 348             }
 349         return answer;
 350     }
 351 
 352     protected NamingEnumeration<SearchResult> p_search(
 353                     Name name,
 354                     Attributes matchingAttributes,
 355                     String[] attributesToReturn,
 356                     Continuation cont)
 357         throws NamingException {
 358         HeadTail res = p_resolveIntermediate(name, cont);
 359         NamingEnumeration<SearchResult> answer = null;
 360         switch (res.getStatus()) {
 361             case TERMINAL_NNS_COMPONENT:
 362                 answer = c_search_nns(res.getHead(), matchingAttributes,
 363                                       attributesToReturn, cont);
 364                 break;
 365 
 366             case TERMINAL_COMPONENT:
 367                 answer = c_search(res.getHead(), matchingAttributes,
 368                                   attributesToReturn, cont);
 369                 break;
 370 
 371             default:
 372                 /* USE_CONTINUATION */
 373                 /* cont already set or exception thrown */
 374                 break;
 375             }
 376         return answer;
 377     }
 378 
 379     protected NamingEnumeration<SearchResult> p_search(Name name,
 380                                                        String filter,
 381                                                        SearchControls cons,
 382                                                        Continuation cont)
 383         throws NamingException {
 384         HeadTail res = p_resolveIntermediate(name, cont);
 385         NamingEnumeration<SearchResult> answer = null;
 386         switch (res.getStatus()) {
 387             case TERMINAL_NNS_COMPONENT:
 388                 answer = c_search_nns(res.getHead(), filter, cons, cont);
 389                 break;
 390 
 391             case TERMINAL_COMPONENT:
 392                 answer = c_search(res.getHead(), filter, cons, cont);
 393                 break;
 394 
 395             default:
 396                 /* USE_CONTINUATION */
 397                 /* cont already set or exception thrown */
 398                 break;
 399             }
 400         return answer;
 401     }
 402 
 403     protected NamingEnumeration<SearchResult> p_search(Name name,
 404                                                        String filterExpr,
 405                                                        Object[] filterArgs,
 406                                                        SearchControls cons,
 407                                                        Continuation cont)
 408             throws NamingException {
 409         HeadTail res = p_resolveIntermediate(name, cont);
 410         NamingEnumeration<SearchResult> answer = null;
 411         switch (res.getStatus()) {
 412             case TERMINAL_NNS_COMPONENT:
 413                 answer = c_search_nns(res.getHead(),
 414                                       filterExpr, filterArgs, cons, cont);
 415                 break;
 416 
 417             case TERMINAL_COMPONENT:
 418                 answer = c_search(res.getHead(), filterExpr, filterArgs, cons, cont);
 419                 break;
 420 
 421             default:
 422                 /* USE_CONTINUATION */
 423                 /* cont already set or exception thrown */
 424                 break;
 425             }
 426         return answer;
 427     }
 428 
 429     protected DirContext p_getSchema(Name name, Continuation cont)
 430         throws NamingException  {