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 ReentrantLock
Only one invocation of close can occur at a time.protected final ConnectionConfig
Provides host connection configuration.private final ConnectionStrategy
Connection strategy for this connection.protected Instant
Time of the last successful open for this connection.private static final org.slf4j.Logger
Logger for this class.protected final ReentrantLock
Only 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 void
complete
(DefaultOperationHandle handle) Report that the supplied handle has completed.void
open()
Opens the connection.protected abstract void
Attempt to open a connection to the supplied LDAP URL.protected abstract void
operation
(UnbindRequest request) Executes an unbind operation.protected void
reopen
(RetryMetadata metadata) Method to support reopening a connection that was previously established.protected void
strategyOpen
(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 boolean
Determine whether the supplied URL is acceptable for use.protected abstract void
write
(DefaultOperationHandle handle) Write the request in the supplied handle to the LDAP server.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERLogger 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:Connection
Opens the connection.- Specified by:
open
in 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 cleanup any resources associated with the handle.- Parameters:
handle
- that has completed
-