Class TransportConnection

java.lang.Object
org.ldaptive.transport.TransportConnection
All Implemented Interfaces:
AutoCloseable, Connection
Direct Known Subclasses:
NettyConnection

public abstract class TransportConnection extends Object implements Connection
Base class for connection implementations.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
      Logger for this class.
    • openLock

      protected final ReentrantLock openLock
      Only one invocation of open can occur at a time.
    • closeLock

      protected final ReentrantLock closeLock
      Only one invocation of close can occur at a time.
    • connectionConfig

      protected final ConnectionConfig connectionConfig
      Provides host connection configuration.
    • lastSuccessfulOpen

      protected Instant lastSuccessfulOpen
      Time of the last successful open for this connection.
    • connectionStrategy

      private final ConnectionStrategy connectionStrategy
      Connection strategy for this connection. Default value is ActivePassiveConnectionStrategy.
  • Constructor Details

    • TransportConnection

      public TransportConnection(ConnectionConfig config)
      Creates a new transport connection.
      Parameters:
      config - connection configuration
  • Method Details

    • open

      public void open() throws LdapException
      Description copied from interface: Connection
      Opens the connection.
      Specified by:
      open in interface Connection
      Throws:
      LdapException - if an error occurs opening the connection
    • reopen

      protected void reopen(RetryMetadata metadata) throws LdapException
      Method to support reopening a connection that was previously established. This method differs from open() in that the autoReconnectCondition is tested before the open is attempted.
      Parameters:
      metadata - associated with this reopen
      Throws:
      LdapException - if the open fails
    • strategyOpen

      protected void strategyOpen(RetryMetadata metadata) throws LdapException
      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

      protected abstract boolean test(LdapURL url)
      Determine whether the supplied URL is acceptable for use.
      Parameters:
      url - LDAP URL to test
      Returns:
      whether URL can be become active
    • open

      protected abstract void open(LdapURL url) throws LdapException
      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

      protected abstract void operation(UnbindRequest request)
      Executes an unbind operation. Clients should close connections using Connection.close().
      Parameters:
      request - unbind request
    • write

      protected abstract void write(DefaultOperationHandle handle)
      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

      protected abstract void complete(DefaultOperationHandle handle)
      Report that the supplied handle has completed. Allows the connection to cleanup any resources associated with the handle.
      Parameters:
      handle - that has completed