Class ComponentConnectionContext

  • All Implemented Interfaces:
    ConnectionContext

    public class ComponentConnectionContext
    extends java.lang.Object
    implements ConnectionContext
    A connection context based on the attach state of a set of component instances. The context is considered active whenever at least one tracked component is attached. All attached components must belong to the same UI instance, and this UI instance is used to dispatch actions using UI.access(Command).
    Since:
    1.0
    Author:
    Vaadin Ltd
    • Constructor Summary

      Constructors 
      Constructor Description
      ComponentConnectionContext()
      Creates an empty component connection context.
      ComponentConnectionContext​(com.vaadin.flow.component.Component component)
      Creates a new component connection context which is initially using a single component.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addComponent​(com.vaadin.flow.component.Component component)
      Adds a component instance to track for this context.
      com.vaadin.flow.shared.Registration init​(ActivationHandler activationHandler, java.util.concurrent.Executor backgroundRunner)
      Initializes the connection context with a ActivationHandler and an Executor.
      void removeComponent​(com.vaadin.flow.component.Component component)
      Stops tracking a component for this context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ComponentConnectionContext

        public ComponentConnectionContext()
        Creates an empty component connection context.
        Since:
        1.0
      • ComponentConnectionContext

        public ComponentConnectionContext​(com.vaadin.flow.component.Component component)
        Creates a new component connection context which is initially using a single component.
        Parameters:
        component - the component to use, not null
        Since:
        1.0
    • Method Detail

      • addComponent

        public void addComponent​(com.vaadin.flow.component.Component component)
        Adds a component instance to track for this context. Calling this method again with a component that is already tracked has no effect.
        Parameters:
        component - the component to track, not null
        Since:
        1.0
        See Also:
        removeComponent(Component)
      • removeComponent

        public void removeComponent​(com.vaadin.flow.component.Component component)
        Stops tracking a component for this context. Calling this method for a component that isn't tracked has no effect.
        Parameters:
        component - the component to stop tracking, not null
        Since:
        1.0
        See Also:
        addComponent(Component)
      • init

        public com.vaadin.flow.shared.Registration init​(ActivationHandler activationHandler,
                                                        java.util.concurrent.Executor backgroundRunner)
        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
        backgroundRunner - 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