com.tibbo.aggregate.common.context

## Class DefaultContextManager<T extends Context>

- java.lang.Object
- - com.tibbo.aggregate.common.context.DefaultContextManager<T>

- All Implemented Interfaces:
    ContextManager<T>
  Direct Known Subclasses:
    RemoteContextManager

      public class DefaultContextManager<T extends Context>
      extends java.lang.Object
      implements ContextManager<T>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultContextManager(boolean async)`
    `DefaultContextManager(boolean async, EventDispatcher eventDispatcher)`
    `DefaultContextManager(boolean async, int eventQueueLength, java.util.function.Supplier<java.util.concurrent.ThreadPoolExecutor> concurrentDispatcherSupplier)`
    `DefaultContextManager(boolean async, int eventQueueLength, java.util.function.Supplier<java.util.concurrent.ThreadPoolExecutor> concurrentDispatcherSupplier, EventDispatcher eventDispatcher)`
    `DefaultContextManager(T rootContext, boolean async)`
    `DefaultContextManager(T rootContext, boolean async, EventDispatcher eventDispatcher)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addListenerToContext(T con, java.lang.String event, ContextEventListener listener, boolean mask, boolean weak)`
    `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` | `addMaskListenerToContext(java.lang.String mask, T context)`
    `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(Context con, EventDefinition ed)` Called when event definition is removed from a context
    `void` | `functionAdded(Context con, FunctionDefinition fd)` Called when new function definition is added to a context
    `void` | `functionRemoved(Context 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.ThreadPoolExecutor` | `getExecutorService()` Returns context manager's task execution service
    `protected ContextEventListenerSet` | `getListeners(java.lang.String context, java.lang.String event)`
    `java.util.Set<java.lang.String>` | `getMaskListenersMasks()`
    `protected int` | `getMaskListenersSize(java.lang.String mask, java.lang.String event)`
    `PluginDirector` | `getPluginDirector()` Returns the plugin director or null if a context manager is not the server context manager.
    `T` | `getRoot()` Get root context.
    `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
    `protected void` | `removeListenerFromContext(T con, java.lang.String event, ContextEventListener listener, boolean mask)`
    `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()
    `protected void` | `setExecutorService(java.util.concurrent.ThreadPoolExecutor executorService)`
    `void` | `setRoot(T newRoot)`
    `void` | `start()` Starts event dispatcher thread
    `void` | `stop()` 1.
    `void` | `variableAdded(Context con, VariableDefinition vd)` Called when new variable definition is added to a context
    `void` | `variableRemoved(Context con, VariableDefinition vd)` Called when variable definition is removed from a context

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.tibbo.aggregate.common.context.ContextManager

      `getFormatCache, getScope, isServerManager`

- - ### Constructor Detail

    - #### DefaultContextManager

          public DefaultContextManager(boolean async)

    - #### DefaultContextManager

          public DefaultContextManager(boolean async,
                                       EventDispatcher eventDispatcher)

    - #### DefaultContextManager

          public DefaultContextManager(boolean async,
                                       int eventQueueLength,
                                       java.util.function.Supplier<java.util.concurrent.ThreadPoolExecutor> concurrentDispatcherSupplier)

    - #### DefaultContextManager

          public DefaultContextManager(boolean async,
                                       int eventQueueLength,
                                       java.util.function.Supplier<java.util.concurrent.ThreadPoolExecutor> concurrentDispatcherSupplier,
                                       EventDispatcher eventDispatcher)

    - #### DefaultContextManager

          public DefaultContextManager(T rootContext,
                                       boolean async,
                                       EventDispatcher eventDispatcher)

    - #### DefaultContextManager

          public DefaultContextManager(T rootContext,
                                       boolean async)

  - ### Method Detail

    - #### start

          public void start()

      Description copied from interface: `ContextManager`
      Starts event dispatcher thread
      Specified by:
        `start` in interface `ContextManager<T extends Context>`

    - #### stop

          public void stop()

      Description copied from interface: `ContextManager`
      1. Stops the event dispatcher
      2. Calls stop() of root context
      Specified by:
        `stop` in interface `ContextManager<T extends Context>`

    - #### restart

          public void restart()

      Description copied from interface: `ContextManager`
      Calls stop() and then start()
      Specified by:
        `restart` in interface `ContextManager<T extends Context>`

    - #### getRoot

          public T getRoot()

      Description copied from interface: `ContextManager`
      Get root context.
      Specified by:
        `getRoot` in interface `ContextManager<T extends Context>`
      Returns:
        Root context of the managed context tree

    - #### setRoot

          public void setRoot(T newRoot)

    - #### get

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

      Description copied from interface: `ContextManager`
      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.
      Specified by:
        `get` in interface `ContextManager<T extends Context>`
      Parameters:
        `contextName` - Context full name
        `caller` - CallerController used for permission checking
      Returns:
        Requested context or null if this context not exist or not available with current permissions

    - #### get

          public T get(java.lang.String contextName)

      Description copied from interface: `ContextManager`
      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.
      Specified by:
        `get` in interface `ContextManager<T extends Context>`
      Parameters:
        `contextName` - Context full name
      Returns:
        Requested context or null if this context not exist or not available with current permissions

    - #### addListenerToContext

          protected void addListenerToContext(T con,
                                              java.lang.String event,
                                              ContextEventListener listener,
                                              boolean mask,
                                              boolean weak)

    - #### removeListenerFromContext

          protected void removeListenerFromContext(T con,
                                                   java.lang.String event,
                                                   ContextEventListener listener,
                                                   boolean mask)

    - #### addMaskEventListener

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

      Description copied from interface: `ContextManager`
      Adds event listener to specified event to every context satisfying context mask.
      Specified by:
        `addMaskEventListener` in interface `ContextManager<T extends Context>`

    - #### addMaskEventListener

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

      Description copied from interface: `ContextManager`
      Adds event listener to specified event to every context satisfying context mask.
      Specified by:
        `addMaskEventListener` in interface `ContextManager<T extends Context>`

    - #### removeMaskEventListener

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

      Description copied from interface: `ContextManager`
      Removes event listener of event 'event' from every context satisfying event mask.
      Specified by:
        `removeMaskEventListener` in interface `ContextManager<T extends Context>`

    - #### getListeners

          protected ContextEventListenerSet getListeners(java.lang.String context,
                                                         java.lang.String event)

    - #### contextAdded

          public void contextAdded(T con)

      Description copied from interface: `ContextManager`
      Called when new context is added to the context manager
      Specified by:
        `contextAdded` in interface `ContextManager<T extends Context>`

    - #### addMaskListenerToContext

          public void addMaskListenerToContext(java.lang.String mask,
                                               T context)

    - #### getMaskListenersMasks

          public java.util.Set<java.lang.String> getMaskListenersMasks()

    - #### getMaskListenersSize

          protected int getMaskListenersSize(java.lang.String mask,
                                             java.lang.String event)

    - #### contextRemoved

          public void contextRemoved(T con)

      Description copied from interface: `ContextManager`
      Called when context is removed from the context manager
      Specified by:
        `contextRemoved` in interface `ContextManager<T extends Context>`

    - #### contextInfoChanged

          public void contextInfoChanged(T con)

      Description copied from interface: `ContextManager`
      Called when context basic info is changed
      Specified by:
        `contextInfoChanged` in interface `ContextManager<T extends Context>`

    - #### variableAdded

          public void variableAdded(Context con,
                                    VariableDefinition vd)

      Description copied from interface: `ContextManager`
      Called when new variable definition is added to a context
      Specified by:
        `variableAdded` in interface `ContextManager<T extends Context>`

    - #### variableRemoved

          public void variableRemoved(Context con,
                                      VariableDefinition vd)

      Description copied from interface: `ContextManager`
      Called when variable definition is removed from a context
      Specified by:
        `variableRemoved` in interface `ContextManager<T extends Context>`

    - #### functionAdded

          public void functionAdded(Context con,
                                    FunctionDefinition fd)

      Description copied from interface: `ContextManager`
      Called when new function definition is added to a context
      Specified by:
        `functionAdded` in interface `ContextManager<T extends Context>`

    - #### functionRemoved

          public void functionRemoved(Context con,
                                      FunctionDefinition fd)

      Description copied from interface: `ContextManager`
      Called when function definition is removed from a context
      Specified by:
        `functionRemoved` in interface `ContextManager<T extends Context>`

    - #### eventAdded

          public void eventAdded(T con,
                                 EventDefinition ed)

      Description copied from interface: `ContextManager`
      Called when new event definition is added to a context
      Specified by:
        `eventAdded` in interface `ContextManager<T extends Context>`

    - #### eventRemoved

          public void eventRemoved(Context con,
                                   EventDefinition ed)

      Description copied from interface: `ContextManager`
      Called when event definition is removed from a context
      Specified by:
        `eventRemoved` in interface `ContextManager<T extends Context>`

    - #### queue

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

      Description copied from interface: `ContextManager`
      Called when event is fired in one of the contexts in the tree
      Specified by:
        `queue` in interface `ContextManager<T extends Context>`

    - #### setExecutorService

          protected void setExecutorService(java.util.concurrent.ThreadPoolExecutor executorService)

    - #### getExecutorService

          public java.util.concurrent.ThreadPoolExecutor getExecutorService()

      Description copied from interface: `ContextManager`
      Returns context manager's task execution service
      Specified by:
        `getExecutorService` in interface `ContextManager<T extends Context>`

    - #### getCallerController

          public CallerController getCallerController()

      Description copied from interface: `ContextManager`
      Returns caller controller used by context manager for internal operations. This controller is unsafe since it doesn't perform any permission checking.
      Specified by:
        `getCallerController` in interface `ContextManager<T extends Context>`

    - #### getEventQueueLength

          public int getEventQueueLength()

      Description copied from interface: `ContextManager`
      Returns current length of event queue.
      Specified by:
        `getEventQueueLength` in interface `ContextManager<T extends Context>`

    - #### getEventsScheduled

          public long getEventsScheduled()

      Description copied from interface: `ContextManager`
      Returns number of events received since server start.
      Specified by:
        `getEventsScheduled` in interface `ContextManager<T extends Context>`

    - #### getEventsProcessed

          public long getEventsProcessed()

      Description copied from interface: `ContextManager`
      Returns number of events processed since server start.
      Specified by:
        `getEventsProcessed` in interface `ContextManager<T extends Context>`

    - #### getEventQueueStatistics

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

      Description copied from interface: `ContextManager`
      Returns pending event count per context
      Specified by:
        `getEventQueueStatistics` in interface `ContextManager<T extends Context>`

    - #### getPluginDirector

          public PluginDirector getPluginDirector()

      Description copied from interface: `ContextManager`
      Returns the plugin director or null if a context manager is not the server context manager.
      Specified by:
        `getPluginDirector` in interface `ContextManager<T extends Context>`

    - #### isStarted

          public boolean isStarted()

      Description copied from interface: `ContextManager`
      Returns true if context manager startup was completed
      Specified by:
        `isStarted` in interface `ContextManager<T extends Context>`