Class SystemConnectionContext

  • All Implemented Interfaces:
    ConnectionContext

    public class SystemConnectionContext
    extends java.lang.Object
    implements ConnectionContext
    A connection context that is always active. This context is intended to be used in cases when Collaboration Engine is used in situations that aren't directly associated with a UI, such as from a background thread or when integrating with external services.

    An instance can be acquired using getInstance() in any situation where CollaborationEngine.getInstance() is available. Other situations can use CollaborationEngine.getSystemContext() or create a new context instance using the constructor.

    Author:
    Vaadin Ltd
    • Constructor Detail

      • SystemConnectionContext

        public SystemConnectionContext​(CollaborationEngine ce)
        Creates a new system connection context instance for the given Collaboration Engine instance. It is typically recommended reusing an existing instance through getInstance() or CollaborationEngine.getSystemContext() rather than creating new instances.
        Parameters:
        ce - the collaboration engine instance to use, not null
    • Method Detail

      • getInstance

        public static SystemConnectionContext getInstance()
        Gets the system connection context associated with the current Collaboration Engine instance. This method can be used only when CollaborationEngine.getInstance() is available.
        Returns:
        a system connection context instance, not null
        Throws:
        java.lang.IllegalStateException - in case no current collaboration engine instance is available
      • init

        public com.vaadin.flow.shared.Registration init​(ActivationHandler activationHandler,
                                                        java.util.concurrent.Executor executor)
        Description copied from interface: ConnectionContext
        Initializes the connection context with a ActivationHandler and an Executor.

        The method Consumer.accept(Object) from the provided ActivationHandler should be called with an ActionDispatcher when this ConnectionContext is activated. When this ConnectionContext is deactivated, it should call Consumer.accept(Object) with a null parameter.

        The ActionDispatcher should ensure synchronization within the context of this ConnectionContext.

        Specified by:
        init in interface ConnectionContext
        Parameters:
        activationHandler - the handler for activation changes
        executor - executor that should be used by the handler to execute background tasks. Not null
        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