Show Table of Contents
13.40. Convenience Methods using the Kcontext Variable
- The call
kcontext.getKnowledgeRuntime().halt()terminates rule execution immediately. - The accessor
getAgenda()returns a reference to the session'sAgenda, which in turn provides access to the various rule groups: activation groups, agenda groups, and rule flow groups. A fairly common paradigm is the activation of some agenda group, which could be done with the lengthy call:// give focus to the agenda group CleanUp kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup( "CleanUp" ).setFocus();
(You can achieve the same usingdrools.setFocus( "CleanUp" ).) - To run a query, you call
getQueryResults(String query), whereupon you may process the results. - A set of methods dealing with event management lets you add and remove event listeners for the Working Memory and the Agenda.
- Method
getKnowledgeBase()returns theKnowledgeBaseobject, the backbone of all the Knowledge in your system, and the originator of the current session. - You can manage globals with
setGlobal(...),getGlobal(...)andgetGlobals(). - Method
getEnvironment()returns the runtime'sEnvironment.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.