<div dir="ltr">hi ,<br>i m new in drools, i m reading the Drools-JBoss-Rules-5.0-Developers-Guide book in which i found a validation rule example on its chapter 3. In this exemple, global variables were set into the session with two methods shown in this code : <br>
<br>...<br>session = knowledgeBase.newStatelessKnowledgeSession();<br> session.setGlobal("reportFactory", reportFactory);<br> session.setGlobal("inquiryService", inquiryService);<br>...<br><br>and these variables <span id="result_box" class="short_text" lang="fr"><span class="hps">qualified</span></span> as immutables, were called from the RuleContext <br>
<br>public static void error(RuleContext drools,<br> Object... context) {<br> KnowledgeRuntime knowledgeRuntime = drools<br> .getKnowledgeRuntime();<br> ValidationReport validationReport = (ValidationReport) <br>
knowledgeRuntime.getGlobal("validationReport");<br> ReportFactory reportFactory = (ReportFactory) <br> knowledgeRuntime.getGlobal("reportFactory");<br>...<br><br>and for other variables(or facts ) the Command interface was used instead :<br>
<br> List<Command> commands = new ArrayList<Command>();<br> commands.add(CommandFactory.newSetGlobal(<br> "validationReport", report));<br> commands.add(CommandFactory<br> .newInsertElements(getFacts(customer)));<br>
session.execute(CommandFactory<br> .newBatchExecution(commands));<br><br>i m looking for accuracy in understanding when and which to use each method. <br><br></div>