Package org.ldaptive.control.util
Class SyncReplClient
java.lang.Object
org.ldaptive.control.util.SyncReplClient
Client that simplifies using the sync repl control.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConnectionFactoryConnection factory to get a connection from.private SearchOperationHandleSearch operation handle.protected final org.slf4j.LoggerLogger for this class.Invoked when an entry is received.Invoked when an exception is received.private Consumer<SyncInfoMessage>Invoked when a sync info message is received.Invoked when a result is received.private booleanWhether the sync repl search has received a result response.private final booleanControls which mode the sync repl control should use. -
Constructor Summary
ConstructorsConstructorDescriptionSyncReplClient(ConnectionFactory cf, boolean persist) Creates a new sync repl client. -
Method Summary
Modifier and TypeMethodDescriptioncancel()Sends a cancel operation on the underlying search operation.voidclose()Closes the connection factory.Returns the connection factory.booleanReturns whether a search result has been received by this client.send(SearchRequest request) Invokessend(SearchRequest, CookieManager)with aDefaultCookieManager.send(SearchRequest request, CookieManager manager) Performs an async search operation with theSyncRequestControl.voidsetOnEntry(Consumer<LdapEntry> consumer) Sets the onEntry consumer.voidsetOnException(Consumer<Exception> consumer) Sets the onException consumer.voidsetOnMessage(Consumer<SyncInfoMessage> consumer) Sets the onMessage consumer.voidsetOnResult(Consumer<Result> consumer) Sets the onResult consumer.toString()
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for this class. -
factory
Connection factory to get a connection from. -
refreshAndPersist
private final boolean refreshAndPersistControls which mode the sync repl control should use. -
handle
Search operation handle. -
onEntry
Invoked when an entry is received. -
onResult
Invoked when a result is received. -
onMessage
Invoked when a sync info message is received. -
onException
Invoked when an exception is received. -
receivedResult
private boolean receivedResultWhether the sync repl search has received a result response.
-
-
Constructor Details
-
SyncReplClient
Creates a new sync repl client.- Parameters:
cf- to get a connection frompersist- whether to refresh and persist or just refresh
-
-
Method Details
-
getConnectionFactory
Returns the connection factory.- Returns:
- connection factory
-
setOnEntry
Sets the onEntry consumer.- Parameters:
consumer- to invoke when an entry is received
-
setOnResult
Sets the onResult consumer.- Parameters:
consumer- to invoke when a result is received
-
setOnMessage
Sets the onMessage consumer.- Parameters:
consumer- to invoke when a sync info message is received
-
setOnException
Sets the onException consumer.- Parameters:
consumer- to invoke when a sync info message is received
-
send
Invokessend(SearchRequest, CookieManager)with aDefaultCookieManager.- Parameters:
request- search request to execute- Returns:
- search operation handle
- Throws:
LdapException- if the search fails
-
send
public SearchOperationHandle send(SearchRequest request, CookieManager manager) throws LdapException Performs an async search operation with theSyncRequestControl. The supplied request is modified in the following way:AbstractRequestMessage.setControls(org.ldaptive.control.RequestControl...)is invoked withSyncRequestControl
The search request object should not be reused for any other search operations.
- Parameters:
request- search request to executemanager- for reading and writing cookies- Returns:
- search operation handle
- Throws:
LdapException- if the search fails
-
isComplete
public boolean isComplete()Returns whether a search result has been received by this client.- Returns:
- whether a search result has been received
-
cancel
Sends a cancel operation on the underlying search operation. SeeDefaultOperationHandle.cancel().- Returns:
- cancel operation result
-
close
public void close()Closes the connection factory. -
toString
-