Package com.unboundid.ldap.sdk
Class SingleServerSet
- java.lang.Object
-
- com.unboundid.ldap.sdk.ServerSet
-
- com.unboundid.ldap.sdk.SingleServerSet
-
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class SingleServerSet extends ServerSet
This class provides a server set implementation that only provides the ability to connect to a single server. It may be used in cases where aServerSet
is required but only a single server is needed.
-
-
Constructor Summary
Constructors Constructor Description SingleServerSet(java.lang.String address, int port)
Creates a new single server set with the specified address and port.SingleServerSet(java.lang.String address, int port, LDAPConnectionOptions connectionOptions)
Creates a new single server set with the specified address and port.SingleServerSet(java.lang.String address, int port, javax.net.SocketFactory socketFactory)
Creates a new single server set with the specified address and port, and using the provided socket factory.SingleServerSet(java.lang.String address, int port, javax.net.SocketFactory socketFactory, LDAPConnectionOptions connectionOptions)
Creates a new single server set with the specified address and port, and using the provided socket factory.SingleServerSet(java.lang.String address, int port, javax.net.SocketFactory socketFactory, LDAPConnectionOptions connectionOptions, BindRequest bindRequest, PostConnectProcessor postConnectProcessor)
Creates a new single server set with the specified address and port, and using the provided socket factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAddress()
Retrieves the address of the directory server to which the connections should be established.LDAPConnection
getConnection()
Attempts to establish a connection to one of the directory servers in this server set.LDAPConnection
getConnection(LDAPConnectionPoolHealthCheck healthCheck)
Attempts to establish a connection to one of the directory servers in this server set, using the provided health check to further validate the connection.LDAPConnectionOptions
getConnectionOptions()
Retrieves the set of connection options that will be used by the underlying connections.int
getPort()
Retrieves the port of the directory server to which the connections should be established.javax.net.SocketFactory
getSocketFactory()
Retrieves the socket factory that will be used to establish connections.boolean
includesAuthentication()
Indicates whether connections created by this server set will be authenticated.boolean
includesPostConnectProcessing()
Indicates whether connections created by this server set will have post-connect processing performed.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this server set to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.ServerSet
associateConnectionWithThisServerSet, doBindPostConnectAndHealthCheckProcessing, handleConnectionClosed, shutDown, toString
-
-
-
-
Constructor Detail
-
SingleServerSet
public SingleServerSet(@NotNull java.lang.String address, int port)
Creates a new single server set with the specified address and port. It will use the default socket factory provided by the JVM to create the underlying socket.- Parameters:
address
- The address of the directory server to which the connections should be established. It must not benull
.port
- The port of the directory server to which the connections should be established. It must be between 1 and 65535, inclusive.
-
SingleServerSet
public SingleServerSet(@NotNull java.lang.String address, int port, @Nullable LDAPConnectionOptions connectionOptions)
Creates a new single server set with the specified address and port. It will use the default socket factory provided by the JVM to create the underlying socket.- Parameters:
address
- The address of the directory server to which the connections should be established. It must not benull
.port
- The port of the directory server to which the connections should be established. It must be between 1 and 65535, inclusive.connectionOptions
- The set of connection options to use for the underlying connections.
-
SingleServerSet
public SingleServerSet(@NotNull java.lang.String address, int port, @Nullable javax.net.SocketFactory socketFactory)
Creates a new single server set with the specified address and port, and using the provided socket factory.- Parameters:
address
- The address of the directory server to which the connections should be established. It must not benull
.port
- The port of the directory server to which the connections should be established. It must be between 1 and 65535, inclusive.socketFactory
- The socket factory to use to create the underlying connections.
-
SingleServerSet
public SingleServerSet(@NotNull java.lang.String address, int port, @Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions)
Creates a new single server set with the specified address and port, and using the provided socket factory.- Parameters:
address
- The address of the directory server to which the connections should be established. It must not benull
.port
- The port of the directory server to which the connections should be established. It must be between 1 and 65535, inclusive.socketFactory
- The socket factory to use to create the underlying connections.connectionOptions
- The set of connection options to use for the underlying connections.
-
SingleServerSet
public SingleServerSet(@NotNull java.lang.String address, int port, @Nullable javax.net.SocketFactory socketFactory, @Nullable LDAPConnectionOptions connectionOptions, @Nullable BindRequest bindRequest, @Nullable PostConnectProcessor postConnectProcessor)
Creates a new single server set with the specified address and port, and using the provided socket factory.- Parameters:
address
- The address of the directory server to which the connections should be established. It must not benull
.port
- The port of the directory server to which the connections should be established. It must be between 1 and 65535, inclusive.socketFactory
- The socket factory to use to create the underlying connections.connectionOptions
- The set of connection options to use for the underlying connections.bindRequest
- The bind request that should be used to authenticate newly-established connections. It may benull
if this server set should not perform any authentication.postConnectProcessor
- The post-connect processor that should be invoked on newly-established connections. It may benull
if this server set should not perform any post-connect processing.
-
-
Method Detail
-
getAddress
@NotNull public java.lang.String getAddress()
Retrieves the address of the directory server to which the connections should be established.- Returns:
- The address of the directory server to which the connections should be established.
-
getPort
public int getPort()
Retrieves the port of the directory server to which the connections should be established.- Returns:
- The port of the directory server to which the connections should be established.
-
getSocketFactory
@NotNull public javax.net.SocketFactory getSocketFactory()
Retrieves the socket factory that will be used to establish connections.- Returns:
- The socket factory that will be used to establish connections.
-
getConnectionOptions
@NotNull public LDAPConnectionOptions getConnectionOptions()
Retrieves the set of connection options that will be used by the underlying connections.- Returns:
- The set of connection options that will be used by the underlying connections.
-
includesAuthentication
public boolean includesAuthentication()
Indicates whether connections created by this server set will be authenticated.- Overrides:
includesAuthentication
in classServerSet
- Returns:
true
if connections created by this server set will be authenticated, orfalse
if not.
-
includesPostConnectProcessing
public boolean includesPostConnectProcessing()
Indicates whether connections created by this server set will have post-connect processing performed.- Overrides:
includesPostConnectProcessing
in classServerSet
- Returns:
true
if connections created by this server set will have post-connect processing performed, orfalse
if not.
-
getConnection
@NotNull public LDAPConnection getConnection() throws LDAPException
Attempts to establish a connection to one of the directory servers in this server set. The connection that is returned must be established. TheServerSet.includesAuthentication()
must return true if and only if the connection will also be authenticated, and theServerSet.includesPostConnectProcessing()
method must return true if and only if pre-authentication and post-authentication post-connect processing will have been performed. The caller may determine the server to which the connection is established using theLDAPConnection.getConnectedAddress()
andLDAPConnection.getConnectedPort()
methods.- Specified by:
getConnection
in classServerSet
- Returns:
- An
LDAPConnection
object that is established to one of the servers in this server set. - Throws:
LDAPException
- If it is not possible to establish a connection to any of the servers in this server set.
-
getConnection
@NotNull public LDAPConnection getConnection(@Nullable LDAPConnectionPoolHealthCheck healthCheck) throws LDAPException
Attempts to establish a connection to one of the directory servers in this server set, using the provided health check to further validate the connection. The connection that is returned must be established. TheServerSet.includesAuthentication()
must return true if and only if the connection will also be authenticated, and theServerSet.includesPostConnectProcessing()
method must return true if and only if pre-authentication and post-authentication post-connect processing will have been performed. The caller may determine the server to which the connection is established using theLDAPConnection.getConnectedAddress()
andLDAPConnection.getConnectedPort()
methods.- Overrides:
getConnection
in classServerSet
- Parameters:
healthCheck
- The health check to use to verify the health of the newly-created connection. It may benull
if no additional health check should be performed. If it is non-null
and this server set performs authentication, then the health check'sensureConnectionValidAfterAuthentication
method will be invoked immediately after the bind operation is processed (regardless of whether the bind was successful or not). And regardless of whether this server set performs authentication, the health check'sensureNewConnectionValid
method must be invoked on the connection to ensure that it is valid immediately before it is returned.- Returns:
- An
LDAPConnection
object that is established to one of the servers in this server set. - Throws:
LDAPException
- If it is not possible to establish a connection to any of the servers in this server set.
-
-