com.vaadin.collaborationengine.
Interface CollaborationMessagePersister
-
All Superinterfaces:
public interface CollaborationMessagePersister extends Serializable
Persister of
CollaborationMessage
items, which enables to read and write messages from/to a backend, for example a database.It can be used with a
CollaborationMessageList
to have the component read messages from the backend when attached and write new messages to it when appended to the list with a submitter component, e.g.CollaborationMessageInput
.Since:
3.1
Author:
Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CollaborationMessagePersister.FetchQuery
A query to fetch messages from a backend.
static class
CollaborationMessagePersister.PersistRequest
A request to persist messages to a backend.
-
Method Summary
All Methods Modifier and Type Method Description Stream<CollaborationMessage>
fetchMessages(CollaborationMessagePersister.FetchQuery query)
Reads a stream of
CollaborationMessage
items from a persistence backend.static CollaborationMessagePersister
fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)
Creates an instance of
CollaborationMessagePersister
from the provided callbacks.void
persistMessage(CollaborationMessagePersister.PersistRequest request)
Writes a
CollaborationMessage
to the persistence backend.
-
-
-
Method Detail
-
fromCallbacks
static CollaborationMessagePersister fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)
Creates an instance of
CollaborationMessagePersister
from the provided callbacks.Parameters:
fetchCallback
- the callback to fetch messages, not nullpersistCallback
- the callback to persist messages, not nullReturns:
the persister instance
-
fetchMessages
Stream<CollaborationMessage> fetchMessages(CollaborationMessagePersister.FetchQuery query)
Reads a stream of
CollaborationMessage
items from a persistence backend. The query parameter contains the topic identifier and the timestamp from which messages should be read.Note: You must include the messages sent during or after the timestamp returned from
CollaborationMessagePersister.FetchQuery.getSince()
, including the messages sent at that exact time. More formally, you should return all such messages, for which the following condition is true:message.getTime() >= fetchQuery.getSince()
Parameters:
query
- the fetch queryReturns:
a stream of messages
-
persistMessage
void persistMessage(CollaborationMessagePersister.PersistRequest request)
Writes a
CollaborationMessage
to the persistence backend.It is recommended to let the backend set the message timestamp and only use
CollaborationMessage.getTime()
as a fallback.Parameters:
request
- the request to persist the message
-
-