Class DefaultLdapConnectionFactory
java.lang.Object
org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionCreates a new instance of DefaultLdapConnectionFactory. -
Method Summary
Modifier and TypeMethodDescriptionbindConnection(LdapConnection connection) Issues a bind request on the supplied connection using the name and credentials from the LdapConnectionConfg supplied to the constructor.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.org.apache.directory.api.ldap.codec.api.LdapApiServiceReturns the LdapApiService instance used by this factory.Returns a newly created, configured, and authenticated connection.Returns a newly created connection, that has not been bound (bind) that otherwise respects LdapConnectionConfig supplied to the constructor.voidsetLdapApiService(org.apache.directory.api.ldap.codec.api.LdapApiService apiService) Sets the LdapApiService (codec) to be used by the connections created by this factory.voidsetTimeOut(long timeout) Sets the timeout that will be used by all connections created by this factory.
-
Constructor Details
-
DefaultLdapConnectionFactory
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:
bindConnectionin interfaceLdapConnectionFactory- 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
Applies the following configuration settings from the LdapConnectionConfig to the supplied connection:- timeOut
- binaryAttributeDetector
- Specified by:
configureConnectionin interfaceLdapConnectionFactory- 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:
getLdapApiServicein interfaceLdapConnectionFactory- Returns:
- The LdapApiService instance used by this factory
-
newLdapConnection
public LdapConnection newLdapConnection() throws org.apache.directory.api.ldap.model.exception.LdapExceptionReturns a newly created, configured, and authenticated connection. This method should be used by a connection pool to manufacture the pooled instances.- Specified by:
newLdapConnectionin interfaceLdapConnectionFactory- 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
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:
newUnboundLdapConnectionin interfaceLdapConnectionFactory- 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:
-