com.vaadin.collaborationengine.
Interface ConnectionContext
All Superinterfaces:
All Known Implementing Classes:
The context in which a topic connection is active. This makes it possible for a connection to become deactivate when it is no longer needed and activate it again if the context status changes. The context does also handle synchronization of date change notifications delivered to application code.
ComponentConnectionContext
is used internally by all high-level
components such as CollaborationAvatarGroup
and by shorthand methods
such as
CollaborationEngine.openTopicConnection(com.vaadin.flow.component.Component, String, UserInfo, com.vaadin.flow.function.SerializableFunction)
that take a component instance as the context. This implementation activates
the topic connection whenever the target component is attached and
deactivates it when the component is detached.
UI.access(com.vaadin.flow.server.Command)
is used for
synchronization.
SystemConnectionContext
is intended for application logic that
integrates with external services that are not directly related to UI
components. This context implementation is immediately active and remains
active until the application is shut down (based on
VaadinService.addServiceDestroyListener(com.vaadin.flow.server.ServiceDestroyListener)
.
Each use site (for instance each individual topic connection) gets its own
synchronization to ensure events are delivered in the expected order, but
still avoiding contention between other use sites.
Since:
1.0
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptioninit
(ActivationHandler activationHandler, Executor executor) Initializes the connection context with a
ActivationHandler
and anExecutor
.
-
Method Details
-
init
Initializes the connection context with a
ActivationHandler
and anExecutor
.The method
Consumer.accept(Object)
from the providedActivationHandler
should be called with anActionDispatcher
when this ConnectionContext is activated. When this ConnectionContext is deactivated, it should callConsumer.accept(Object)
with a null parameter.The
ActionDispatcher
should ensure synchronization within the context of this ConnectionContext.Parameters:
activationHandler
- the handler for activation changesexecutor
- executor that should be used by the handler to execute background tasks. Notnull
Returns:
the registration for any logic that needs to be cleaned up if the connection is closed permanently, or
null
if there is nothing to clean up
-