- 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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Returns an instance ofRuleSetBuilderfor building and appending rules to the current context.compile(Collection<LiteralExpression> expressions) A convenience method for compiling literal expressions.default LiteralEvaluatorcompile(LiteralExpression expression) configureTypes(Consumer<TypeResolver> action) Configures theTypeResolverby applying the given action.Class<? extends ActivationManager>Returns the Activation Manager factory class for this RuntimeContext.Retrieves the ClassLoader used by the current context.Retrieves the Configuration object associated with this RuntimeContext.Retrieves the expression resolver for parsing string expressions.Retrieves the comparator used for ordering rules.Returns theKnowledgeServiceinstance.Creates and returns a new instance ofJavaSourceCompiler.Retrieves the TypeResolver instance associated with this RuntimeContext.newRule()Deprecated.this method is deprecated in favor of a more efficient way of building rules, especially for large rule sets.Deprecated.this method is deprecated in favor of a more efficient way of building rules, especially for large rule sets.<A extends ActivationManager>
voidsetActivationManagerFactory(Class<A> managerClass) Sets the Activation Manager factory class for this RuntimeContext.voidsetActivationManagerFactory(String managerClass) Sets the Activation Manager factory class name for this RuntimeContext.setActivationMode(ActivationMode activationMode) Sets the activation mode for the session.voidsetClassLoader(ClassLoader classLoader) Sets new parent classloader for this context's internal classloader.voidsetRuleComparator(Comparator<Rule> comparator) Sets the comparator used for ordering rules.voidwrapTypeResolver(TypeResolverWrapper wrapper) Deprecated.This class is deprecated and will be removed in future releases.Methods inherited from interface org.evrete.api.Environment
get, get, getPropertyNamesMethods inherited from interface org.evrete.api.EvaluationListeners
addListener, removeListenerMethods inherited from interface org.evrete.api.EvaluatorsContext
addEvaluator, addEvaluator, getEvaluator, replaceEvaluator, replaceEvaluatorMethods inherited from interface org.evrete.api.FluentEnvironment
setMethods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImports
-
Field Details
-
SALIENCE_COMPARATOR
-
-
Method Details
-
getRuleComparator
Comparator<Rule> getRuleComparator()Retrieves the comparator used for ordering rules.- Returns:
- the comparator for Rule objects.
-
setRuleComparator
Sets the comparator used for ordering rules.- Parameters:
comparator- the comparator for Rule objects.
-
newRule
Deprecated.this method is deprecated in favor of a more efficient way of building rules, especially for large rule sets. See the newbuilder()method for detailsCreates 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. Seebuilder()for detailsCreates a new unnamed rule.- Returns:
- a new rule builder
-
builder
RuleSetBuilder<C> builder()Returns an instance of
RuleSetBuilderfor 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:
Usage AFTER 3.1.00:service .newKnowledge() .newRule() .forEach("$a", A.class) .where("$a.active") .execute();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
- Parameters:
expression- literal condition and its context- Returns:
- new evaluator instance
- Throws:
CompilationException- if the expression failed to compile- See Also:
-
compile
Collection<LiteralEvaluator> compile(Collection<LiteralExpression> expressions) throws CompilationException 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.This class is deprecated and will be removed in future releases. Use theconfigureTypes(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
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
Configures theTypeResolverby 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
Sets new parent classloader for this context's internal classloader.
- Parameters:
classLoader- this context's new parent classloader
-
getService
KnowledgeService getService()Returns theKnowledgeServiceinstance.- Returns:
- the
KnowledgeServiceinstance
-
getActivationManagerFactory
Class<? extends ActivationManager> getActivationManagerFactory()Returns the Activation Manager factory class for this RuntimeContext.- Returns:
- the Activation Manager factory class
-
setActivationManagerFactory
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
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 ofJavaSourceCompiler.- Returns:
- A new
JavaSourceCompilerinstance.
-