Class SignalEnvironment

java.lang.Object
com.vaadin.signals.SignalEnvironment

public abstract class SignalEnvironment extends Object
The context in which signal operations are processed. Gives frameworks control over how application code is executed to allow acquiring relevant locks while running callbacks or to run potentially slow operations asynchronously without holding irrelevant locks. It is assumed that the environment is based on a ThreadLocal with regards to how results can be cached between invocations.
  • Constructor Details

    • SignalEnvironment

      public SignalEnvironment()
      Creates a new signal environment.
  • Method Details

    • isActive

      protected abstract boolean isActive()
      Checks whether this environment is active on the current thread. No other instance methods will be run while the environment is not active.
      Returns:
      true if this environment is active, false if it's inactive
    • getResultNotifier

      protected abstract Executor getResultNotifier()
      Gets an executor to use for asynchronously notifying about operation results. This method is run when an operation is submitted and the returned executor is used to notify of the results when the operation has been fully processed. The executor can thus be used to make sure the notification is delivered in the same context as where the operation was initiated. The notification is delivered immediately if no notifier is provided. It is recommended that the executor preserves ordering of submitted tasks within the same context so that notifications are delivered in the order that operations have been applied.
      Returns:
      an executor to use for notifying about operation results, or null to notify about results immediately
    • getEffectDispatcher

      protected abstract Executor getEffectDispatcher()
      Gets an executor to use for running the callback of an effect. The executor can be used to make effect callback invocations asynchronous rather than blocking the thread that applied the change until all affected effects have been processed. This executor does not need to preserve ordering since the effect callback always uses the latest signal values without concern for in which order values have been changed.
      Returns:
      the executor to use for invoking affected effects, or null to invoke the callbacks immediately
    • register

      public static Runnable register(SignalEnvironment environment)
      Registers a signal environment to consider when processing signal operations. The environment should be unregistered using the returned callback when it's no longer needed.
      Parameters:
      environment - the environment to register, not null
      Returns:
      callback for unregistering the environment, not null
    • getCurrentResultNotifier

      public static Executor getCurrentResultNotifier()
      Queries currently active environments for an executor to use for notifying the results of an operation that is currently submitted. An immediate executor is returned if no executor is provided by registered environments.
      Returns:
      the executor to use, not null
      See Also:
    • getDefaultEffectDispatcher

      public static Executor getDefaultEffectDispatcher()
      Gets an executor that queries currently active environments for an executor to use for evaluating changes for an effect. An immediate executor is used if no executor is provided by registered environments.
      Returns:
      the executor to use, not null
      See Also: