Package org.ldaptive
Class AbstractConnectionValidator
java.lang.Object
org.ldaptive.AbstractFreezable
org.ldaptive.AbstractConnectionValidator
- All Implemented Interfaces:
Function<Connection,,Boolean> ConnectionValidator,Freezable
- Direct Known Subclasses:
AbstractOperationConnectionValidator
public abstract class AbstractConnectionValidator
extends AbstractFreezable
implements ConnectionValidator
Base class for connection validator implementations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classBase class for validator builders. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationDefault validation period, value is 30 minutes.static final DurationDefault per connection validate timeout, value is 5 seconds.protected final LoggerLogger for this class.private Consumer<Connection>Consumer to execute on a failed validation.private Consumer<Connection>Consumer to execute on a successful validation.private booleanWhether the occurrence of a timeout should result in a validation failure.private DurationValidation period.private DurationMaximum length of time a connection validation should block. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(Connection conn) applyAsync(Connection conn) Provides an asynchronous implementation ofFunction.apply(Object).Returns a consumer to handle a connection that has failed validation.Returns a consumer to handle a connection that has been successfully validated.booleanReturns whether a timeout should be considered a validation failure.Returns the interval at which the validation task will be executed.Returns the duration at which a validate operation should be abandoned.voidsetOnFailure(Consumer<Connection> consumer) Sets a consumer to handle a connection that has failed validation.voidsetOnSuccess(Consumer<Connection> consumer) Sets a consumer to handle a connection that has been successfully validated.voidsetTimeoutIsFailure(boolean failure) Sets whether a timeout should be considered a validation failure.voidsetValidatePeriod(Duration period) Sets the validate period.voidsetValidateTimeout(Duration timeout) Sets the validate timeout.toString()Methods inherited from class org.ldaptive.AbstractFreezable
assertMutable, freeze, freeze, freeze, isFrozenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ldaptive.ConnectionValidator
applyAsync
-
Field Details
-
DEFAULT_VALIDATE_PERIOD
Default validation period, value is 30 minutes. -
DEFAULT_VALIDATE_TIMEOUT
Default per connection validate timeout, value is 5 seconds. -
logger
Logger for this class. -
validatePeriod
Validation period. -
validateTimeout
Maximum length of time a connection validation should block. -
onSuccess
Consumer to execute on a successful validation. -
onFailure
Consumer to execute on a failed validation. -
timeoutIsFailure
private boolean timeoutIsFailureWhether the occurrence of a timeout should result in a validation failure.
-
-
Constructor Details
-
AbstractConnectionValidator
public AbstractConnectionValidator()
-
-
Method Details
-
getValidatePeriod
Description copied from interface:ConnectionValidatorReturns the interval at which the validation task will be executed.- Specified by:
getValidatePeriodin interfaceConnectionValidator- Returns:
- validation period
-
setValidatePeriod
Sets the validate period.- Parameters:
period- at which to validate
-
getValidateTimeout
Description copied from interface:ConnectionValidatorReturns the duration at which a validate operation should be abandoned.- Specified by:
getValidateTimeoutin interfaceConnectionValidator- Returns:
- validation timeout
-
setValidateTimeout
Sets the validate timeout.- Parameters:
timeout- to set
-
getOnSuccess
Returns a consumer to handle a connection that has been successfully validated.- Returns:
- success consumer
-
setOnSuccess
Sets a consumer to handle a connection that has been successfully validated.- Parameters:
consumer- to invoke on success
-
getOnFailure
Returns a consumer to handle a connection that has failed validation.- Returns:
- failure consumer
-
setOnFailure
Sets a consumer to handle a connection that has failed validation.- Parameters:
consumer- to invoke on failure
-
getTimeoutIsFailure
public boolean getTimeoutIsFailure()Returns whether a timeout should be considered a validation failure.- Returns:
- whether a timeout should be considered a validation failure
-
setTimeoutIsFailure
public void setTimeoutIsFailure(boolean failure) Sets whether a timeout should be considered a validation failure.- Parameters:
failure- whether a timeout should be considered a validation failure
-
apply
- Specified by:
applyin interfaceFunction<Connection,Boolean>
-
applyAsync
Description copied from interface:ConnectionValidatorProvides an asynchronous implementation ofFunction.apply(Object). The returned supplier will block until a validation result is received respectingConnectionValidator.getValidateTimeout().- Specified by:
applyAsyncin interfaceConnectionValidator- Parameters:
conn- to validate- Returns:
- supplier to retrieve the validation result
-
toString
-