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 ConnectionFactory
Connection factory to get a connection from.private SearchOperationHandle
Search operation handle.protected final org.slf4j.Logger
Logger 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 boolean
Whether the sync repl search has received a result response.private final boolean
Controls 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.void
close()
Closes the connection factory.Returns the connection factory.boolean
Returns 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
.void
setOnEntry
(Consumer<LdapEntry> consumer) Sets the onEntry consumer.void
setOnException
(Consumer<Exception> consumer) Sets the onException consumer.void
setOnMessage
(Consumer<SyncInfoMessage> consumer) Sets the onMessage consumer.void
setOnResult
(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
-