src/java.naming/share/classes/javax/naming/ReferralException.java
author herrick
Tue, 24 Sep 2019 13:41:16 -0400
branchJDK-8200758-branch
changeset 58301 e0efb29609bd
parent 47216 71c04702a3d5
permissions -rw-r--r--
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code Submitted-by: asemenyuk Reviewed-by: herrick, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18580
6c4badf4ffba 8019407: Fix doclint issues in javax.naming.*
darcy
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2013, 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 javax.naming;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This abstract class is used to represent a referral exception,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * which is generated in response to a <em>referral</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * such as that returned by LDAP v3 servers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * A service provider provides
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    36
 * a subclass of {@code ReferralException} by providing implementations
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    37
 * for {@code getReferralInfo()} and {@code getReferralContext()} (and appropriate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * constructors and/or corresponding "set" methods).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * <p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    40
 * The following code sample shows how {@code ReferralException} can be used.
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    41
 * <blockquote><pre>{@code
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *      while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *          try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *              bindings = ctx.listBindings(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *              while (bindings.hasMore()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *                  b = bindings.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *                  ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *          } catch (ReferralException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *              ctx = e.getReferralContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *      }
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    54
 * }</pre></blockquote>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    56
 * {@code ReferralException} is an abstract class. Concrete implementations
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * determine its synchronization and serialization properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
    59
 * An environment parameter passed to the {@code getReferralContext()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * method is owned by the caller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * The service provider will not modify the object or keep a reference to it,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * but may keep a reference to a clone of it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
public abstract class ReferralException extends NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Constructs a new instance of ReferralException using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * explanation supplied. All other fields are set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @param   explanation     Additional detail about this exception. Can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @see java.lang.Throwable#getMessage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    protected ReferralException(String explanation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super(explanation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      * Constructs a new instance of ReferralException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
      * All fields are set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    protected ReferralException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Retrieves information (such as URLs) related to this referral.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * The program may examine or display this information
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * to the user to determine whether to continue with the referral,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * or to determine additional information needs to be supplied in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * to continue with the referral.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @return Non-null referral information related to this referral.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public abstract Object getReferralInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Retrieves the context at which to continue the method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Regardless of whether a referral is encountered directly during a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * context operation, or indirectly, for example, during a search
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * enumeration, the referral exception should provide a context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * at which to continue the operation. The referral context is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * created using the environment properties of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * that threw the ReferralException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * To continue the operation, the client program should re-invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * the method using the same arguments as the original invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @return The non-null context at which to continue the method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @exception NamingException If a naming exception was encountered.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   117
     * Call either {@code retryReferral()} or {@code skipReferral()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * to continue processing referrals.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public abstract Context getReferralContext() throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Retrieves the context at which to continue the method using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * environment properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Regardless of whether a referral is encountered directly during a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * context operation, or indirectly, for example, during a search
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * enumeration, the referral exception should provide a context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * at which to continue the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *<p>
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   130
     * The referral context is created using {@code env} as its environment
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * This method should be used instead of the no-arg overloaded form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * when the caller needs to use different environment properties for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * the referral context. It might need to do this, for example, when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * it needs to supply different authentication information to the referred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * server in order to create the referral context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * To continue the operation, the client program should re-invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * the method using the same arguments as the original invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @param env The possibly null environment to use when retrieving the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     *          referral context. If null, no environment properties will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @return The non-null context at which to continue the method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @exception NamingException If a naming exception was encountered.
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   146
     * Call either {@code retryReferral()} or {@code skipReferral()}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * to continue processing referrals.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public abstract Context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        getReferralContext(Hashtable<?,?> env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        throws NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Discards the referral about to be processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * A call to this method should be followed by a call to
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   156
     * {@code getReferralContext} to allow the processing of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * other referrals to continue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * The following code fragment shows a typical usage pattern.
21285
e740104a04f1 8026840: Fix new doclint issues in javax.naming
darcy
parents: 18580
diff changeset
   159
     * <blockquote><pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *  } catch (ReferralException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *      if (!shallIFollow(e.getReferralInfo())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *          if (!e.skipReferral()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *              return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *      ctx = e.getReferralContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @return true If more referral processing is pending; false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public abstract boolean skipReferral();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Retries the referral currently being processed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * A call to this method should be followed by a call to
32029
a5538163e144 8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents: 25859
diff changeset
   177
     * {@code getReferralContext} to allow the current
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * referral to be retried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * The following code fragment shows a typical usage pattern.
21285
e740104a04f1 8026840: Fix new doclint issues in javax.naming
darcy
parents: 18580
diff changeset
   180
     * <blockquote><pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *  } catch (ReferralException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     *      while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *          try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *              ctx = e.getReferralContext(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *              break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *          } catch (NamingException ne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *              if (! shallIRetry()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *                  return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *              }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *              // modify environment properties (env), if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *              e.retryReferral();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public abstract void retryReferral();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    private static final long serialVersionUID = -2881363844695698876L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
}