Package org.ldaptive
Class DefaultConnectionFactory.DefaultConnection
- java.lang.Object
-
- org.ldaptive.DefaultConnectionFactory.DefaultConnection
-
- All Implemented Interfaces:
AutoCloseable
,Connection
- Enclosing class:
- DefaultConnectionFactory
protected static class DefaultConnectionFactory.DefaultConnection extends Object implements Connection
Default implementation for managing a connection to an LDAP.
-
-
Field Summary
Fields Modifier and Type Field Description private ConnectionConfig
config
Connection configuration.protected Logger
logger
Logger for this class.private ProviderConnection
providerConnection
Provider connection.private ProviderConnectionFactory<?>
providerConnectionFactory
Connection factory.
-
Constructor Summary
Constructors Constructor Description DefaultConnection(ConnectionConfig cc, ProviderConnectionFactory<?> cf)
Creates a new default connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This will close the connection to the LDAP.void
close(RequestControl[] controls)
This will close the connection to the LDAP using the supplied controls.protected void
finalize()
ConnectionConfig
getConnectionConfig()
Returns the connection config for this connection.ProviderConnection
getProviderConnection()
Returns the provider specific connection.boolean
isOpen()
Returns whether the underlying provider connection is not null.Response<Void>
open()
This will establish a connection if one does not already exist.Response<Void>
open(BindRequest request)
This will establish a connection if one does not already exist and bind to the LDAP using the supplied bind request.Response<Void>
reopen()
This will close an existing connection to the LDAP and establish a new connection to the LDAP.Response<Void>
reopen(BindRequest request)
This will close an existing connection to the LDAP and establish a new connection to the LDAP using the supplied bind request.String
toString()
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
config
private final ConnectionConfig config
Connection configuration.
-
providerConnectionFactory
private final ProviderConnectionFactory<?> providerConnectionFactory
Connection factory.
-
providerConnection
private ProviderConnection providerConnection
Provider connection.
-
-
Constructor Detail
-
DefaultConnection
public DefaultConnection(ConnectionConfig cc, ProviderConnectionFactory<?> cf)
Creates a new default connection.- Parameters:
cc
- connection configurationcf
- provider connection factory
-
-
Method Detail
-
getConnectionConfig
public ConnectionConfig getConnectionConfig()
Description copied from interface:Connection
Returns the connection config for this connection. The config may be read-only.- Specified by:
getConnectionConfig
in interfaceConnection
- Returns:
- connection config
-
getProviderConnection
public ProviderConnection getProviderConnection()
Returns the provider specific connection. Must be called after a successful call toopen()
.- Specified by:
getProviderConnection
in interfaceConnection
- Returns:
- provider connection
- Throws:
IllegalStateException
- if the connection is not open
-
open
public Response<Void> open() throws LdapException
This will establish a connection if one does not already exist. This connection should be closed usingclose()
.- Specified by:
open
in interfaceConnection
- Returns:
- response associated with the
ConnectionInitializer
or an empty response if no connection initializer was configured - Throws:
IllegalStateException
- if the connection is already openLdapException
- if the LDAP cannot be reached
-
open
public Response<Void> open(BindRequest request) throws LdapException
This will establish a connection if one does not already exist and bind to the LDAP using the supplied bind request. This connection should be closed usingclose()
.- Specified by:
open
in interfaceConnection
- Parameters:
request
- bind request- Returns:
- response associated with the bind operation
- Throws:
IllegalStateException
- if the connection is already openLdapException
- if the LDAP cannot be reached
-
isOpen
public boolean isOpen()
Returns whether the underlying provider connection is not null.- Specified by:
isOpen
in interfaceConnection
- Returns:
- whether the provider connection has been initialized
-
close
public void close()
Description copied from interface:Connection
This will close the connection to the LDAP.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
-
close
public void close(RequestControl[] controls)
Description copied from interface:Connection
This will close the connection to the LDAP using the supplied controls.- Specified by:
close
in interfaceConnection
- Parameters:
controls
- request controls
-
reopen
public Response<Void> reopen() throws LdapException
Description copied from interface:Connection
This will close an existing connection to the LDAP and establish a new connection to the LDAP.- Specified by:
reopen
in interfaceConnection
- Returns:
- response associated with the
ConnectionInitializer
or an empty response if no connection initializer was configured - Throws:
LdapException
- if the LDAP cannot be reached
-
reopen
public Response<Void> reopen(BindRequest request) throws LdapException
Description copied from interface:Connection
This will close an existing connection to the LDAP and establish a new connection to the LDAP using the supplied bind request.- Specified by:
reopen
in interfaceConnection
- Parameters:
request
- containing bind information- Returns:
- response associated with the bind operation
- Throws:
LdapException
- if the LDAP cannot be reached
-
-