Class AbstractPoolableLdapConnectionFactory

java.lang.Object
org.apache.directory.ldap.client.api.AbstractPoolableLdapConnectionFactory
All Implemented Interfaces:
org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
Direct Known Subclasses:
DefaultPoolableLdapConnectionFactory, ValidatingPoolableLdapConnectionFactory

public abstract class AbstractPoolableLdapConnectionFactory extends Object implements org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
An abstract class implementing the PoolableObjectFactory, for LdapConnections.
Author:
Apache Directory Project
  • Field Details

  • Constructor Details

    • AbstractPoolableLdapConnectionFactory

      public AbstractPoolableLdapConnectionFactory(LdapConnectionFactory connectionFactory)
      Constructor that takes a LdapConnection factory for poolable connections
      Parameters:
      connectionFactory - The Ldap connection factory to use
  • Method Details

    • activateObject

      public void activateObject(org.apache.commons.pool2.PooledObject<LdapConnection> connection) throws org.apache.directory.api.ldap.model.exception.LdapException
      There is nothing to do to activate a connection.
      Specified by:
      activateObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException
    • destroyObject

      public void destroyObject(org.apache.commons.pool2.PooledObject<LdapConnection> connection) throws org.apache.directory.api.ldap.model.exception.LdapException
      Destroying a connection will unbind it which will result on a shutdown of teh underlying protocol.
      Specified by:
      destroyObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException
    • getLdapApiService

      public org.apache.directory.api.ldap.codec.api.LdapApiService getLdapApiService()
      Returns the LdapApiService instance used by this factory.
      Returns:
      The LdapApiService instance used by this factory
    • makeObject

      public org.apache.commons.pool2.PooledObject<LdapConnection> makeObject() throws org.apache.directory.api.ldap.model.exception.LdapException
      Specifically, we are creating a new connection based on the LdapConnection Factory we used to create this pool of connections. The default is to create bound connections.
      Specified by:
      makeObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If unable to connect.
    • newLdapConnectionFactory

      protected static LdapConnectionFactory newLdapConnectionFactory(LdapConnectionConfig config, Class<? extends LdapConnectionFactory> connectionFactoryClass)
      Create a new LdapConnectionFactory instance
      Parameters:
      config - The connection configuration to use
      connectionFactoryClass - The factory class to use
      Returns:
      An instance of LdapConnectionFactory
    • passivateObject

      public void passivateObject(org.apache.commons.pool2.PooledObject<LdapConnection> connection) throws org.apache.directory.api.ldap.model.exception.LdapException
      We don't do anything with the connection. It remains in the state it was before being used.
      Specified by:
      passivateObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If unable to reconfigure and rebind.
    • setValidator

      public void setValidator(LdapConnectionValidator validator)
      Sets the validator to use when validation occurs. Note that validation will only occur if the connection pool was configured to validate. This means one of:
      • setTestOnBorrow
      • setTestWhileIdle
      • setTestOnReturn
      must have been set to true on the pool. The default validator is LookupLdapConnectionValidator.
      Parameters:
      validator - The validator
    • validateObject

      public boolean validateObject(org.apache.commons.pool2.PooledObject<LdapConnection> connection)
      Validating a connection is done by checking the connection status.
      Specified by:
      validateObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>