Package com.vaadin.collaborationengine
Interface CollaborationMessagePersister
-
- All Superinterfaces:
Serializable
public interface CollaborationMessagePersister extends Serializable
Persister ofCollaborationMessageitems, which enables to read and write messages from/to a backend, for example a database.It can be used with a
CollaborationMessageListto 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 classCollaborationMessagePersister.FetchQueryA query to fetch messages from a backend.static classCollaborationMessagePersister.PersistRequestA request to persist messages to a backend.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Stream<CollaborationMessage>fetchMessages(CollaborationMessagePersister.FetchQuery query)Reads a stream ofCollaborationMessageitems from a persistence backend.static CollaborationMessagePersisterfromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)Creates an instance ofCollaborationMessagePersisterfrom the provided callbacks.voidpersistMessage(CollaborationMessagePersister.PersistRequest request)Writes aCollaborationMessageto the persistence backend.
-
-
-
Method Detail
-
fromCallbacks
static CollaborationMessagePersister fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)
Creates an instance ofCollaborationMessagePersisterfrom the provided callbacks.- Parameters:
fetchCallback- the callback to fetch messages, not nullpersistCallback- the callback to persist messages, not null- Returns:
- the persister instance
-
fetchMessages
Stream<CollaborationMessage> fetchMessages(CollaborationMessagePersister.FetchQuery query)
Reads a stream ofCollaborationMessageitems 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 query- Returns:
- a stream of messages
-
persistMessage
void persistMessage(CollaborationMessagePersister.PersistRequest request)
Writes aCollaborationMessageto 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
-
-