- 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 Summary
Modifier and TypeMethodDescriptiondefault RuleSetBuilder<C>builder()Returns an instance ofRuleSetBuilderfor building and appending rules to the current context.builder(ClassLoader classLoader) Returns an instance ofRuleSetBuilderfor building and appending rules to the current context.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.Return the condition manager associated with this context.Retrieves the comparator used for ordering rules.Returns theKnowledgeServiceinstance.Retrieves the TypeResolver instance associated with this RuntimeContext.default CimportRules(String dslName, Object source) Imports rules using the specified DSL provider and rule sources into this ruleset builder.default CimportRules(DSLKnowledgeProvider provider, Object source) Imports all rules using the specified DSL provider and rule source into this ruleset builder.<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.voidsetRuleComparator(Comparator<Rule> comparator) Sets the comparator used for ordering rules.Methods inherited from interface org.evrete.api.Environment
get, get, getPropertyNamesMethods inherited from interface org.evrete.api.events.EventBus
getPublisher, subscribe, subscribe, subscribeAsyncMethods inherited from interface org.evrete.api.FluentEnvironment
setMethods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImports
-
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.
-
getEvaluatorsContext
EvaluatorsContext getEvaluatorsContext()Return the condition manager associated with this context.- Returns:
- the evaluator context
-
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- Parameters:
classLoader- the classloader to use.- Returns:
- new instance of RuleSetBuilder.
- Since:
- 3.1.00
-
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
-
setActivationMode
Sets the activation mode for the session.- Parameters:
activationMode- the activation mode to set- Returns:
- the updated instance of the class
-
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.
-
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
-
importRules
Imports all rules using the specified DSL provider and rule source into this ruleset builder.- Parameters:
provider- The DSL providersource- 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
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:
-