Interface RuleSession<S extends RuleSession<S>>
- All Superinterfaces:
AutoCloseable,Environment,EvaluationListeners,EvaluatorsContext,FluentEnvironment<S>,FluentImports<RuntimeContext<?>>,RuleSet<RuntimeRule>,RuntimeContext<S>,WorkingMemory
- All Known Subinterfaces:
StatefulSession
public interface RuleSession<S extends RuleSession<S>> extends WorkingMemory, RuntimeContext<S>, RuleSet<RuntimeRule>, AutoCloseable
-
Field Summary
Fields inherited from interface org.evrete.api.RuntimeContext
SALIENCE_COMPARATOR -
Method Summary
Modifier and Type Method Description voidclear()This method clears session's working memory and its beta-memory nodes as if the session had never been used.voidclose()Closes the session and destroys its memory.voidfire()default Future<S>fireAsync()Same asfireAsync(Object), with the Future's get method will returning the session itself.<T> Future<T>fireAsync(T result)Fires session asynchronously and returns a Future representing the session execution status.default <T> voidforEachFact(Class<T> type, Consumer<T> consumer)A memory inspection method that accepts fact type as an argument.default <T> voidforEachFact(Class<T> type, Predicate<T> filter, Consumer<T> consumer)A filtering version of theforEachFact(Class, Consumer)method.<T> voidforEachFact(String type, Consumer<T> consumer)A memory inspection method that accepts fact type as an argument.default <T> voidforEachFact(String type, Predicate<T> filter, Consumer<T> consumer)A filtering version of theforEachFact(String, Consumer)method.voidforEachFact(BiConsumer<FactHandle,Object> consumer)ActivationManagergetActivationManager()RuntimeContext<?>getParentContext()SsetActivationManager(ActivationManager activationManager)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, replaceEvaluatorMethods inherited from interface org.evrete.api.FluentEnvironment
setMethods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImportsMethods inherited from interface org.evrete.api.RuleSet
compileRule, getRule, getRules, ruleExistsMethods inherited from interface org.evrete.api.RuntimeContext
getActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolver
-
Method Details
-
getActivationManager
ActivationManager getActivationManager() -
setActivationManager
-
forEachFact
-
forEachFact
A memory inspection method that accepts fact type as an argument.
- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typeconsumer- consumer for the facts- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
TypeResolver
-
forEachFact
A memory inspection method that accepts fact type as an argument. Type name can be either a class name or a name of explicitly declared type. In the latter case, the generic type parameter
Tmust match the declared type's Java type (seeType.getJavaType())- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- type nameconsumer- consumer for the facts- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
TypeResolver
-
forEachFact
A filtering version of the
forEachFact(Class, Consumer)method.- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typeconsumer- consumer for the factsfilter- filtering predicate- See Also:
forEachFact(Class, Consumer)
-
forEachFact
A filtering version of the
forEachFact(String, Consumer)method.- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- expected fact typeconsumer- consumer for the factsfilter- filtering predicate- See Also:
forEachFact(String, Consumer)
-
getParentContext
RuntimeContext<?> getParentContext() -
fire
void fire() -
fireAsync
Fires session asynchronously and returns a Future representing the session execution status.
- Type Parameters:
T- result type parameter- Parameters:
result- the result to return by the Future- Returns:
- a Future representing pending completion of the
fire()command - Throws:
RejectedExecutionException- if the task cannot be scheduled for execution
-
fireAsync
Same as
fireAsync(Object), with the Future's get method will returning the session itself.- Returns:
- a Future representing pending completion of the
fire()command. - Throws:
RejectedExecutionException- if the task cannot be scheduled for execution- See Also:
fireAsync(Object)
-
close
void close()Closes the session and destroys its memory. A closed session can not be reused.
- Specified by:
closein interfaceAutoCloseable
-
clear
void clear()This method clears session's working memory and its beta-memory nodes as if the session had never been used.
-