0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.naming;
0N/A
0N/Aimport java.util.Hashtable;
0N/A
0N/A/**
0N/A * This abstract class is used to represent a referral exception,
0N/A * which is generated in response to a <em>referral</em>
0N/A * such as that returned by LDAP v3 servers.
0N/A * <p>
0N/A * A service provider provides
0N/A * a subclass of <tt>ReferralException</tt> by providing implementations
0N/A * for <tt>getReferralInfo()</tt> and <tt>getReferralContext()</tt> (and appropriate
0N/A * constructors and/or corresponding "set" methods).
0N/A * <p>
0N/A * The following code sample shows how <tt>ReferralException</tt> can be used.
0N/A * <p><blockquote><pre>
0N/A * while (true) {
0N/A * try {
0N/A * bindings = ctx.listBindings(name);
0N/A * while (bindings.hasMore()) {
0N/A * b = bindings.next();
0N/A * ...
0N/A * }
0N/A * break;
0N/A * } catch (ReferralException e) {
0N/A * ctx = e.getReferralContext();
0N/A * }
0N/A * }
0N/A * </pre></blockquote></p>
0N/A *<p>
0N/A * <tt>ReferralException</tt> is an abstract class. Concrete implementations
0N/A * determine its synchronization and serialization properties.
0N/A *<p>
0N/A * An environment parameter passed to the <tt>getReferralContext()</tt>
0N/A * method is owned by the caller.
0N/A * The service provider will not modify the object or keep a reference to it,
0N/A * but may keep a reference to a clone of it.
0N/A *
0N/A * @author Rosanna Lee
0N/A * @author Scott Seligman
0N/A *
0N/A * @since 1.3
0N/A *
0N/A */
0N/A
0N/Apublic abstract class ReferralException extends NamingException {
0N/A /**
0N/A * Constructs a new instance of ReferralException using the
0N/A * explanation supplied. All other fields are set to null.
0N/A *
0N/A * @param explanation Additional detail about this exception. Can be null.
0N/A * @see java.lang.Throwable#getMessage
0N/A */
0N/A protected ReferralException(String explanation) {
0N/A super(explanation);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a new instance of ReferralException.
0N/A * All fields are set to null.
0N/A */
0N/A protected ReferralException() {
0N/A super();
0N/A }
0N/A
0N/A /**
0N/A * Retrieves information (such as URLs) related to this referral.
0N/A * The program may examine or display this information
0N/A * to the user to determine whether to continue with the referral,
0N/A * or to determine additional information needs to be supplied in order
0N/A * to continue with the referral.
0N/A *
0N/A * @return Non-null referral information related to this referral.
0N/A */
0N/A public abstract Object getReferralInfo();
0N/A
0N/A /**
0N/A * Retrieves the context at which to continue the method.
0N/A * Regardless of whether a referral is encountered directly during a
0N/A * context operation, or indirectly, for example, during a search
0N/A * enumeration, the referral exception should provide a context
0N/A * at which to continue the operation. The referral context is
0N/A * created using the environment properties of the context
0N/A * that threw the ReferralException.
0N/A *
0N/A *<p>
0N/A * To continue the operation, the client program should re-invoke
0N/A * the method using the same arguments as the original invocation.
0N/A *
0N/A * @return The non-null context at which to continue the method.
0N/A * @exception NamingException If a naming exception was encountered.
0N/A * Call either <tt>retryReferral()</tt> or <tt>skipReferral()</tt>
0N/A * to continue processing referrals.
0N/A */
0N/A public abstract Context getReferralContext() throws NamingException;
0N/A
0N/A /**
0N/A * Retrieves the context at which to continue the method using
0N/A * environment properties.
0N/A * Regardless of whether a referral is encountered directly during a
0N/A * context operation, or indirectly, for example, during a search
0N/A * enumeration, the referral exception should provide a context
0N/A * at which to continue the operation.
0N/A *<p>
0N/A * The referral context is created using <tt>env</tt> as its environment
0N/A * properties.
0N/A * This method should be used instead of the no-arg overloaded form
0N/A * when the caller needs to use different environment properties for
0N/A * the referral context. It might need to do this, for example, when
0N/A * it needs to supply different authentication information to the referred
0N/A * server in order to create the referral context.
0N/A *<p>
0N/A * To continue the operation, the client program should re-invoke
0N/A * the method using the same arguments as the original invocation.
0N/A *
0N/A * @param env The possibly null environment to use when retrieving the
0N/A * referral context. If null, no environment properties will be used.
0N/A *
0N/A * @return The non-null context at which to continue the method.
0N/A * @exception NamingException If a naming exception was encountered.
0N/A * Call either <tt>retryReferral()</tt> or <tt>skipReferral()</tt>
0N/A * to continue processing referrals.
0N/A */
0N/A public abstract Context
0N/A getReferralContext(Hashtable<?,?> env)
0N/A throws NamingException;
0N/A
0N/A /**
0N/A * Discards the referral about to be processed.
0N/A * A call to this method should be followed by a call to
0N/A * <code>getReferralContext</code> to allow the processing of
0N/A * other referrals to continue.
0N/A * The following code fragment shows a typical usage pattern.
0N/A * <p><blockquote><pre>
0N/A * } catch (ReferralException e) {
0N/A * if (!shallIFollow(e.getReferralInfo())) {
0N/A * if (!e.skipReferral()) {
0N/A * return;
0N/A * }
0N/A * }
0N/A * ctx = e.getReferralContext();
0N/A * }
0N/A * </pre></blockquote>
0N/A *
0N/A * @return true If more referral processing is pending; false otherwise.
0N/A */
0N/A public abstract boolean skipReferral();
0N/A
0N/A /**
0N/A * Retries the referral currently being processed.
0N/A * A call to this method should be followed by a call to
0N/A * <code>getReferralContext</code> to allow the current
0N/A * referral to be retried.
0N/A * The following code fragment shows a typical usage pattern.
0N/A * <p><blockquote><pre>
0N/A * } catch (ReferralException e) {
0N/A * while (true) {
0N/A * try {
0N/A * ctx = e.getReferralContext(env);
0N/A * break;
0N/A * } catch (NamingException ne) {
0N/A * if (! shallIRetry()) {
0N/A * return;
0N/A * }
0N/A * // modify environment properties (env), if necessary
0N/A * e.retryReferral();
0N/A * }
0N/A * }
0N/A * }
0N/A * </pre></blockquote>
0N/A *
0N/A */
0N/A public abstract void retryReferral();
0N/A
0N/A /**
0N/A * Use serialVersionUID from JNDI 1.1.1 for interoperability
0N/A */
0N/A private static final long serialVersionUID = -2881363844695698876L;
0N/A}