Class ValidatingPoolableLdapConnectionFactory
- java.lang.Object
-
- org.apache.directory.ldap.client.api.AbstractPoolableLdapConnectionFactory
-
- org.apache.directory.ldap.client.api.ValidatingPoolableLdapConnectionFactory
-
- All Implemented Interfaces:
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:bind()anonymousBind()bind(String)bind(String, String)bind(Dn)bind(Dn, String)bind(BindRequest)extended(String)where oid is StartTLSextended(String, byte[])where oid is StartTLSextended(String)where oid is StartTLSextended(String, byte[])where oid is StartTLSextended(ExtendedRequest)where ExtendedRequest is StartTLS
DefaultPoolableLdapConnectionFactorymay be the right choice.- Author:
- Apache Directory Project
-
-
Field Summary
-
Fields inherited from class org.apache.directory.ldap.client.api.AbstractPoolableLdapConnectionFactory
connectionFactory, validator
-
-
Constructor Summary
Constructors Constructor Description ValidatingPoolableLdapConnectionFactory(LdapConnectionConfig config)Creates a new instance of ValidatingPoolableLdapConnectionFactory.ValidatingPoolableLdapConnectionFactory(LdapConnectionConfig config, Class<? extends LdapConnectionFactory> connectionFactoryClass)Creates a new instance of ValidatingPoolableLdapConnectionFactory.ValidatingPoolableLdapConnectionFactory(LdapConnectionFactory connectionFactory)Creates a new instance of ValidatingPoolableLdapConnectionFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivateObject(PooledObject<LdapConnection> pooledObject)Reinitializes an instance to be returned by the pool.PooledObject<LdapConnection>makeObject()Creates an instance that can be served by the pool and wrap it in aPooledObjectto be managed by the pool.voidpassivateObject(PooledObject<LdapConnection> pooledObject)Uninitializes an instance to be returned to the idle object pool.-
Methods inherited from class org.apache.directory.ldap.client.api.AbstractPoolableLdapConnectionFactory
destroyObject, getLdapApiService, newLdapConnectionFactory, setValidator, validateObject
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.pool2.PooledObjectFactory
destroyObject
-
-
-
-
Constructor Detail
-
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. TheconnectionFactoryClassmust have a public constructor accepting anLdapConnectionConfigobject or anIllegalArgumentExceptionwill be thrown.- Parameters:
config- the configuration for creating LdapConnectionsconnectionFactoryClass- An implementation class of for the LDAP connection factory.- Throws:
IllegalArgumentException- If the instantiation of an instance of theconnectionFactoryClassfails.
-
ValidatingPoolableLdapConnectionFactory
public ValidatingPoolableLdapConnectionFactory(LdapConnectionFactory connectionFactory)
Creates a new instance of ValidatingPoolableLdapConnectionFactory.- Parameters:
connectionFactory- the connection factory for creating LdapConnections
-
-
Method Detail
-
activateObject
public void activateObject(PooledObject<LdapConnection> pooledObject) throws LdapException
Reinitializes an instance to be returned by the pool. There is nothing to do to activate a connection. There is nothing to do to activate a connection.- Specified by:
activateObjectin interfacePooledObjectFactory<LdapConnection>- Overrides:
activateObjectin classAbstractPoolableLdapConnectionFactory- Parameters:
pooledObject- aPooledObjectwrapping the instance to be activated- Throws:
LdapException- See Also:
PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)
-
makeObject
public PooledObject<LdapConnection> makeObject() throws LdapException
Creates an instance that can be served by the pool and wrap it in aPooledObjectto be managed by the pool. 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:
makeObjectin interfacePooledObjectFactory<LdapConnection>- Overrides:
makeObjectin classAbstractPoolableLdapConnectionFactory- Returns:
- a
PooledObjectwrapping an instance that can be served by the pool - Throws:
LdapException- If unable to connect.
-
passivateObject
public void passivateObject(PooledObject<LdapConnection> pooledObject) throws LdapException
Uninitializes an instance to be returned to the idle object pool. 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:
passivateObjectin interfacePooledObjectFactory<LdapConnection>- Overrides:
passivateObjectin classAbstractPoolableLdapConnectionFactory- Parameters:
pooledObject- aPooledObjectwrapping the instance to be passivated- Throws:
LdapException- If unable to reconfigure and rebind.- See Also:
PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)
-
-