Interface RuntimeContext<C extends RuntimeContext<C>>

Type Parameters:
C - the type of the implementing class or interface
All Superinterfaces:
Environment, EventBus, FluentEnvironment<C>, FluentImports<C>
All Known Subinterfaces:
Knowledge, RuleSession<S>, RuleSetContext<C,R>, StatefulSession, StatelessSession
All Known Implementing Classes:
AbstractSessionWrapper, KnowledgeWrapper

public interface RuntimeContext<C extends RuntimeContext<C>> extends FluentImports<C>, FluentEnvironment<C>, EventBus
The RuntimeContext interface represents the context in which the rules are executed. Both stateful and stateless sessions, as well as Knowledge instances, extend this interface.
  • Method Details

    • getRuleComparator

      Comparator<Rule> getRuleComparator()
      Retrieves the comparator used for ordering rules.
      Returns:
      the comparator for Rule objects.
    • setRuleComparator

      void setRuleComparator(Comparator<Rule> comparator)
      Sets the comparator used for ordering rules.
      Parameters:
      comparator - the comparator for Rule objects.
    • getEvaluatorsContext

      EvaluatorsContext getEvaluatorsContext()
      Return the condition manager associated with this context.
      Returns:
      the evaluator context
    • builder

      RuleSetBuilder<C> builder(ClassLoader classLoader)

      Returns an instance of RuleSetBuilder for building and appending rules to the current context.

      Builder MUST be terminated with the RuleSetBuilder.build() call for changes to take effect.

      Usage BEFORE 3.1.00:

       
       service
            .newKnowledge()
            .newRule()
            .forEach("$a", A.class)
            .where("$a.active")
            .execute();
       
       
      Usage AFTER 3.1.00:
       
       service
            .newKnowledge()
            .builder()       // !! important
            .newRule()
            .forEach("$a", A.class)
            .where("$a.active")
            .execute()
            .build();        // !! important
       
       
      Parameters:
      classLoader - the classloader to use.
      Returns:
      new instance of RuleSetBuilder.
      Since:
      3.1.00
    • builder

      default RuleSetBuilder<C> builder()

      Returns an instance of RuleSetBuilder for building and appending rules to the current context.

      Builder MUST be terminated with the RuleSetBuilder.build() call for changes to take effect.

      Usage BEFORE 3.1.00:

       
       service
            .newKnowledge()
            .newRule()
            .forEach("$a", A.class)
            .where("$a.active")
            .execute();
       
       
      Usage AFTER 3.1.00:
       
       service
            .newKnowledge()
            .builder()       // !! important
            .newRule()
            .forEach("$a", A.class)
            .where("$a.active")
            .execute()
            .build();        // !! important
       
       
      Returns:
      new instance of RuleSetBuilder.
      Since:
      3.1.00
    • setActivationMode

      C setActivationMode(ActivationMode activationMode)
      Sets the activation mode for the session.
      Parameters:
      activationMode - the activation mode to set
      Returns:
      the updated instance of the class
    • configureTypes

      C configureTypes(Consumer<TypeResolver> action)
      Configures the TypeResolver by applying the given action.
      Parameters:
      action - the action to configure the TypeResolver
      Returns:
      this context
    • getClassLoader

      ClassLoader getClassLoader()
      Retrieves the ClassLoader used by the current context.
      Returns:
      the ClassLoader used by the object.
    • getService

      KnowledgeService getService()
      Returns the KnowledgeService instance.
      Returns:
      the KnowledgeService instance
    • getActivationManagerFactory

      Class<? extends ActivationManager> getActivationManagerFactory()
      Returns the Activation Manager factory class for this RuntimeContext.
      Returns:
      the Activation Manager factory class
    • setActivationManagerFactory

      <A extends ActivationManager> void setActivationManagerFactory(Class<A> managerClass)
      Sets the Activation Manager factory class for this RuntimeContext.
      Type Parameters:
      A - the type of Activation Manager
      Parameters:
      managerClass - the Activation Manager factory class
    • setActivationManagerFactory

      void setActivationManagerFactory(String managerClass)
      Sets the Activation Manager factory class name for this RuntimeContext.
      Parameters:
      managerClass - the Activation Manager factory class name
    • getTypeResolver

      TypeResolver getTypeResolver()
      Retrieves the TypeResolver instance associated with this RuntimeContext.
      Returns:
      the TypeResolver instance
    • getConfiguration

      Configuration getConfiguration()
      Retrieves the Configuration object associated with this RuntimeContext.
      Returns:
      the Configuration object
    • importRules

      default C importRules(DSLKnowledgeProvider provider, Object source) throws IOException
      Imports all rules using the specified DSL provider and rule source into this ruleset builder.
      Parameters:
      provider - The DSL provider
      source - Data source containing the rules.
      Returns:
      This RuleSetBuilder instance for method chaining.
      Throws:
      IOException - If there is an issue reading from the sources.
      IllegalArgumentException - If the source format is not recognized or cannot be processed.
      See Also:
    • importRules

      default C importRules(String dslName, Object source) throws IOException
      Imports rules using the specified DSL provider and rule sources into this ruleset builder.
      Parameters:
      dslName - The name of the DSL provider.
      source - Data source that contains rule definitions
      Returns:
      This RuleSetBuilder instance for method chaining.
      Throws:
      IOException - If there is an issue reading from the sources.
      IllegalArgumentException - If the source format is not recognized or cannot be processed.
      IllegalStateException - if no or multiple providers were found for the specified DSL identifier.
      See Also: