Class ValidatingPoolableLdapConnectionFactory

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

public class ValidatingPoolableLdapConnectionFactory extends AbstractPoolableLdapConnectionFactory
A factory for creating LdapConnection objects managed by LdapConnectionPool. A bind operation is executed upon return if any of the following operations were performed on the connection while it was checked out: This is a MOSTLY safe way to handle connections in a pool. If one would like to use a slightly less expensive pool factory, the DefaultPoolableLdapConnectionFactory may be the right choice.
Author:
Apache Directory Project
  • Constructor Details

    • ValidatingPoolableLdapConnectionFactory

      public ValidatingPoolableLdapConnectionFactory(LdapConnectionConfig config)
      Creates a new instance of ValidatingPoolableLdapConnectionFactory.
      Parameters:
      config - the configuration for creating LdapConnections
    • ValidatingPoolableLdapConnectionFactory

      public ValidatingPoolableLdapConnectionFactory(LdapConnectionConfig config, Class<? extends LdapConnectionFactory> connectionFactoryClass)
      Creates a new instance of ValidatingPoolableLdapConnectionFactory. The connectionFactoryClass must have a public constructor accepting an LdapConnectionConfig object or an IllegalArgumentException will be thrown.
      Parameters:
      config - the configuration for creating LdapConnections
      connectionFactoryClass - An implementation class of for the LDAP connection factory.
      Throws:
      IllegalArgumentException - If the instantiation of an instance of the connectionFactoryClass fails.
    • ValidatingPoolableLdapConnectionFactory

      public ValidatingPoolableLdapConnectionFactory(LdapConnectionFactory connectionFactory)
      Creates a new instance of ValidatingPoolableLdapConnectionFactory.
      Parameters:
      connectionFactory - the connection factory for creating LdapConnections
  • Method Details

    • activateObject

      public void activateObject(org.apache.commons.pool2.PooledObject<LdapConnection> pooledObject) throws org.apache.directory.api.ldap.model.exception.LdapException
      There is nothing to do to activate a connection. There is nothing to do to activate a connection.
      Specified by:
      activateObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Overrides:
      activateObject in class AbstractPoolableLdapConnectionFactory
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException
    • 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. 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>
      Overrides:
      makeObject in class AbstractPoolableLdapConnectionFactory
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If unable to connect.
    • passivateObject

      public void passivateObject(org.apache.commons.pool2.PooledObject<LdapConnection> pooledObject) 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. Here, passivating a connection means we re-bind it, so that the existing LDAPSession is reset.
      Specified by:
      passivateObject in interface org.apache.commons.pool2.PooledObjectFactory<LdapConnection>
      Overrides:
      passivateObject in class AbstractPoolableLdapConnectionFactory
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If unable to reconfigure and rebind.