src/java.naming/share/classes/com/sun/jndi/toolkit/ctx/ComponentContext.java
author rriggs
Fri, 07 Dec 2018 11:51:17 -0500
changeset 52902 e3398b2e1ab0
parent 47216 71c04702a3d5
permissions -rw-r--r--
8214971: Replace use of string.equals("") with isEmpty() Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jndi.toolkit.ctx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.naming.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.naming.spi.ResolveResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  * Provides implementation of p_* operations using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * c_* operations provided by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  * Clients: deal only with names for its own naming service.  Must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  * provide implementations for c_* methods, and for p_parseComponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  * and the c_*_nns methods if the defaults are not appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public abstract class ComponentContext extends PartialCompositeContext {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static int debug = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    protected ComponentContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        _contextType = _COMPONENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
// ------ Abstract methods whose implementation are provided by subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /* Equivalent methods in Context interface */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    protected abstract Object c_lookup(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected abstract Object c_lookupLink(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    58
    protected abstract NamingEnumeration<NameClassPair> c_list(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        Continuation cont) throws NamingException;
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    60
    protected abstract NamingEnumeration<Binding> c_listBindings(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    protected abstract void c_bind(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected abstract void c_rebind(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected abstract void c_unbind(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected abstract void c_destroySubcontext(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected abstract Context c_createSubcontext(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    protected abstract void c_rename(Name oldname, Name newname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    protected abstract NameParser c_getNameParser(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
// ------ Methods that may need to be overridden by subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /* Parsing method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
      * Determines which of the first components of 'name' belong
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      * to this naming system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      * If no components belong to this naming system, return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      * the empty name (new CompositeName()) as the head,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      * and the entire name as the tail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
      * The default implementation supports strong separation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
      * If the name is empty or if the first component is empty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
      * head is the empty name and tail is the entire name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      * (This means that this context does not have any name to work with).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      * Otherwise, it returns the first component as head, and the rest of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      * the components as tail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      * Subclass should override this method according its own policies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      * For example, a weakly separated system with dynamic boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      * determination would simply return as head 'name'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      * A weakly separated with static boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      * determination would select the components in the front of 'name'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      * that conform to some syntax rules.  (e.g. in X.500 syntax, perhaps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
      * select front components that have a equal sign).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      * If none conforms, return an empty name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    protected HeadTail p_parseComponent(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        int separator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        // if no name to parse, or if we're already at boundary
52902
e3398b2e1ab0 8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents: 47216
diff changeset
   108
        if (name.isEmpty() ||  name.get(0).isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            separator = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            separator = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        Name head, tail;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if (name instanceof CompositeName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            head = name.getPrefix(separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            tail = name.getSuffix(separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            // treat like compound name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            head = new CompositeName().add(name.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            tail = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (debug > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            System.err.println("ORIG: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            System.err.println("PREFIX: " + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            System.err.println("SUFFIX: " + null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return new HeadTail(head, tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /* Resolution method for supporting federation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      * Resolves the nns for 'name' when the named context is acting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
      * as an intermediate context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
      * For a system that supports only junctions, this would be
25808
e113d0a0fde0 8054158: Fix typos in JNDI-related packages
prappo
parents: 10324
diff changeset
   140
      * equivalent to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      *         c_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      * because for junctions, an intermediate slash simply signifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
      * a syntactic separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
      * For a system that supports only implicit nns, this would be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
      * equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      *         c_lookup_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
      * because for implicit nns, a slash always signifies the implicit nns,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      * regardless of whether it is intermediate or trailing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
      * By default this method supports junctions, and also allows for an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
      * implicit nns to be dynamically determined through the use of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
      * "nns" reference (see c_processJunction_nns()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
      * Contexts that implement implicit nns directly should provide an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
      * appropriate override.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
      * A junction, by definition, is a binding of a name in one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
      * namespace to an object in another.  The default implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
      * of this method detects the crossover into another namespace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
      * using the following heuristic:  there is a junction when "name"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
      * resolves to a context that is not an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
      * this.getClass().  Contexts supporting junctions for which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
      * heuristic is inappropriate should override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    protected Object c_resolveIntermediate_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                final Object obj = c_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                // Do not append "" to Continuation 'cont' even if set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                // because the intention is to ignore the nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                if (obj != null && getClass().isInstance(obj)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    // If "obj" is in the same type as this object, it must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    // not be a junction. Continue the lookup with "/".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    cont.setContinueNNS(obj, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                } else if (obj != null && !(obj instanceof Context)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    // obj is not even a context, so try to find its nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    // dynamically by constructing a Reference containing obj.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    RefAddr addr = new RefAddr("nns") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                        public Object getContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                            return obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        private static final long serialVersionUID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                            -8831204798861786362L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    Reference ref = new Reference("java.lang.Object", addr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    // Resolved name has trailing slash to indicate nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    CompositeName resName = (CompositeName)name.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    resName.add(""); // add trailing slash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    // Set continuation leave it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    // PartialCompositeContext.getPCContext() to throw CPE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    // Do not use setContinueNNS() because we've already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    // consumed "/" (i.e., moved it to resName).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    cont.setContinue(ref, resName, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    // Consume "/" and continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    return obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                e.appendRemainingComponent(""); // add nns back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /* Equivalent of Context Methods for supporting nns */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    // The following methods are called when the Context methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    // are invoked with a name that has a trailing slash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    // For naming systems that support implicit nns,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    // the trailing slash signifies the implicit nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    // For such naming systems, override these c_*_nns methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    // For naming systems that do not support implicit nns, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    // default implementations here throw an exception.  See
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    // c_processJunction_nns() for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    protected Object c_lookup_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    protected Object c_lookupLink_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   238
    protected NamingEnumeration<NameClassPair> c_list_nns(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   244
    protected NamingEnumeration<Binding> c_listBindings_nns(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    protected void c_bind_nns(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    protected void c_rebind_nns(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    protected void c_unbind_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    protected Context c_createSubcontext_nns(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    protected void c_destroySubcontext_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    protected void c_rename_nns(Name oldname, Name newname, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            c_processJunction_nns(oldname, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    protected NameParser c_getNameParser_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            c_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
// ------ internal method used by ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Locates the nns using the default policy.  This policy fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * handles junctions, but otherwise throws an exception when an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * attempt is made to resolve an implicit nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * The default policy is as follows:  If there is a junction in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * the namespace, then resolve to the junction and continue the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * operation there (thus deferring to that context to find its own
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * nns).  Otherwise, resolve as far as possible and then throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * CannotProceedException with the resolved object being a reference:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * the address type is "nns", and the address contents is this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * For example, when c_bind_nns(name, obj, ...) is invoked, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * caller is attempting to bind the object "obj" to the nns of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * "name".  If "name" is a junction, it names an object in another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * naming system that (presumably) has an nns.  c_bind_nns() will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * first resolve "name" to a context and then attempt to continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * the bind operation there, (thus binding to the nns of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * context named by "name").  If "name" is empty then throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * exception, since this context does not by default support an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * implicit nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * To implement a context that does support an implicit nns, it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * necessary to override this default policy.  This is done by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * overriding the c_*_nns() methods (which each call this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * by default).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    protected void c_processJunction_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            throws NamingException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        if (name.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            // Construct a new Reference that contains this context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            RefAddr addr = new RefAddr("nns") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                public Object getContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    return ComponentContext.this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                private static final long serialVersionUID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    -1389472957988053402L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            Reference ref = new Reference("java.lang.Object", addr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            // Set continuation leave it to PartialCompositeContext.getPCContext()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            // to throw the exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            // Do not use setContinueNNS() because we've are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            // setting relativeResolvedName to "/".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            cont.setContinue(ref, _NNS_NAME, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            // lookup name to continue operation in nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            Object target = c_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            if (cont.isContinue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                cont.appendRemainingComponent("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                cont.setContinueNNS(target, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            e.appendRemainingComponent(""); // add nns back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    protected static final byte USE_CONTINUATION = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    protected static final byte TERMINAL_COMPONENT = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    protected static final byte TERMINAL_NNS_COMPONENT = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
      * Determine whether 'name' is a terminal component in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
      * this naming system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
      * If so, return status indicating so, so that caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
      * can perform context operation on this name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
      * If not, then the first component(s) of 'name' names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
      * an intermediate context.  In that case, resolve these components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
      * and set Continuation to be the object named.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
      * see test cases at bottom of file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    protected HeadTail p_resolveIntermediate(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        int ret = USE_CONTINUATION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        cont.setSuccess();      // initialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        HeadTail p = p_parseComponent(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        Name tail = p.getTail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        Name head = p.getHead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (tail == null || tail.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
//System.out.println("terminal : " + head);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            ret = TERMINAL_COMPONENT;
52902
e3398b2e1ab0 8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents: 47216
diff changeset
   382
        } else if (!tail.get(0).isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            // tail does not begin with "/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            if (head.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                // Context could not find name that it can use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                // illegal syntax error or name not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
//System.out.println("nnf exception : " + head);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                NamingException e = new NameNotFoundException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                cont.setError(this, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                throw cont.fillInException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            } else  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                // head is being used as intermediate context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                // resolve head and set Continuation with tail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    Object obj = c_resolveIntermediate_nns(head, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
//System.out.println("resInter : " + head + "=" + obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                    if (obj != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                        cont.setContinue(obj, head, this, tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    else if (cont.isContinue()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                        checkAndAdjustRemainingName(cont.getRemainingName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                        cont.appendRemainingName(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    checkAndAdjustRemainingName(e.getRemainingName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                    e.appendRemainingName(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                    throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            // tail begins with "/"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            if (tail.size() == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                ret = TERMINAL_NNS_COMPONENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
//System.out.println("terminal_nns : " + head);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            } else if (head.isEmpty() || isAllEmpty(tail)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                // resolve nns of head and continue with tail.getSuffix(1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                Name newTail = tail.getSuffix(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                    Object obj = c_lookup_nns(head, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
//System.out.println("lookup_nns : " + head + "=" + obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                    if (obj != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        cont.setContinue(obj, head, this, newTail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                    else if (cont.isContinue()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                        cont.appendRemainingName(newTail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
//                      Name rname = cont.getRemainingName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
//System.out.println("cont.rname" + rname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                    e.appendRemainingName(newTail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                    throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                // head is being used as intermediate context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                // resolve and set continuation to tail
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    Object obj = c_resolveIntermediate_nns(head, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
//System.out.println("resInter2 : " + head + "=" + obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    if (obj != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                        cont.setContinue(obj, head, this, tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                    else if (cont.isContinue()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        checkAndAdjustRemainingName(cont.getRemainingName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                        cont.appendRemainingName(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    checkAndAdjustRemainingName(e.getRemainingName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    e.appendRemainingName(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        p.setStatus(ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    // When c_resolveIntermediate_nns() or c_lookup_nns() sets up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    // its continuation, to indicate "nns", it appends an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    // component to the remaining name (e.g. "eng/"). If last
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    // component of remaining name is empty; delete empty component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    // before appending tail so that composition of the names work
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    // correctly. For example, when merging "eng/" and "c.b.a", we want
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    // the result to be "eng/c.b.a" because the trailing slash in eng
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    // is extraneous.  When merging "" and "c.b.a", we want the result
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    // to be "/c.b.a" and so must keep the trailing slash (empty name).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    void checkAndAdjustRemainingName(Name rname) throws InvalidNameException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        int count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        if (rname != null && (count=rname.size()) > 1 &&
52902
e3398b2e1ab0 8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents: 47216
diff changeset
   471
            rname.get(count-1).isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            rname.remove(count-1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    // Returns true if n contains only empty components
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    protected boolean isAllEmpty(Name n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        int count = n.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        for (int i =0; i < count; i++ ) {
52902
e3398b2e1ab0 8214971: Replace use of string.equals("") with isEmpty()
rriggs
parents: 47216
diff changeset
   480
            if (!n.get(i).isEmpty()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
// ------ implementations of p_ Resolver and Context methods using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
// ------ corresponding c_ and c_*_nns methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    /* implementation for Resolver method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    protected ResolveResult p_resolveToClass(Name name,
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   496
                                             Class<?> contextType,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                             Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        if (contextType.isInstance(this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
            cont.setSuccess();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            return (new ResolveResult(this, name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        ResolveResult ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            Object obj = p_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            if (!cont.isContinue() && contextType.isInstance(obj)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                ret = new ResolveResult(obj, _EMPTY_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            cont.setSuccess();  // no contextType found; return null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            /* pcont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /* implementations of p_ Context methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    protected Object p_lookup(Name name, Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        Object ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                ret = c_lookup_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                if (ret instanceof LinkRef) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                    cont.setContinue(ret, res.getHead(), this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                    ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                ret = c_lookup(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                if (ret instanceof LinkRef) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                    cont.setContinue(ret, res.getHead(), this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                    ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                /* pcont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   557
    protected NamingEnumeration<NameClassPair> p_list(Name name, Continuation cont)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        throws NamingException {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   559
        NamingEnumeration<NameClassPair> ret = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                    System.out.println("c_list_nns(" + res.getHead() + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                ret = c_list_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    System.out.println("c_list(" + res.getHead() + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                ret = c_list(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   582
    protected NamingEnumeration<Binding> p_listBindings(Name name, Continuation cont) throws
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        NamingException {
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   584
        NamingEnumeration<Binding> ret = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                ret = c_listBindings_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                ret = c_listBindings(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    protected void p_bind(Name name, Object obj, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                c_bind_nns(res.getHead(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                c_bind(res.getHead(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    protected void p_rebind(Name name, Object obj, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                c_rebind_nns(res.getHead(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                c_rebind(res.getHead(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    protected void p_unbind(Name name, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                c_unbind_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                c_unbind(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    protected void p_destroySubcontext(Name name, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                c_destroySubcontext_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                c_destroySubcontext(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    protected Context p_createSubcontext(Name name, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            Context ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                ret = c_createSubcontext_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                ret = c_createSubcontext(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    protected void p_rename(Name oldName, Name newName, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        HeadTail res = p_resolveIntermediate(oldName, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                c_rename_nns(res.getHead(), newName, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                c_rename(res.getHead(), newName, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
    protected NameParser p_getNameParser(Name name, Continuation cont) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        NameParser ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                ret = c_getNameParser_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                ret = c_getNameParser(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    protected Object p_lookupLink(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        Object ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        HeadTail res = p_resolveIntermediate(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        switch (res.getStatus()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
            case TERMINAL_NNS_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                ret = c_lookupLink_nns(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            case TERMINAL_COMPONENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                ret = c_lookupLink(res.getHead(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                /* USE_CONTINUATION */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                /* cont already set or exception thrown */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
 *      How p_resolveIntermediate() should behave for various test cases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
a.b/x   {a.b, x}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        c_resolveIntermediate_nns(a.b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        continue(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        {x,}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        terminal(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
a.b/    {a.b, ""}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        terminal_nns(a.b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
a.b//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        {a.b, ("", "")}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        c_lookup_nns(a.b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        continue({""})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        {,""}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        terminal_nns({})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
/x      {{}, {"", x}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        c_lookup_nns({})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        continue(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        {x,}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        terminal(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
//y     {{}, {"", "", y}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        c_lookup_nns({})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        continue({"", y})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        {{}, {"", y}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        c_lookup_nns({})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        continue(y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        {y,}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        terminal(y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
a.b//y  {a.b, {"", y}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        c_resolveIntermediate_nns(a.b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        continue({"", y})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        {{}, {"",y}}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        c_lookup_nns({});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        continue(y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        {y,}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        terminal(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
 */