Package org.ldaptive.transport
Class TransportConnection
java.lang.Object
org.ldaptive.transport.TransportConnection
- All Implemented Interfaces:
AutoCloseable,Connection
- Direct Known Subclasses:
NettyConnection
Base class for connection implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReentrantLockOnly one invocation of close can occur at a time.protected final ConnectionConfigProvides host connection configuration.private final ConnectionStrategyConnection strategy for this connection.protected InstantTime of the last successful open for this connection.private static final LoggerLogger for this class.protected final ReentrantLockOnly one invocation of open can occur at a time. -
Constructor Summary
ConstructorsConstructorDescriptionTransportConnection(ConnectionConfig config) Creates a new transport connection. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcomplete(DefaultOperationHandle<?, ?> handle) Report that the supplied handle has completed.voidopen()Opens the connection.protected abstract voidAttempt to open a connection to the supplied LDAP URL.protected abstract voidoperation(UnbindRequest request) Executes an unbind operation.protected voidreopen(RetryMetadata metadata) Method to support reopening a connection that was previously established.protected voidstrategyOpen(RetryMetadata metadata) Retrieves URLs from the connection strategy and attempts each one, in order, until a connection is made or the list is exhausted.protected abstract booleanDetermine whether the supplied URL is acceptable for use.protected abstract voidwrite(DefaultOperationHandle<?, ?> handle) Write the request in the supplied handle to the LDAP server.
-
Field Details
-
LOGGER
Logger for this class. -
openLock
Only one invocation of open can occur at a time. -
closeLock
Only one invocation of close can occur at a time. -
connectionConfig
Provides host connection configuration. -
lastSuccessfulOpen
Time of the last successful open for this connection. -
connectionStrategy
Connection strategy for this connection. Default value isActivePassiveConnectionStrategy.
-
-
Constructor Details
-
TransportConnection
Creates a new transport connection.- Parameters:
config- connection configuration
-
-
Method Details
-
open
Description copied from interface:ConnectionOpens the connection.- Specified by:
openin interfaceConnection- Throws:
LdapException- if an error occurs opening the connection
-
reopen
Method to support reopening a connection that was previously established. This method differs fromopen()in that the autoReconnectCondition is tested before the open is attempted.- Parameters:
metadata- associated with this reopen- Throws:
LdapException- if the open fails
-
strategyOpen
Retrieves URLs from the connection strategy and attempts each one, in order, until a connection is made or the list is exhausted.- Parameters:
metadata- to track URL success and failure- Throws:
LdapException- if a connection cannot be established
-
test
Determine whether the supplied URL is acceptable for use.- Parameters:
url- LDAP URL to test- Returns:
- whether URL can be become active
-
open
Attempt to open a connection to the supplied LDAP URL.- Parameters:
url- LDAP URL to connect to- Throws:
LdapException- if opening the connection fails
-
operation
Executes an unbind operation. Clients should close connections usingConnection.close().- Parameters:
request- unbind request
-
write
Write the request in the supplied handle to the LDAP server. This method does not throw, it should report exceptions to the handle.- Parameters:
handle- for the operation write
-
complete
Report that the supplied handle has completed. Allows the connection to clean up any resources associated with the handle.- Parameters:
handle- that has completed
-