Interface StatelessSession
-
- All Superinterfaces:
Environment,EvaluationListeners,EvaluatorsContext,FluentEnvironment<StatelessSession>,FluentImports<StatelessSession>,RuleSession<StatelessSession>,RuleSet<RuntimeRule>,RuleSetContext<StatelessSession,RuntimeRule>,RuntimeContext<StatelessSession>
public interface StatelessSession extends RuleSession<StatelessSession>
Unlike stateful sessions, stateless sessions are designed to be short-living instances that can be fired only once, returning the resulting working memory snapshot. Generally, every
StatelessSessioncan be considered as aStatefulSessionthat automatically callsStatefulSession.close()afterStatefulSession.fire().
-
-
Field Summary
-
Fields inherited from interface org.evrete.api.RuntimeContext
SALIENCE_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Voidfire()Fires the session and performs no memory scan.<T> voidfire(Class<T> type, Consumer<T> consumer)A convenience method to retrieve the resulting instances of a specific Java class.default <T> voidfire(Class<T> type, Predicate<T> filter, Consumer<T> consumer)A convenience method to retrieve facts of a specific Java type and matching given predicate<T> voidfire(String type, Consumer<T> consumer)A convenience method to retrieve facts of a specific type name.default <T> voidfire(String type, Predicate<T> filter, Consumer<T> consumer)A convenience method to retrieve facts of a specific type name and matching given predicatevoidfire(BiConsumer<FactHandle,Object> consumer)Fires the session and calls the consumer for each memory object and its fact handle.voidfire(Consumer<Object> consumer)Fires the session and calls the consumer for each memory object.default voidfire(Predicate<Object> filter, Consumer<Object> consumer)Fires the session and calls the consumer for each memory object that satisfies given filterdefault voidinsertAndFire(Iterable<Object> objects)default voidinsertAndFire(Object... objects)-
Methods inherited from interface org.evrete.api.Environment
get, get, getPropertyNames
-
Methods inherited from interface org.evrete.api.EvaluationListeners
addListener, removeListener
-
Methods inherited from interface org.evrete.api.EvaluatorsContext
addEvaluator, addEvaluator, getEvaluator, replaceEvaluator, replaceEvaluator
-
Methods inherited from interface org.evrete.api.FluentEnvironment
set
-
Methods inherited from interface org.evrete.api.FluentImports
addImport, addImport, getImports, getJavaImports
-
Methods inherited from interface org.evrete.api.RuleSession
addEventListener, asCollector, getActivationManager, getParentContext, insert, insert, insert, insert0, insert0, insertAs, insertAs, insertAs, removeEventListener, setActivationManager, setExecutionPredicate
-
Methods inherited from interface org.evrete.api.RuleSet
getRule, getRule, getRules, resolveFieldReferences, ruleExists, setRuleBuilderExceptionHandler
-
Methods inherited from interface org.evrete.api.RuntimeContext
builder, compile, compile, getActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getSourceCompiler, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolver
-
-
-
-
Method Detail
-
fire
void fire(BiConsumer<FactHandle,Object> consumer)
Fires the session and calls the consumer for each memory object and its fact handle.
- Parameters:
consumer- consumer for session memory
-
fire
Void fire()
Fires the session and performs no memory scan. This method might be useful if developer is holding references to fact variables and only interested in changes of those facts:
Customer c = new Customer(); session.insert(c); session.fire(); Log.info(c.getSomeUpdatedProperty());While this method is the easiest among the other
fire(..)methods, it is only applicable if the providedFactStorageSPI implementation stores facts by reference (e.g. does not serialize/deserialize objects). The default implementation does not serialize or otherwise transform fact instances- Specified by:
firein interfaceRuleSession<StatelessSession>
-
fire
default void fire(Predicate<Object> filter, Consumer<Object> consumer)
Fires the session and calls the consumer for each memory object that satisfies given filter
- Parameters:
consumer- consumer for session memoryfilter- filtering predicate
-
fire
void fire(Consumer<Object> consumer)
Fires the session and calls the consumer for each memory object.
- Parameters:
consumer- consumer for session memory
-
fire
<T> void fire(String type, Consumer<T> consumer)
A convenience method to retrieve facts of a specific type name.
- Parameters:
consumer- consumer for session memory
-
fire
default <T> void fire(String type, Predicate<T> filter, Consumer<T> consumer)
A convenience method to retrieve facts of a specific type name and matching given predicate
- Parameters:
consumer- consumer for session memoryfilter- filtering predicate
-
fire
<T> void fire(Class<T> type, Consumer<T> consumer)
A convenience method to retrieve the resulting instances of a specific Java class.
- Parameters:
consumer- consumer for session memory
-
fire
default <T> void fire(Class<T> type, Predicate<T> filter, Consumer<T> consumer)
A convenience method to retrieve facts of a specific Java type and matching given predicate
- Parameters:
consumer- consumer for session memoryfilter- filtering predicate
-
insertAndFire
default void insertAndFire(Object... objects)
-
-