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 andLdapApiService
as well as the standardLdapConnectionConfig
.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description DefaultLdapConnectionFactory(LdapConnectionConfig config)
Creates a new instance of DefaultLdapConnectionFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LdapConnection
bindConnection(LdapConnection connection)
Issues a bind request on the supplied connection using the name and credentials from the LdapConnectionConfg supplied to the constructor.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.LdapApiService
getLdapApiService()
Returns the LdapApiService instance used by this factory.LdapConnection
newLdapConnection()
Returns a newly created, configured, and authenticated connection.LdapConnection
newUnboundLdapConnection()
Returns a newly created connection, that has not been bound (bind) that otherwise respects LdapConnectionConfig supplied to the constructor.void
setLdapApiService(LdapApiService apiService)
Sets the LdapApiService (codec) to be used by the connections created by this factory.void
setTimeOut(long timeout)
Sets the timeout that will be used by all connections created by this factory.
-
-
-
Constructor Detail
-
DefaultLdapConnectionFactory
public DefaultLdapConnectionFactory(LdapConnectionConfig config)
Creates a new instance of DefaultLdapConnectionFactory.- Parameters:
config
- The connection config.
-
-
Method Detail
-
bindConnection
public LdapConnection bindConnection(LdapConnection connection) throws 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 interfaceLdapConnectionFactory
- Parameters:
connection
- The connection to bind with the configuration credentials.- Returns:
- The connection supplied.
- Throws:
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
- Specified by:
configureConnection
in interfaceLdapConnectionFactory
- Parameters:
connection
- The connection to configure- Returns:
- The supplied connection.
-
getLdapApiService
public LdapApiService getLdapApiService()
Returns the LdapApiService instance used by this factory.- Specified by:
getLdapApiService
in interfaceLdapConnectionFactory
- Returns:
- The LdapApiService instance used by this factory
-
newLdapConnection
public LdapConnection newLdapConnection() throws 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 interfaceLdapConnectionFactory
- Returns:
- A newly created, configured, and authenticated LdapConnection.
- Throws:
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 interfaceLdapConnectionFactory
- Returns:
- A newly created and configured LdapConnection.
-
setLdapApiService
public void setLdapApiService(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:
LdapConnection.setTimeOut(long)
-
-