jdk/src/java.naming/share/classes/com/sun/jndi/toolkit/ctx/AtomicContext.java
author martin
Thu, 30 Oct 2014 07:31:41 -0700
changeset 28059 e576535359cc
parent 25859 3317bb8137f4
permissions -rw-r--r--
8067377: My hobby: caning, then then canning, the the can-can Summary: Fix ALL the stutters! Reviewed-by: rriggs, mchung, lancea
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  * Clients: deal only with names for its own naming service
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  * and deals with single contexts that can be built up into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * hierarchical naming systems.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * Direct subclasses of AtomicContext must provide implementations for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  * the abstract a_ Context methods, and c_parseComponent().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  * If the subclass implements the notion of implicit nns,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  * it must override the a_*_nns Context methods as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public abstract class AtomicContext extends ComponentContext {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static int debug = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    protected AtomicContext () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        _contextType = _ATOMIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
// ------ Abstract methods whose implementation are provided by subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /* Equivalent to Context methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    protected abstract Object a_lookup(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected abstract Object a_lookupLink(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    60
    protected abstract NamingEnumeration<NameClassPair> a_list(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        Continuation cont) throws NamingException;
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
    62
    protected abstract NamingEnumeration<Binding> a_listBindings(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    protected abstract void a_bind(String 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 a_rebind(String name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    protected abstract void a_unbind(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected abstract void a_destroySubcontext(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    protected abstract Context a_createSubcontext(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    protected abstract void a_rename(String oldname, Name newname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected abstract NameParser a_getNameParser(Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /* Parsing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Parse 'inputName' into two parts:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * head: the first component in this name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * tail: the rest of the unused name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Subclasses should provide an implementation for this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * which parses inputName using its own name syntax.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    protected abstract StringHeadTail c_parseComponent(String inputName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        Continuation cont) throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
// ------ Methods that need to be overridden by subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /* Resolution method for supporting federation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      * Resolves the nns for 'name' when the named context is acting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      * as an intermediate context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      *
25808
e113d0a0fde0 8054158: Fix typos in JNDI-related packages
prappo
parents: 10324
diff changeset
    99
      * For a system that supports junctions, this would be equivalent to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      *         a_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
      * because for junctions, an intermediate slash simply signifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      * a syntactic separator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      * For a system that supports implicit nns, this would be equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      *         a_lookup_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      * because for implicit nns, a slash always signifies the implicit nns,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      * regardless of whether it is intermediate or trailing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      * By default this method supports junctions, and also allows for an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      * implicit nns to be dynamically determined through the use of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
      * "nns" reference (see a_processJunction_nns()).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      * Contexts that implement implicit nns directly should provide an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      * appropriate override.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected Object a_resolveIntermediate_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                final Object obj = a_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                // Do not append "" to Continuation 'cont' even if set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                // because the intention is to ignore the nns
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 (obj != null && getClass().isInstance(obj)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    // If "obj" is in the same type as this object, it must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    // not be a junction. Continue the lookup with "/".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    cont.setContinueNNS(obj, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                } else if (obj != null && !(obj instanceof Context)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    // obj is not even a context, so try to find its nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    // dynamically by constructing a Reference containing obj.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    RefAddr addr = new RefAddr("nns") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                        public Object getContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                            return obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                        private static final long serialVersionUID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                            -3399518522645918499L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                    Reference ref = new Reference("java.lang.Object", addr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                    // Resolved name has trailing slash to indicate nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                    CompositeName resName = new CompositeName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                    resName.add(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    resName.add(""); // add trailing slash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    // Set continuation leave it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    // PartialCompositeContext.getPCContext() to throw CPE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                    // Do not use setContinueNNS() because we've already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    // consumed "/" (i.e., moved it to resName).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    cont.setContinue(ref, resName, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    return obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                e.appendRemainingComponent(""); // add nns back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /* Equivalent of Context Methods for supporting nns */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    // The following methods are called when the DirContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    // are invoked with a name that has a trailing slash.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    // For naming systems that support implicit nns,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    // the trailing slash signifies the implicit nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    // For such naming systems, override these a_*_nns methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    // For naming systems that support junctions (explicit nns),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    // the trailing slash is meaningless because a junction does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    // have an implicit nns.  The default implementation here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    // throws a NameNotFoundException for such names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    // If a context wants to accept a trailing slash as having
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    // the same meaning as the same name without a trailing slash,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    // then it should override these a_*_nns methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    protected Object a_lookup_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    protected Object a_lookupLink_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   195
    protected NamingEnumeration<NameClassPair> a_list_nns(Continuation cont)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            a_processJunction_nns(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   200
    protected NamingEnumeration<Binding> a_listBindings_nns(Continuation cont)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            a_processJunction_nns(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    protected void a_bind_nns(String name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    protected void a_rebind_nns(String name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    protected void a_unbind_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    protected Context a_createSubcontext_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            a_processJunction_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    protected void a_destroySubcontext_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            a_processJunction_nns(name, cont);
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 void a_rename_nns(String oldname, Name newname, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            a_processJunction_nns(oldname, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    protected NameParser a_getNameParser_nns(Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            a_processJunction_nns(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    protected boolean isEmpty(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return name == null || name.equals("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
// ------ implementations of c_  and c_*_nns methods using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
// ------ the corresponding a_ and a_*_nns methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /* Equivalent to methods in  Context interface */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    protected Object c_lookup(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            Object ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            if (resolve_to_penultimate_context(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                ret = a_lookup(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                if (ret != null && ret instanceof LinkRef) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                    cont.setContinue(ret, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    protected Object c_lookupLink(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            if (resolve_to_penultimate_context(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                return a_lookupLink(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   275
    protected NamingEnumeration<NameClassPair> c_list(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            if (resolve_to_context(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                return a_list(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   283
    protected NamingEnumeration<Binding> c_listBindings(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            if (resolve_to_context(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                return a_listBindings(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    protected void c_bind(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            if (resolve_to_penultimate_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                a_bind(name.toString(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    protected void c_rebind(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            if (resolve_to_penultimate_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                a_rebind(name.toString(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    protected void c_unbind(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            if (resolve_to_penultimate_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                a_unbind(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    protected void c_destroySubcontext(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            if (resolve_to_penultimate_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                a_destroySubcontext(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    protected Context c_createSubcontext(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            if (resolve_to_penultimate_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                return a_createSubcontext(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    protected void c_rename(Name oldname, Name newname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            if (resolve_to_penultimate_context(oldname, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                 a_rename(oldname.toString(), newname, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    protected NameParser c_getNameParser(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            if (resolve_to_context(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                return a_getNameParser(cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /* The following are overridden only for AtomicContexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * AtomicContext is used by PartialCompositeDirContext and ComponentDirContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * in the inheritance tree to make use of methods in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * PartialCompositeContext and ComponentContext. We only want to use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * atomic forms when we're actually an atomic context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    /* From ComponentContext */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    protected Object c_resolveIntermediate_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                Object ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                if (resolve_to_penultimate_context_nns(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                    ret = a_resolveIntermediate_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                    if (ret != null && ret instanceof LinkRef) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                        cont.setContinue(ret, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                        ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                return super.c_resolveIntermediate_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /* Equivalent to methods in Context interface for nns */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    protected Object c_lookup_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                Object ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                if (resolve_to_penultimate_context_nns(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                    ret = a_lookup_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    if (ret != null && ret instanceof LinkRef) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                        cont.setContinue(ret, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                        ret = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                return super.c_lookup_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    protected Object c_lookupLink_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                // %%% check logic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                resolve_to_nns_and_continue(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                return super.c_lookupLink_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   394
    protected NamingEnumeration<NameClassPair> c_list_nns(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                resolve_to_nns_and_continue(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                return super.c_list_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   405
    protected NamingEnumeration<Binding> c_listBindings_nns(Name name,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                resolve_to_nns_and_continue(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                // use ComponentContext
10324
e28265130e4f 7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents: 5506
diff changeset
   412
                return super.c_listBindings_nns(name, cont);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    protected void c_bind_nns(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                if (resolve_to_penultimate_context_nns(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                    a_bind_nns(name.toString(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                super.c_bind_nns(name, obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    protected void c_rebind_nns(Name name, Object obj, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                if (resolve_to_penultimate_context_nns(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                    a_rebind_nns(name.toString(), obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                super.c_rebind_nns(name, obj, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    protected void c_unbind_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                if (resolve_to_penultimate_context_nns(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    a_unbind_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                super.c_unbind_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    protected Context c_createSubcontext_nns(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                if (resolve_to_penultimate_context_nns(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    return a_createSubcontext_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                return super.c_createSubcontext_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    protected void c_destroySubcontext_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                if (resolve_to_penultimate_context_nns(name, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    a_destroySubcontext_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                super.c_destroySubcontext_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    protected void c_rename_nns(Name oldname, Name newname, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                if (resolve_to_penultimate_context_nns(oldname, cont))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                    a_rename_nns(oldname.toString(), newname, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                // use ComponentContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                super.c_rename_nns(oldname, newname, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    protected NameParser c_getNameParser_nns(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            if (_contextType == _ATOMIC) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                resolve_to_nns_and_continue(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            } else {
25808
e113d0a0fde0 8054158: Fix typos in JNDI-related packages
prappo
parents: 10324
diff changeset
   490
                // use ComponentContext
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                return super.c_getNameParser_nns(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
// --------------    internal methods used by this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /* Handles nns for junctions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
      * This function is used when implementing a naming system that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
      * supports junctions.  For example, when the a_bind_nns(name, newobj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      * method is invoked, that means the caller is attempting to bind the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      * object 'newobj' to the nns of 'name'.  For context that supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
      * junctions, 'name' names a junction and is pointing to the root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      * of another naming system, which in turn might have an nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
      * This means that a_bind_nns() should first resolve 'name' and attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
      * continue the operation in the context named by 'name'.  (i.e. bind
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
      * to the nns of the context named by 'name').
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
      * If name is already empty, then throw NameNotFoundException because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
      * this context by default does not have any nns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    protected void a_processJunction_nns(String name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            if (name.equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                NameNotFoundException e = new NameNotFoundException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                cont.setErrorNNS(this, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                throw cont.fillInException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                // lookup name to continue operation in nns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                Object target = a_lookup(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                if (cont.isContinue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                    cont.appendRemainingComponent("");  // add nns back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                    cont.setContinueNNS(target, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                e.appendRemainingComponent(""); // add nns back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
      * This function is used when implementing a naming system that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
      * supports junctions.  For example, when the a_list_nns(newobj)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
      * method is invoked, that means the caller is attempting to list the
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   536
      * the nns context of this context.  For a context that supports
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
      * junctions, it by default does not have any nns.  Consequently,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
      * a NameNotFoundException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    protected void a_processJunction_nns(Continuation cont) throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        // Construct a new Reference that contains this context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        RefAddr addr = new RefAddr("nns") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            public Object getContent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                return AtomicContext.this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            private static final long serialVersionUID = 3449785852664978312L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        Reference ref = new Reference("java.lang.Object", addr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        // Set continuation leave it to PartialCompositeContext.getPCContext()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        // to throw the exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        // Do not use setContinueNNS() because we've are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        // setting relativeResolvedName to "/".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        cont.setContinue(ref, _NNS_NAME, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    /* *********** core resolution routines ******************* */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /** Resolve to context named by 'name'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
      * Returns true if at named context (i.e. 'name' is empty name).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
      * Returns false otherwise, and sets Continuation on parts of 'name'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
      * not yet resolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    protected boolean resolve_to_context(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        String target = name.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        StringHeadTail ht = c_parseComponent(target, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        String tail = ht.getTail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        String head = ht.getHead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            System.out.println("RESOLVE TO CONTEXT(" + target + ") = {" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                               head + ", " + tail + "}");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (head == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            // something is wrong; no name at all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            InvalidNameException e = new InvalidNameException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            throw cont.fillInException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if (!isEmpty(head)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            // if there is head is a non-empty name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            // this means more resolution to be done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                Object headCtx = a_lookup(head, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
//              System.out.println("answer " + headCtx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                if (headCtx != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                    cont.setContinue(headCtx, head, this, (tail == null ? "" : tail));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                else if (cont.isContinue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                    cont.appendRemainingComponent(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                e.appendRemainingComponent(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            cont.setSuccess();  // clear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
      * Resolves to penultimate context named by 'name'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
      * Returns true if penultimate context has been reached (i.e. name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
      * only has one atomic component left).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
      * Returns false otherwise, and sets Continuation to parts of name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
      * not yet resolved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    protected boolean resolve_to_penultimate_context(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        String target = name.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            System.out.println("RESOLVE TO PENULTIMATE" + target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        StringHeadTail ht = c_parseComponent(target, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        String tail = ht.getTail();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        String head = ht.getHead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        if (head == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            // something is wrong; no name at all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            InvalidNameException e = new InvalidNameException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            throw cont.fillInException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        if (!isEmpty(tail)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            // more components; hence not at penultimate context yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                Object headCtx = a_lookup(head, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                if (headCtx != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                    cont.setContinue(headCtx, head, this, tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                else if (cont.isContinue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                    cont.appendRemainingComponent(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                e.appendRemainingComponent(tail);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            // already at penultimate context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            cont.setSuccess();  // clear
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
      * This function is similar to resolve_to_penultimate_context()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
      * except it should only be called by the nns() functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
      * This function fixes any exception or continuations so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
      * it will have the proper nns name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    protected boolean resolve_to_penultimate_context_nns(Name name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                                                         Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            System.out.println("RESOLVE TO PENULTIMATE NNS" + name.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                boolean answer = resolve_to_penultimate_context(name, cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                // resolve_to_penultimate_context() only calls a_lookup().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                // Any continuation it sets is lacking the nns, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                // we need to add it back
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                if (cont.isContinue())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                    cont.appendRemainingComponent("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                return answer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                // resolve_to_penultimate_context() only calls a_lookup().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                // Any exceptions it throws is lacking the nns, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                // we need to add it back.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                e.appendRemainingComponent("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
      * Resolves to nns associated with 'name' and set Continuation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      * to the result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    protected void resolve_to_nns_and_continue(Name name, Continuation cont)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        throws NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (debug > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            System.out.println("RESOLVE TO NNS AND CONTINUE" + name.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        if (resolve_to_penultimate_context_nns(name, cont)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            Object nns = a_lookup_nns(name.toString(), cont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            if (nns != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                cont.setContinue(nns, name, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}