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 StatelessSession can be considered as a StatefulSession
that automatically calls StatefulSession.close() after StatefulSession.fire().
SALIENCE_COMPARATOR| Modifier and Type | Method and Description |
|---|---|
void |
fire()
Fires the session and performs no memory scan.
|
void |
fire(BiConsumer<FactHandle,Object> consumer)
Fires the session and calls the consumer for each memory object and its fact handle.
|
<T> void |
fire(Class<T> type,
Consumer<T> consumer)
A convenience method to retrieve the resulting instances of a specific Java class.
|
void |
fire(Consumer<Object> consumer)
Fires the session and calls the consumer for each memory object.
|
<T> void |
fire(String type,
Consumer<T> consumer)
A convenience method to retrieve facts of a specific type name.
|
default void |
insertAndFire(Object... objects) |
addEventListener, getActivationManager, getParentContext, insert, insert, insert, insert, insert, removeEventListener, setActivationManager, setExecutionPredicate, setFireCriteriagetActivationManagerFactory, getClassLoader, getConfiguration, getExpressionResolver, getRuleComparator, getService, getTypeResolver, newRule, newRule, setActivationManagerFactory, setActivationManagerFactory, setActivationMode, setClassLoader, setRuleComparator, wrapTypeResolveraddListener, removeListeneraddImport, addImport, getImports, getJavaImportssetget, get, getPropertyNamesaddEvaluator, addEvaluator, replaceEvaluatorcompileRule, getRule, getRule, getRules, ruleExistsvoid fire(BiConsumer<FactHandle,Object> consumer)
Fires the session and calls the consumer for each memory object and its fact handle.
consumer - consumer for session memoryvoid 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();
System.out.println(c.getSomeUpdatedProperty());
While this method is the fastest among the other fire(..) methods, it is only
applicable if the provided FactStorage SPI implementation stores facts by reference
(e.g. does not serialize/deserialize objects)
void fire(Consumer<Object> consumer)
Fires the session and calls the consumer for each memory object.
consumer - consumer for session memory<T> void fire(String type, Consumer<T> consumer)
A convenience method to retrieve facts of a specific type name.
consumer - consumer for session memory<T> void fire(Class<T> type, Consumer<T> consumer)
A convenience method to retrieve the resulting instances of a specific Java class.
consumer - consumer for session memorydefault void insertAndFire(Object... objects)
Copyright © 2021. All rights reserved.