Class DefaultLdapConnectionFactory

java.lang.Object
org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory
All Implemented Interfaces:
LdapConnectionFactory

public class DefaultLdapConnectionFactory extends Object implements LdapConnectionFactory
The default implementation of LdapConnectionFactory. Allows for the setting of timeout and LdapApiService as well as the standard LdapConnectionConfig.
Author:
Apache Directory Project
  • Constructor Details

    • DefaultLdapConnectionFactory

      public DefaultLdapConnectionFactory(LdapConnectionConfig config)
      Creates a new instance of DefaultLdapConnectionFactory.
      Parameters:
      config - The connection config.
  • Method Details

    • bindConnection

      public LdapConnection bindConnection(LdapConnection connection) throws org.apache.directory.api.ldap.model.exception.LdapException
      Issues a bind request on the supplied connection using the name and credentials from the LdapConnectionConfg supplied to the constructor. Returns the connection supplied for chaining.
      Specified by:
      bindConnection in interface LdapConnectionFactory
      Parameters:
      connection - The connection to bind with the configuration credentials.
      Returns:
      The connection supplied.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the bind fails.
    • configureConnection

      public LdapConnection configureConnection(LdapConnection connection)
      Applies the following configuration settings from the LdapConnectionConfig to the supplied connection:
      • timeOut
      • binaryAttributeDetector
      This method is called by newLdapConnection, so there is no need to call this on a newly created connection. This should be used for pooling where the returned connection could have been modified by the borrower in order to ensure the next borrower gets a correctly configured connection. Returns the supplied connection for chaining.
      Specified by:
      configureConnection in interface LdapConnectionFactory
      Parameters:
      connection - The connection to configure
      Returns:
      The supplied connection.
    • getLdapApiService

      public org.apache.directory.api.ldap.codec.api.LdapApiService getLdapApiService()
      Returns the LdapApiService instance used by this factory.
      Specified by:
      getLdapApiService in interface LdapConnectionFactory
      Returns:
      The LdapApiService instance used by this factory
    • newLdapConnection

      public LdapConnection newLdapConnection() throws org.apache.directory.api.ldap.model.exception.LdapException
      Returns a newly created, configured, and authenticated connection. This method should be used by a connection pool to manufacture the pooled instances.
      Specified by:
      newLdapConnection in interface LdapConnectionFactory
      Returns:
      A newly created, configured, and authenticated LdapConnection.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the new connection couldn't be established
    • newUnboundLdapConnection

      public LdapConnection newUnboundLdapConnection()
      Returns a newly created connection, that has not been bound (bind) that otherwise respects LdapConnectionConfig supplied to the constructor. This is useful for authentication purposes where the consumer will use a bind operation.
      Specified by:
      newUnboundLdapConnection in interface LdapConnectionFactory
      Returns:
      A newly created and configured LdapConnection.
    • setLdapApiService

      public void setLdapApiService(org.apache.directory.api.ldap.codec.api.LdapApiService apiService)
      Sets the LdapApiService (codec) to be used by the connections created by this factory.
      Parameters:
      apiService - The codec to used by connections created by this factory
    • setTimeOut

      public void setTimeOut(long timeout)
      Sets the timeout that will be used by all connections created by this factory.
      Parameters:
      timeout - The timeout in millis.
      See Also: