Interface RuleSession<S extends RuleSession<S>>

All Superinterfaces:
Environment, EventBus, FluentEnvironment<S>, FluentImports<S>, MemoryStreaming, Named, RuleSet<RuntimeRule>, RuleSetContext<S,RuntimeRule>, RuntimeContext<S>, SessionOps
All Known Subinterfaces:
StatefulSession, StatelessSession
All Known Implementing Classes:
AbstractSessionWrapper

public interface RuleSession<S extends RuleSession<S>> extends RuleSetContext<S,RuntimeRule>, SessionOps, MemoryStreaming

Base interface for both stateful and stateless sessions

  • Method Details

    • getFact

      <T> T getFact(FactHandle handle)
      Returns fact by its handle.
      Type Parameters:
      T - type of the fact (use Object or wildcard if type is unknown)
      Parameters:
      handle - fact handle
      Returns:
      fact or null if fact is not found
    • asCollector

      <T> Collector<T,?,S> asCollector()
      A convenience method that returns an instance of Collector for inserting streams of facts.
      Type Parameters:
      T - the type of input elements to the reduction operation
      Returns:
      collector
    • insertAs

      default S insertAs(String type, Iterable<?> objects)

      Inserts a collection of facts, marking them as being of a specific type.

      Parameters:
      type - type name
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insertAs

      default S insertAs(String type, Object... objects)

      Inserts a collection of facts, marking them as being of a specific type.

      Parameters:
      type - type name
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insert

      default S insert(Iterable<?> objects)

      Inserts a collection of facts.

      Parameters:
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • insert

      default S insert(Object... objects)

      Inserts an array of facts.

      Parameters:
      objects - objects to insert
      Returns:
      this instance
      See Also:
    • getActivationManager

      ActivationManager getActivationManager()
      Retrieves the activation manager associated with this session.
      Returns:
      the activation manager for this session
    • setActivationManager

      S setActivationManager(ActivationManager activationManager)
      Sets the activation manager for the session.
      Parameters:
      activationManager - the activation manager to set
      Returns:
      the current session instance
    • addEventListener

      @Deprecated default S addEventListener(SessionLifecycleListener listener)
      Deprecated.
      since 4.0.0. The library has moved from an Observer to a PubSub pattern. See the EventBus.subscribe(Class, boolean, Consumer) method for alternatives to adding listeners.
      Adds a session lifecycle listener to receive session lifecycle events.
      Parameters:
      listener - the session lifecycle listener to add
      Returns:
      the current instance of the session
    • removeEventListener

      @Deprecated default S removeEventListener(SessionLifecycleListener listener)
      Deprecated.
      since 4.0.0. The library has moved from an Observer to a PubSub pattern. See the EventBus.subscribe(Class, boolean, Consumer) method for alternatives to adding listeners.
      Removes a SessionLifecycleListener from the session.
      Parameters:
      listener - the SessionLifecycleListener to be removed
      Returns:
      the current instance of the session
    • getParentContext

      Knowledge getParentContext()
      Retrieves the parent context of this session instance.
      Returns:
      the parent context of this Knowledge instance
    • fire

      Object fire()

      Fires the rule session and returns the associated object that depends on the implementation of the current session.

      Returns:
      an object representing the result of the rule session execution.