- All Superinterfaces:
AutoCloseable,Environment,EventBus,FluentEnvironment<StatefulSession>,FluentImports<StatefulSession>,MemoryStreaming,Named,RuleSession<StatefulSession>,RuleSet<RuntimeRule>,RuleSetContext<StatefulSession,,RuntimeRule> RuntimeContext<StatefulSession>,SessionOps
The StatefulSession interface represents a stateful rule session.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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.fire()Fire all rules.default Future<StatefulSession>Deprecated.default <T> Future<T>fireAsync(T result) Deprecated.Use external tools likeExecutorService.submit(Runnable, Object).default <T> StatefulSessionforEachFact(Class<T> type, Consumer<T> consumer) A memory inspection method that accepts fact type as an argument.default <T> StatefulSessionforEachFact(Class<T> type, Predicate<T> filter, Consumer<T> consumer) A filtering version of theforEachFact(Class, Consumer)method.default <T> StatefulSessionforEachFact(String type, Consumer<T> consumer) A memory inspection method that accepts fact type as an argument.default <T> StatefulSessionforEachFact(String type, Predicate<T> filter, Consumer<T> consumer) A filtering version of theforEachFact(String, Consumer)method.default StatefulSessionforEachFact(BiConsumer<FactHandle, Object> consumer) A full-scan memory inspection method.default StatefulSessionforEachFact(BiPredicate<FactHandle, Object> filter, BiConsumer<FactHandle, Object> consumer) default StatefulSessionforEachFact(Consumer<Object> consumer) default StatefulSessioninsertAndFire(Iterable<?> objects) default StatefulSessioninsertAndFire(Object... objects) 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, getJavaImportsMethods inherited from interface org.evrete.api.MemoryStreaming
streamFactEntries, streamFactEntries, streamFactEntries, streamFacts, streamFacts, streamFactsMethods inherited from interface org.evrete.api.RuleSession
addEventListener, asCollector, getActivationManager, getFact, getParentContext, insert, insert, insertAs, insertAs, removeEventListener, setActivationManagerMethods inherited from interface org.evrete.api.RuleSet
getRule, getRule, getRules, ruleExistsMethods inherited from interface org.evrete.api.RuntimeContext
builder, builder, configureTypes, getActivationManagerFactory, getClassLoader, getConfiguration, getEvaluatorsContext, getRuleComparator, getService, getTypeResolver, importRules, importRules, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setRuleComparator
-
Method Details
-
fire
StatefulSession fire()Fire all rules.- Specified by:
firein interfaceRuleSession<StatefulSession>- Returns:
- an object representing the result of the rule session execution.
-
fireAsync
Deprecated.Use external tools likeExecutorService.submit(Runnable, Object).Fires the session asynchronously and returns a Future representing the session's execution status.- Type Parameters:
T- the result type parameter- Parameters:
result- the result to return by the Future- Returns:
- a Future representing the pending completion of the
fire()command
-
fireAsync
Deprecated.Use external tools likeExecutorService.submit(Runnable, Object).Same asfireAsync(Object), but the Future's get method will return the session itself.- Returns:
- a Future representing pending completion of the
fire()command.
-
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.
-
forEachFact
A full-scan memory inspection method.
- Parameters:
consumer- consumer for the facts- Returns:
- this instance
-
forEachFact
default StatefulSession forEachFact(BiPredicate<FactHandle, Object> filter, BiConsumer<FactHandle, Object> consumer) -
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- Returns:
- this instance
- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
-
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.getJavaClass())- Type Parameters:
T- expected java type for the provided type name- Parameters:
type- type nameconsumer- consumer for the facts- Returns:
- this instance
- Throws:
ClassCastException- if a working memory object can not be cast to the specified typeIllegalArgumentException- if no such type exists- See Also:
-
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- Returns:
- this instance
- See Also:
-
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- Returns:
- new stateful session instance
- See Also:
-
insertAndFire
-
insertAndFire
-
ExecutorService.submit(Runnable, Object).