Package org.ldaptive
Class ConnectionConfig
- java.lang.Object
-
- org.ldaptive.AbstractConfig
-
- org.ldaptive.ConnectionConfig
-
public class ConnectionConfig extends AbstractConfig
Contains all the configuration data needed to control connections.- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConnectionConfig.Builder
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Predicate<RetryMetadata>
INFINITE_RECONNECT_ATTEMPTS
Predicate that attempts to reconnect forever, waiting for 5 seconds after the first attempt.static java.util.function.Predicate<RetryMetadata>
INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
Predicate that attempts to reconnect forever, backing off in 5 second intervals after the first attempt.static java.util.function.Predicate<RetryMetadata>
ONE_RECONNECT_ATTEMPT
Predicate that attempts a single reconnect.-
Fields inherited from class org.ldaptive.AbstractConfig
logger
-
-
Constructor Summary
Constructors Constructor Description ConnectionConfig()
Default constructor.ConnectionConfig(java.lang.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.boolean
getAutoReconnect()
Returns whether connections will attempt to reconnect.java.util.function.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.java.time.Duration
getConnectTimeout()
Returns the connect timeout.java.lang.String
getLdapUrl()
Returns the ldap url.java.time.Duration
getReconnectTimeout()
Returns the reconnect timeout.java.time.Duration
getResponseTimeout()
Returns the response timeout.SslConfig
getSslConfig()
Returns the ssl config.java.lang.Object
getTransportOption(java.lang.String id)
Returns a transport option.java.util.Map<java.lang.String,?>
getTransportOptions()
Returns transport options.boolean
getUseStartTLS()
Returns whether startTLS will be used for connections.void
setAutoReconnect(boolean b)
Sets whether connections will attempt to reconnect when unexpectedly closed.void
setAutoReconnectCondition(java.util.function.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(java.time.Duration time)
Sets the maximum amount of time that connects will block.void
setLdapUrl(java.lang.String url)
Sets the ldap url.void
setReconnectTimeout(java.time.Duration time)
Sets the maximum amount of time that operations will block waiting for a reconnect.void
setResponseTimeout(java.time.Duration time)
Sets the maximum amount of time that operations will wait for a response.void
setSslConfig(SslConfig config)
Sets the ssl config.void
setTransportOption(java.lang.String id, java.lang.Object value)
Sets a transport option.void
setTransportOptions(java.util.Map<java.lang.String,?> options)
Sets transport options.void
setUseStartTLS(boolean b)
Sets whether startTLS will be used for connections.java.lang.String
toString()
-
Methods inherited from class org.ldaptive.AbstractConfig
checkArrayContainsNull, checkImmutable, checkStringInput, makeImmutable
-
-
-
-
Field Detail
-
ONE_RECONNECT_ATTEMPT
public static final java.util.function.Predicate<RetryMetadata> ONE_RECONNECT_ATTEMPT
Predicate that attempts a single reconnect.
-
INFINITE_RECONNECT_ATTEMPTS
public static final java.util.function.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 java.util.function.Predicate<RetryMetadata> INFINITE_RECONNECT_ATTEMPTS_WITH_BACKOFF
Predicate that attempts to reconnect forever, backing off in 5 second intervals after the first attempt.
-
-
Method Detail
-
getLdapUrl
public java.lang.String getLdapUrl()
Returns the ldap url.- Returns:
- ldap url
-
setLdapUrl
public void setLdapUrl(java.lang.String url)
Sets the ldap url.- Parameters:
url
- of the ldap
-
getConnectTimeout
public java.time.Duration getConnectTimeout()
Returns the connect timeout.- Returns:
- timeout
-
setConnectTimeout
public void setConnectTimeout(java.time.Duration time)
Sets the maximum amount of time that connects will block.- Parameters:
time
- timeout for connects
-
getResponseTimeout
public java.time.Duration getResponseTimeout()
Returns the response timeout.- Returns:
- timeout
-
setResponseTimeout
public void setResponseTimeout(java.time.Duration time)
Sets the maximum amount of time that operations will wait for a response.- Parameters:
time
- timeout for responses
-
getReconnectTimeout
public java.time.Duration getReconnectTimeout()
Returns the reconnect timeout.- Returns:
- timeout
-
setReconnectTimeout
public void setReconnectTimeout(java.time.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 java.util.function.Predicate<RetryMetadata> getAutoReconnectCondition()
Returns the auto reconnect condition.- Returns:
- auto reconnect condition
-
setAutoReconnectCondition
public void setAutoReconnectCondition(java.util.function.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
-
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 java.util.Map<java.lang.String,?> getTransportOptions()
Returns transport options.- Returns:
- transport options
-
setTransportOptions
public void setTransportOptions(java.util.Map<java.lang.String,?> options)
Sets transport options.- Parameters:
options
- to set
-
getTransportOption
public java.lang.Object getTransportOption(java.lang.String id)
Returns a transport option.- Parameters:
id
- transport option id- Returns:
- transport option
-
setTransportOption
public void setTransportOption(java.lang.String id, java.lang.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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
builder
public static ConnectionConfig.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-