Package com.unboundid.ldap.sdk
Class RetainConnectExceptionReferralConnector
java.lang.Object
com.unboundid.ldap.sdk.RetainConnectExceptionReferralConnector
- All Implemented Interfaces:
ReferralConnector
@ThreadSafety(level=MOSTLY_NOT_THREADSAFE)
public final class RetainConnectExceptionReferralConnector
extends Object
implements ReferralConnector
This class provides an implementation of a referral connector that will
retain the exception encountered on the last attempt to establish a
connection for the purpose of following a referral.
Note that although this class is technically safe to be used concurrently by multiple threads in that it won't result in a deadlock or concurrent modification exception or any other kind of obvious failure, it only retains a single exception, and only from the last attempt made to establish a connection for the purpose of following a referral. If multiple threads try to use the same instance of this connector concurrently, a call to the
Note that although this class is technically safe to be used concurrently by multiple threads in that it won't result in a deadlock or concurrent modification exception or any other kind of obvious failure, it only retains a single exception, and only from the last attempt made to establish a connection for the purpose of following a referral. If multiple threads try to use the same instance of this connector concurrently, a call to the
getExceptionFromLastConnectAttempt() method may return the result
from the last attempt made on another thread. It is therefore recommended
that this connector only be used in contexts where it can be safely assumed
that it will not be used concurrently across multiple threads. For example,
if a connection is not expected to be concurrently shared by multiple
threads, then it may be desirable to use the
LDAPConnection.setReferralConnector(ReferralConnector) to set a
different instance of this connector for each connection. Alternately, the
LDAPRequest.setReferralConnector(ReferralConnector) method may be
used to specify a connector that should be used for an individual request.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this referral connector that will use the connection's default referral handler to actually attempt to establish a connection.RetainConnectExceptionReferralConnector(ReferralConnector wrappedReferralConnector) Creates a new instance of this referral connector that will use the provided connector to actually attempt to establish a connection. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the exception that was caught in the last attempt to establish a connection for the purpose of following a referral, if any.getReferralConnection(LDAPURL referralURL, LDAPConnection connection) Retrieves an (optionally authenticated) LDAP connection for use in following a referral as defined in the provided LDAP URL.
-
Constructor Details
-
RetainConnectExceptionReferralConnector
Creates a new instance of this referral connector that will use the connection's default referral handler to actually attempt to establish a connection. -
RetainConnectExceptionReferralConnector
public RetainConnectExceptionReferralConnector(@Nullable ReferralConnector wrappedReferralConnector) Creates a new instance of this referral connector that will use the provided connector to actually attempt to establish a connection.- Parameters:
wrappedReferralConnector- The referral connector that will be used to actually attempt to establish a connection for the purpose of following a referral. This may benullto use the default referral connector for the connection on which the referral was received.
-
-
Method Details
-
getExceptionFromLastConnectAttempt
Retrieves the exception that was caught in the last attempt to establish a connection for the purpose of following a referral, if any.- Returns:
- The exception that was caught in the last attempt to establish a
connection for the purpose of following a referral, or
nullif the last connection attempt was successful or if there have not yet been any connection attempts.
-
getReferralConnection
@NotNull public LDAPConnection getReferralConnection(@NotNull LDAPURL referralURL, @NotNull LDAPConnection connection) throws LDAPException Retrieves an (optionally authenticated) LDAP connection for use in following a referral as defined in the provided LDAP URL. The connection will automatically be closed after the referral has been followed.- Specified by:
getReferralConnectionin interfaceReferralConnector- Parameters:
referralURL- The LDAP URL representing the referral being followed.connection- The connection on which the referral was received.- Returns:
- An LDAP connection established and optionally authenticated to the target system that may be used to attempt to follow a referral.
- Throws:
LDAPException- If a problem occurs while establishing the connection or performing authentication on it. If an exception is thrown, then any underlying connection should be terminated before the exception is thrown.
-