
The StatelessSession wraps the WorkingMemory, instead of extending it, its main focus is on decision service type scenarios.
StatelessSession session = ruleBase.newStatelessSession(); session.execute( new Cheese( "cheddar" ) );
The api is reduced for the problem domain and is much simpler making maintenance of those services easier. The RuleBase never retains a reference to the StatelessSession, thus dispose() is not needed, and they only have an execute() method that takes an object, an array of objects or a collection of objects - there is no insert or fireAllRules. The execute method iterates the objects inserting each and calling fireAllRules() at the end; session finished. Should the session need access to any results information they can use the executeWithResults method, which returns a StatelessSessionResult. The reason for this is in remoting situations you do not always want the return payload, so this way its optional.
setAgendaFilter, setGlobal and setGlobalResolver share their state across sessions; so each call to execute() will use the set AgendaFilter, or see any previous set globals etc.
StatelessSessions do not currently support propertyChangeListeners.
Async versions of the Execute method are supported, remember to override the ExecutorService implementation when in special managed thread environments such as JEE.
StatelessSessions also support sequential mode, which is a special optimised mode that uses less memory and executes faster; please see the Sequential section for more details.

StatelessSession.executeWithResults(....) returns a minimal api to examine the sessions data. The inserted Objects can be iterated over, querries can be executed and globals retrieved. Once the StatelessSessionResult is serialised it loses the reference to the underlying WorkingMemory and RuleBase, so querries can no longer be executed, however globals can still be retrieved and objects iterated. To retrieve globals they must be exported from the StatelessSession; the GlobalExporter strategy is set with StatelessSession.setGlobalExporter( GlobalExporter globalExporter ). Two implementations of GlobalExporter are available and users may implement their own strategies. CopyIdentifiersGlobalExporter copies named identifiers into a new GlobalResovler that is passed to the StatelessSessionResult; the constructor takes a String[] array of identifiers, if no identifiers are specified it copies all identifiers declaredin the RuleBase. ReferenceOriginalGlobalExporter just passes a reference to the original Global Resolver; the later should be used with care as identifier instances can be changed at any time by the StatelessSession and the GlobalResolver may not be serialiser friendly.
StatelessSession session = ruleBase.newStatelessSession(); session.setGlobalExporter( new CopyIdentifiersGlobalExporter( new String[]{"list"} ) ); StatelessSessionResult result = session.executeWithResults( new Cheese( "stilton" ) ); List list = ( List ) result.getGlobal( "list" );