org.eclipse.incquery.runtime.api

## Class IncQueryEngineManager

- java.lang.Object
- - org.eclipse.incquery.runtime.api.IncQueryEngineManager

-     public class IncQueryEngineManager
      extends java.lang.Object

  Global registry of active IncQuery engines.

  Manages an `IncQueryEngine` for each model (more precisely scope), that is created on demand. Managed engines are shared between clients querying the same model.

  It is also possible to create private, unmanaged engines that are not shared between clients.

  Only weak references are retained on the managed engines. So if there are no other references to the matchers or the engine, they can eventually be GC'ed, and they won't block the model from being GC'ed either.

  Author:
    Bergmann Gabor

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addIncQueryEngineInitializationListener(IncQueryEngineInitializationListener listener)` Registers a listener for new engine initialization.
    `java.util.Set<IncQueryEngine>` | `getExistingIncQueryEngines()` Collects all `IncQueryEngine` instances that still exist.
    `IncQueryEngine` | `getIncQueryEngine(IncQueryScope scope)` Creates a managed IncQuery engine at a given scope (e.g.
    `IncQueryEngine` | `getIncQueryEngineIfExists(IncQueryScope scope)` Retrieves an already existing managed IncQuery engine.
    `static IncQueryEngineManager` | `getInstance()`
    `void` | `removeIncQueryEngineInitializationListener(IncQueryEngineInitializationListener listener)` Removes a registered listener added with `addIncQueryEngineInitializationListener(org.eclipse.incquery.runtime.api.IncQueryEngineInitializationListener)`

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

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

- - ### Method Detail

    - #### getInstance

          public static IncQueryEngineManager getInstance()

      Returns:
        the singleton instance

    - #### getIncQueryEngine

          public IncQueryEngine getIncQueryEngine(IncQueryScope scope)
                                           throws IncQueryException

      Creates a managed IncQuery engine at a given scope (e.g. an EMF Resource or ResourceSet, as in `EMFScope`) or retrieves an already existing one. Repeated invocations for a single model root will return the same engine. Consequently, the engine will be reused between different clients querying the same model, providing performance benefits.

      The match set of any patterns will be incrementally refreshed upon updates from this scope.

      Parameters:
        `scope` - the scope of query evaluation; the definition of the set of model elements that this engine is operates on. Provide e.g. a `EMFScope` for evaluating queries on an EMF model.
      Returns:
        a new or previously existing engine
      Throws:
        `IncQueryException`

    - #### getIncQueryEngineIfExists

          public IncQueryEngine getIncQueryEngineIfExists(IncQueryScope scope)

      Retrieves an already existing managed IncQuery engine.
      Parameters:
        `scope` - the scope of query evaluation; the definition of the set of model elements that this engine is operates on. Provide e.g. a `EMFScope` for evaluating queries on an EMF model.
      Returns:
        a previously existing engine, or null if no engine is active for the given EMF model root

    - #### getExistingIncQueryEngines

          public java.util.Set<IncQueryEngine> getExistingIncQueryEngines()

      Collects all `IncQueryEngine` instances that still exist.
      Returns:
        set of engines if there is any, otherwise EMTPY_SET

    - #### addIncQueryEngineInitializationListener

          public void addIncQueryEngineInitializationListener(IncQueryEngineInitializationListener listener)

      Registers a listener for new engine initialization.

      For removal, use `removeIncQueryEngineInitializationListener(org.eclipse.incquery.runtime.api.IncQueryEngineInitializationListener)`
      Parameters:
        `listener` - the listener to register

    - #### removeIncQueryEngineInitializationListener

          public void removeIncQueryEngineInitializationListener(IncQueryEngineInitializationListener listener)

      Removes a registered listener added with `addIncQueryEngineInitializationListener(org.eclipse.incquery.runtime.api.IncQueryEngineInitializationListener)`
      Parameters:
        `listener` -