T - The type of documents that this synchronizer can handleS - The type of Edits that this synchronizer can handlepublic interface ClientSynchronizer<T,S extends Edit<? extends Diff>>
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(T content,
com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String fieldName)
Adds the content of the passed in
content to the ObjectNode. |
S |
clientDiff(ShadowDocument<T> shadowDocument,
ClientDocument<T> document)
|
PatchMessage<S> |
createPatchMessage(String documentId,
String clientId,
Queue<S> edits)
Creates a new
PatchMessage with the with the type of Edit that this
synchronizer can handle. |
ClientDocument<T> |
patchDocument(S edit,
ClientDocument<T> document)
Called when the document should be patched.
|
PatchMessage<S> |
patchMessageFromJson(String json)
Creates a {link PatchMessage} by parsing the passed-in json.
|
ShadowDocument<T> |
patchShadow(S edit,
ShadowDocument<T> shadowDocument)
Called when the shadow should be patched.
|
S |
serverDiff(ClientDocument<T> document,
ShadowDocument<T> shadowDocument)
|
ShadowDocument<T> patchShadow(S edit, ShadowDocument<T> shadowDocument)
edit - the Edit containing the diffs/patchesshadowDocument - the ShadowDocument to be patchedShadowDocument a new patched shadow documentClientDocument<T> patchDocument(S edit, ClientDocument<T> document)
edit - the Edit containing the diffs/patchesdocument - the ClientDocument to be patchedClientDocument a new patched document.S serverDiff(ClientDocument<T> document, ShadowDocument<T> shadowDocument)
Edit containing the changes between the updated ClientDocument
and the ShadowDocument.
Calling the method is the first step in when starting a client side synchronization. We need to
gather the changes between the updates made by the client and the shadow document.
The produced Edit can then be passed to the server side.
document - the ClientDocument containing updates made by the clientshadowDocument - the ShadowDocument for the ClientDocumentEdit the edit representing the diff between the client document and it's shadow document.S clientDiff(ShadowDocument<T> shadowDocument, ClientDocument<T> document)
Edit containing the changes between updated ShadowDocument
and the ClientDocument.
This method would be called when the client receives an update from the server and need
to produce an Edit to be able to patch the ClientDocument.shadowDocument - the ShadowDocument patched with updates from the serverdocument - the ClientDocumentEdit the edit representing the diff between the shadow document and the client document.PatchMessage<S> createPatchMessage(String documentId, String clientId, Queue<S> edits)
PatchMessage with the with the type of Edit that this
synchronizer can handle.documentId - the document identifier for the PatchMessageclientId - the client identifier for the PatchMessageedits - the Edits for the PatchMessagePatchMessage the created {code PatchMessage}PatchMessage<S> patchMessageFromJson(String json)
json - the json representation of a PatchMessagePatchMessage the created {code PatchMessage}void addContent(T content, com.fasterxml.jackson.databind.node.ObjectNode objectNode, String fieldName)
content to the ObjectNode.
When a client initially adds a document to the engine it will also be sent across the
wire to the server. Before sending, the content of the document has to be added to the
JSON message payload. Different implementation will require different content types that
the engine can handle and this give them control over how the content is added to the JSON
ObjectNode.
For example, a ClientEngine that stores simple text will just add the contents as a String,
but one that stores JsonNode object will want to add its content as an object.
content - the content to be addedobjectNode - the ObjectNode to add the content tofieldName - the name of the fieldCopyright © 2015 JBoss by Red Hat. All Rights Reserved.