Package org.forgerock.opendj.ldap
Interface ConnectionFactory
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
LdapConnectionFactory
public interface ConnectionFactory extends Closeable
A connection factory provides an interface for obtaining a connection to a Directory Server. Connection factories can be used to wrap other connection factories in order to provide enhanced capabilities in a manner which is transparent to the application. For example:- Connection pooling
- Load balancing
- Keep alive
- Transactional connections
- Connections to LDIF files
- Data transformations
- Logging connections
- Read-only connections
- Pre-authenticated connections
- Recording connections, with primitive roll-back functionality
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Releases any resources associated with this connection factory.Connection
getConnection()
Returns a connection to the Directory Server associated with this connection factory.Promise<Connection,LdapException>
getConnectionAsync()
Asynchronously obtains a connection to the Directory Server associated with this connection factory.
-
-
-
Method Detail
-
close
void close()
Releases any resources associated with this connection factory. Depending on the implementation a factory may:- do nothing
- close underlying connection factories (e.g. load-balancers)
- close pooled connections (e.g. connection pools)
- shutdown IO event service and related thread pools.
close
on a connection factory which is already closed has no effect.Applications should avoid closing connection factories while there are remaining active connections in use or connection attempts in progress.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- See Also:
Connections.uncloseable(ConnectionFactory)
-
getConnectionAsync
Promise<Connection,LdapException> getConnectionAsync()
Asynchronously obtains a connection to the Directory Server associated with this connection factory. The returnedPromise
can be used to retrieve the completed connection.- Returns:
- A promise which can be used to retrieve the connection.
-
getConnection
Connection getConnection() throws LdapException
Returns a connection to the Directory Server associated with this connection factory. The connection returned by this method can be used immediately.If the calling thread is interrupted while waiting for the connection attempt to complete then the calling thread unblock and throw a
CancelledResultException
whose cause is the underlyingInterruptedException
.- Returns:
- A connection to the Directory Server associated with this connection factory.
- Throws:
LdapException
- If the connection request failed for some reason.
-
-