Package org.ldaptive
Class ConnectionConfig
- java.lang.Object
-
- org.ldaptive.AbstractFreezable
-
- org.ldaptive.AbstractConfig
-
- org.ldaptive.ConnectionConfig
-
- All Implemented Interfaces:
Freezable
public final class ConnectionConfig extends AbstractConfig
Contains all the configuration data needed to control connections.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionConfig.Builder
-
Field Summary
Fields Modifier and Type Field Description private boolean
autoRead
Whether data will be read from the socket as it arrives or only after each LDAP message is consumed.private boolean
autoReconnect
Whether to automatically reconnect to the server when a connection is lost.private Predicate<RetryMetadata>
autoReconnectCondition
Condition used to determine whether another reconnect attempt should be made.private boolean
autoReplay
Whether pending operations should be replayed after a reconnect.private ConnectionInitializer[]
connectionInitializers
Connection initializers to execute onConnection.open()
.private ConnectionStrategy
connectionStrategy
Connection strategy.private ConnectionValidator
connectionValidator
Connection validator.private Duration
connectTimeout
Duration of time that connects will block.static Predicate<RetryMetadata>
INFINITE_RECONNECT_ATTEMPTS
Predicate that attempts to reconnect forever, waiting for 5 seconds after the first attempt.static Predicate<RetryMetadata>
INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
Predicate that attempts to reconnect forever, backing off in 5 second intervals after the first attempt.private String
ldapUrl
URL to the LDAP(s).static Predicate<RetryMetadata>
ONE_RECONNECT_ATTEMPT
Predicate that attempts a single reconnect.private Duration
reconnectTimeout
Duration of time that operations will block on reconnects, should generally be longer thanconnectTimeout
.private Duration
responseTimeout
Duration of time to wait for responses.private SslConfig
sslConfig
Configuration for SSL and startTLS connections.private Duration
startTLSTimeout
Duration of time to wait for startTLS responses.private Map<String,Object>
transportOptions
Transport options.private boolean
useStartTLS
Connect to LDAP using startTLS.-
Fields inherited from class org.ldaptive.AbstractConfig
logger
-
-
Constructor Summary
Constructors Constructor Description ConnectionConfig()
Default constructor.ConnectionConfig(String url)
Creates a new connection config.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConnectionConfig.Builder
builder()
Creates a builder for this class.static ConnectionConfig
copy(ConnectionConfig config)
Returns a new connection config initialized with the supplied config.void
freeze()
Freezes this object, making it immutable.boolean
getAutoRead()
Returns whether data will be read from the socket as it arrives or only after each LDAP message is consumed.boolean
getAutoReconnect()
Returns whether connections will attempt to reconnect.Predicate<RetryMetadata>
getAutoReconnectCondition()
Returns the auto reconnect condition.boolean
getAutoReplay()
Returns whether operations should be replayed after a reconnect.ConnectionInitializer[]
getConnectionInitializers()
Returns the connection initializers.ConnectionStrategy
getConnectionStrategy()
Returns the connection strategy.ConnectionValidator
getConnectionValidator()
Returns the connection validator.Duration
getConnectTimeout()
Returns the connect timeout.String
getLdapUrl()
Returns the ldap url.Duration
getReconnectTimeout()
Returns the reconnect timeout.Duration
getResponseTimeout()
Returns the response timeout.SslConfig
getSslConfig()
Returns the ssl config.Duration
getStartTLSTimeout()
Returns the startTLS timeout.Object
getTransportOption(String id)
Returns a transport option.Map<String,?>
getTransportOptions()
Returns transport options.boolean
getUseStartTLS()
Returns whether startTLS will be used for connections.void
setAutoRead(boolean b)
Sets whether data will be read from the socket as it arrives or only after each LDAP message is consumed.void
setAutoReconnect(boolean b)
Sets whether connections will attempt to reconnect when unexpectedly closed.void
setAutoReconnectCondition(Predicate<RetryMetadata> predicate)
Sets the auto reconnect condition.void
setAutoReplay(boolean b)
Sets whether operations will be replayed after a reconnect.void
setConnectionInitializers(ConnectionInitializer... initializers)
Sets the connection initializers.void
setConnectionStrategy(ConnectionStrategy strategy)
Sets the connection strategy.void
setConnectionValidator(ConnectionValidator validator)
Sets the connection validator.void
setConnectTimeout(Duration time)
Sets the maximum amount of time that connects will block.void
setLdapUrl(String url)
Sets the ldap url.void
setReconnectTimeout(Duration time)
Sets the maximum amount of time that operations will block waiting for a reconnect.void
setResponseTimeout(Duration time)
Sets the maximum amount of time that operations will wait for a response.void
setSslConfig(SslConfig config)
Sets the ssl config.void
setStartTLSTimeout(Duration time)
Sets the maximum amount of time that startTLS operations will wait for a response.void
setTransportOption(String id, Object value)
Sets a transport option.void
setTransportOptions(Map<String,?> options)
Sets transport options.void
setUseStartTLS(boolean b)
Sets whether startTLS will be used for connections.String
toString()
-
Methods inherited from class org.ldaptive.AbstractConfig
checkArrayContainsNull, checkStringInput
-
Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, isFrozen
-
-
-
-
Field Detail
-
ONE_RECONNECT_ATTEMPT
public static final Predicate<RetryMetadata> ONE_RECONNECT_ATTEMPT
Predicate that attempts a single reconnect.
-
INFINITE_RECONNECT_ATTEMPTS
public static final Predicate<RetryMetadata> INFINITE_RECONNECT_ATTEMPTS
Predicate that attempts to reconnect forever, waiting for 5 seconds after the first attempt.
-
INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
public static final Predicate<RetryMetadata> INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
Predicate that attempts to reconnect forever, backing off in 5 second intervals after the first attempt.
-
ldapUrl
private String ldapUrl
URL to the LDAP(s).
-
connectTimeout
private Duration connectTimeout
Duration of time that connects will block.
-
startTLSTimeout
private Duration startTLSTimeout
Duration of time to wait for startTLS responses.
-
responseTimeout
private Duration responseTimeout
Duration of time to wait for responses.
-
reconnectTimeout
private Duration reconnectTimeout
Duration of time that operations will block on reconnects, should generally be longer thanconnectTimeout
.
-
autoReconnect
private boolean autoReconnect
Whether to automatically reconnect to the server when a connection is lost. Default is true.
-
autoReconnectCondition
private Predicate<RetryMetadata> autoReconnectCondition
Condition used to determine whether another reconnect attempt should be made. Default makes a single attempt only if the connection was previously opened.
-
autoReplay
private boolean autoReplay
Whether pending operations should be replayed after a reconnect. Default is false.
-
autoRead
private boolean autoRead
Whether data will be read from the socket as it arrives or only after each LDAP message is consumed. Default is true.
-
sslConfig
private SslConfig sslConfig
Configuration for SSL and startTLS connections.
-
useStartTLS
private boolean useStartTLS
Connect to LDAP using startTLS.
-
connectionInitializers
private ConnectionInitializer[] connectionInitializers
Connection initializers to execute onConnection.open()
.
-
connectionStrategy
private ConnectionStrategy connectionStrategy
Connection strategy.
-
connectionValidator
private ConnectionValidator connectionValidator
Connection validator.
-
-
Constructor Detail
-
ConnectionConfig
public ConnectionConfig()
Default constructor.
-
ConnectionConfig
public ConnectionConfig(String url)
Creates a new connection config.- Parameters:
url
- to connect to
-
-
Method Detail
-
freeze
public void freeze()
Description copied from interface:Freezable
Freezes this object, making it immutable.- Specified by:
freeze
in interfaceFreezable
- Overrides:
freeze
in classAbstractFreezable
-
getLdapUrl
public String getLdapUrl()
Returns the ldap url.- Returns:
- ldap url
-
setLdapUrl
public void setLdapUrl(String url)
Sets the ldap url.- Parameters:
url
- of the ldap
-
getConnectTimeout
public Duration getConnectTimeout()
Returns the connect timeout.- Returns:
- timeout
-
setConnectTimeout
public void setConnectTimeout(Duration time)
Sets the maximum amount of time that connects will block.- Parameters:
time
- timeout for connects
-
getStartTLSTimeout
public Duration getStartTLSTimeout()
Returns the startTLS timeout.- Returns:
- timeout
-
setStartTLSTimeout
public void setStartTLSTimeout(Duration time)
Sets the maximum amount of time that startTLS operations will wait for a response.- Parameters:
time
- timeout for responses
-
getResponseTimeout
public Duration getResponseTimeout()
Returns the response timeout.- Returns:
- timeout
-
setResponseTimeout
public void setResponseTimeout(Duration time)
Sets the maximum amount of time that operations will wait for a response.- Parameters:
time
- timeout for responses
-
getReconnectTimeout
public Duration getReconnectTimeout()
Returns the reconnect timeout.- Returns:
- timeout
-
setReconnectTimeout
public void setReconnectTimeout(Duration time)
Sets the maximum amount of time that operations will block waiting for a reconnect.- Parameters:
time
- timeout for reconnects
-
getAutoReconnect
public boolean getAutoReconnect()
Returns whether connections will attempt to reconnect.- Returns:
- whether to automatically reconnect when a connection is lost
-
setAutoReconnect
public void setAutoReconnect(boolean b)
Sets whether connections will attempt to reconnect when unexpectedly closed.- Parameters:
b
- whether to automatically reconnect when a connection is lost
-
getAutoReconnectCondition
public Predicate<RetryMetadata> getAutoReconnectCondition()
Returns the auto reconnect condition.- Returns:
- auto reconnect condition
-
setAutoReconnectCondition
public void setAutoReconnectCondition(Predicate<RetryMetadata> predicate)
Sets the auto reconnect condition.- Parameters:
predicate
- to determine whether to attempt a reconnect
-
getAutoReplay
public boolean getAutoReplay()
Returns whether operations should be replayed after a reconnect.- Returns:
- whether to auto replay
-
setAutoReplay
public void setAutoReplay(boolean b)
Sets whether operations will be replayed after a reconnect.- Parameters:
b
- whether to replay operations
-
getAutoRead
public boolean getAutoRead()
Returns whether data will be read from the socket as it arrives or only after each LDAP message is consumed.- Returns:
- whether to auto read data from the socket
-
setAutoRead
public void setAutoRead(boolean b)
Sets whether data will be read from the socket as it arrives or only after each LDAP message is consumed.- Parameters:
b
- whether to auto read data from the socket
-
getSslConfig
public SslConfig getSslConfig()
Returns the ssl config.- Returns:
- ssl config
-
setSslConfig
public void setSslConfig(SslConfig config)
Sets the ssl config.- Parameters:
config
- ssl config
-
getUseStartTLS
public boolean getUseStartTLS()
Returns whether startTLS will be used for connections.- Returns:
- whether startTLS will be used
-
setUseStartTLS
public void setUseStartTLS(boolean b)
Sets whether startTLS will be used for connections.- Parameters:
b
- whether startTLS will be used
-
getConnectionInitializers
public ConnectionInitializer[] getConnectionInitializers()
Returns the connection initializers.- Returns:
- connection initializers
-
setConnectionInitializers
public void setConnectionInitializers(ConnectionInitializer... initializers)
Sets the connection initializers.- Parameters:
initializers
- connection initializers
-
getConnectionStrategy
public ConnectionStrategy getConnectionStrategy()
Returns the connection strategy.- Returns:
- strategy for making connections
-
setConnectionStrategy
public void setConnectionStrategy(ConnectionStrategy strategy)
Sets the connection strategy.- Parameters:
strategy
- for making new connections
-
getConnectionValidator
public ConnectionValidator getConnectionValidator()
Returns the connection validator.- Returns:
- connection validator
-
setConnectionValidator
public void setConnectionValidator(ConnectionValidator validator)
Sets the connection validator.- Parameters:
validator
- for validating connections
-
getTransportOptions
public Map<String,?> getTransportOptions()
Returns transport options.- Returns:
- transport options
-
setTransportOptions
public void setTransportOptions(Map<String,?> options)
Sets transport options.- Parameters:
options
- to set
-
getTransportOption
public Object getTransportOption(String id)
Returns a transport option.- Parameters:
id
- transport option id- Returns:
- transport option
-
setTransportOption
public void setTransportOption(String id, Object value)
Sets a transport option.- Parameters:
id
- of the transport optionvalue
- of the transport option
-
copy
public static ConnectionConfig copy(ConnectionConfig config)
Returns a new connection config initialized with the supplied config.- Parameters:
config
- connection config to read properties from- Returns:
- connection config
-
builder
public static ConnectionConfig.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-