Interface RuntimeContext<C extends RuntimeContext<C>>

Type Parameters:
C - the type of the implementing class or interface
All Superinterfaces:
Environment, EvaluationListeners, EvaluatorsContext, 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>, EvaluatorsContext
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.
  • Field Details

    • SALIENCE_COMPARATOR

      static final Comparator<Rule> SALIENCE_COMPARATOR
  • 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.
    • newRule

      @Deprecated RuleBuilder<C> newRule(String name)
      Deprecated.
      this method is deprecated in favor of a more efficient way of building rules, especially for large rule sets. See the new builder() method for details
      Creates a new rule with the provided name.
      Parameters:
      name - rule name
      Returns:
      a new rule builder
    • newRule

      Deprecated.
      this method is deprecated in favor of a more efficient way of building rules, especially for large rule sets. See builder() for details
      Creates a new unnamed rule.
      Returns:
      a new rule builder
    • builder

      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
    • compile

      default LiteralEvaluator compile(LiteralExpression expression) throws CompilationException
      Parameters:
      expression - literal condition and its context
      Returns:
      new evaluator instance
      Throws:
      CompilationException - if the expression failed to compile
      See Also:
    • compile

      A convenience method for compiling literal expressions.

      Parameters:
      expressions - literal conditions and their context
      Returns:
      compiled literal conditions
      Throws:
      CompilationException - if the expression failed to compile
    • wrapTypeResolver

      @Deprecated void wrapTypeResolver(TypeResolverWrapper wrapper)
      Deprecated.
      This class is deprecated and will be removed in future releases. Use the configureTypes(Consumer) method instead to configure the context's types and their fields.
      Wraps the provided TypeResolver with a TypeResolverWrapper instance.
      Parameters:
      wrapper - the TypeResolverWrapper instance used to wrap the TypeResolver
    • 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
    • getExpressionResolver

      ExpressionResolver getExpressionResolver()
      Retrieves the expression resolver for parsing string expressions.
      Returns:
      the expression resolver
    • 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.
    • setClassLoader

      void setClassLoader(ClassLoader classLoader)

      Sets new parent classloader for this context's internal classloader.

      Parameters:
      classLoader - this context's new parent classloader
    • 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
    • getSourceCompiler

      JavaSourceCompiler getSourceCompiler()
      Creates and returns a new instance of JavaSourceCompiler.
      Returns:
      A new JavaSourceCompiler instance.