Interface ConnectionContext
-
- All Known Implementing Classes:
ComponentConnectionContext,SystemConnectionContext
public interface ConnectionContextThe 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.ComponentConnectionContextis used internally by all high-level components such asCollaborationAvatarGroupand by shorthand methods such asCollaborationEngine.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.SystemConnectionContextis 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 onVaadinService.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Registrationinit(ActivationHandler activationHandler, Executor executor)Initializes the connection context with aActivationHandlerand anExecutor.
-
-
-
Method Detail
-
init
Registration init(ActivationHandler activationHandler, Executor executor)
Initializes the connection context with aActivationHandlerand anExecutor.The method
Consumer.accept(Object)from the providedActivationHandlershould be called with anActionDispatcherwhen this ConnectionContext is activated. When this ConnectionContext is deactivated, it should callConsumer.accept(Object)with a null parameter.The
ActionDispatchershould 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
nullif there is nothing to clean up
-
-