com.tibbo.aggregate.common.context

## Interface ContextManager<T extends Context>

- All Known Subinterfaces:
    ServerContextManager<T>
  All Known Implementing Classes:
    DefaultContextManager, RemoteContextManager

      public interface ContextManager<T extends Context>

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addMaskEventListener(java.lang.String mask, java.lang.String event, ContextEventListener listener)` Adds event listener to specified event to every context satisfying context mask.
    `void` | `addMaskEventListener(java.lang.String mask, java.lang.String event, ContextEventListener listener, boolean weak)` Adds event listener to specified event to every context satisfying context mask.
    `void` | `contextAdded(T con)` Called when new context is added to the context manager
    `void` | `contextInfoChanged(T con)` Called when context basic info is changed
    `void` | `contextRemoved(T con)` Called when context is removed from the context manager
    `void` | `eventAdded(T con, EventDefinition ed)` Called when new event definition is added to a context
    `void` | `eventRemoved(T con, EventDefinition ed)` Called when event definition is removed from a context
    `void` | `functionAdded(T con, FunctionDefinition fd)` Called when new function definition is added to a context
    `void` | `functionRemoved(T con, FunctionDefinition fd)` Called when function definition is removed from a context
    `T` | `get(java.lang.String contextName)` Get specifies context without CallerController.
    `T` | `get(java.lang.String contextName, CallerController caller)` Get specified context using specified CallerController for permission checking.
    `CallerController` | `getCallerController()` Returns caller controller used by context manager for internal operations.
    `int` | `getEventQueueLength()` Returns current length of event queue.
    `java.util.Map<java.lang.String,java.lang.Long>` | `getEventQueueStatistics()` Returns pending event count per context
    `long` | `getEventsProcessed()` Returns number of events processed since server start.
    `long` | `getEventsScheduled()` Returns number of events received since server start.
    `java.util.concurrent.ExecutorService` | `getExecutorService()` Returns context manager's task execution service
    `default java.util.Optional<FormatCache>` | `getFormatCache()`
    `<P extends PluginDirector> P` | `getPluginDirector()` Returns the plugin director or null if a context manager is not the server context manager.
    `T` | `getRoot()` Get root context.
    `default java.lang.String` | `getScope()` The scope of the context manager is for observability purposes only.
    `default boolean` | `isServerManager()`
    `boolean` | `isStarted()` Returns true if context manager startup was completed
    `void` | `queue(EventData ed, Event ev, FireEventRequestController request)` Called when event is fired in one of the contexts in the tree
    `void` | `removeMaskEventListener(java.lang.String mask, java.lang.String event, ContextEventListener listener)` Removes event listener of event 'event' from every context satisfying event mask.
    `void` | `restart()` Calls stop() and then start()
    `void` | `start()` Starts event dispatcher thread
    `void` | `stop()` 1.
    `void` | `variableAdded(T con, VariableDefinition vd)` Called when new variable definition is added to a context
    `void` | `variableRemoved(T con, VariableDefinition vd)` Called when variable definition is removed from a context

- - ### Method Detail

    - #### isStarted

          boolean isStarted()

      Returns true if context manager startup was completed

    - #### start

          void start()

      Starts event dispatcher thread

    - #### restart

          void restart()

      Calls stop() and then start()

    - #### stop

          void stop()

      1. Stops the event dispatcher
      2. Calls stop() of root context

    - #### getRoot

          T getRoot()

      Get root context.
      Returns:
        Root context of the managed context tree

    - #### get

          T get(java.lang.String contextName,
                CallerController caller)

      Get specified context using specified CallerController for permission checking. Note: getting contexts via context manager should not be used in distributed environment. Use `Context.get(String, CallerController)` method of a "reference" context instead to ensure proper paths conversion.
      Parameters:
        `caller` - CallerController used for permission checking
        `contextName` - Context full name
      Returns:
        Requested context or null if this context not exist or not available with current permissions

    - #### get

          T get(java.lang.String contextName)

      Get specifies context without CallerController. Internally calls get(null, contextName); Note: getting contexts via context manager should not be used in distributed environment. Use `Context.get(String)` method of a "reference" context instead to ensure proper paths conversion.
      Parameters:
        `contextName` - Context full name
      Returns:
        Requested context or null if this context not exist or not available with current permissions

    - #### addMaskEventListener

          void addMaskEventListener(java.lang.String mask,
                                    java.lang.String event,
                                    ContextEventListener listener)

      Adds event listener to specified event to every context satisfying context mask.

    - #### addMaskEventListener

          void addMaskEventListener(java.lang.String mask,
                                    java.lang.String event,
                                    ContextEventListener listener,
                                    boolean weak)

      Adds event listener to specified event to every context satisfying context mask.

    - #### removeMaskEventListener

          void removeMaskEventListener(java.lang.String mask,
                                       java.lang.String event,
                                       ContextEventListener listener)

      Removes event listener of event 'event' from every context satisfying event mask.

    - #### contextAdded

          void contextAdded(T con)

      Called when new context is added to the context manager

    - #### contextRemoved

          void contextRemoved(T con)

      Called when context is removed from the context manager

    - #### contextInfoChanged

          void contextInfoChanged(T con)

      Called when context basic info is changed

    - #### variableAdded

          void variableAdded(T con,
                             VariableDefinition vd)

      Called when new variable definition is added to a context

    - #### variableRemoved

          void variableRemoved(T con,
                               VariableDefinition vd)

      Called when variable definition is removed from a context

    - #### functionAdded

          void functionAdded(T con,
                             FunctionDefinition fd)

      Called when new function definition is added to a context

    - #### functionRemoved

          void functionRemoved(T con,
                               FunctionDefinition fd)

      Called when function definition is removed from a context

    - #### eventAdded

          void eventAdded(T con,
                          EventDefinition ed)

      Called when new event definition is added to a context

    - #### eventRemoved

          void eventRemoved(T con,
                            EventDefinition ed)

      Called when event definition is removed from a context

    - #### queue

          void queue(EventData ed,
                     Event ev,
                     FireEventRequestController request)

      Called when event is fired in one of the contexts in the tree

    - #### getExecutorService

          java.util.concurrent.ExecutorService getExecutorService()

      Returns context manager's task execution service

    - #### getPluginDirector

          <P extends PluginDirector> P getPluginDirector()

      Returns the plugin director or null if a context manager is not the server context manager.

    - #### getCallerController

          CallerController getCallerController()

      Returns caller controller used by context manager for internal operations. This controller is unsafe since it doesn't perform any permission checking.

    - #### getEventQueueLength

          int getEventQueueLength()

      Returns current length of event queue.

    - #### getEventsScheduled

          long getEventsScheduled()

      Returns number of events received since server start.

    - #### getEventsProcessed

          long getEventsProcessed()

      Returns number of events processed since server start.

    - #### getEventQueueStatistics

          java.util.Map<java.lang.String,java.lang.Long> getEventQueueStatistics()

      Returns pending event count per context

    - #### getFormatCache

          default java.util.Optional<FormatCache> getFormatCache()

      Returns:
        format cache associated with the context. This may be the server-wide cache, a local one or even nothing (denoted by an empty optional) in case of cache absence.

    - #### getScope

          @Nullable
          default java.lang.String getScope()

      The scope of the context manager is for observability purposes only. It helps to reliably distinguish likely-named contexts belonging to different scopes of a low-code application, e.g. the root context of the system tree (named "") and the context of the root panel of a web dashboard (also named "").
      Returns:
        this manager's scope to ease tracing of its contexts or null if the scope is not defined (yet)

    - #### isServerManager

          default boolean isServerManager()