hi ,
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 :

...
session = knowledgeBase.newStatelessKnowledgeSession();
    session.setGlobal("reportFactory", reportFactory);
    session.setGlobal("inquiryService", inquiryService);
...

and these variables qualified as immutables, were called from the RuleContext

public static void error(RuleContext drools,
      Object... context) {
 KnowledgeRuntime knowledgeRuntime = drools
        .getKnowledgeRuntime();
    ValidationReport validationReport = (ValidationReport)
        knowledgeRuntime.getGlobal("validationReport");
    ReportFactory reportFactory = (ReportFactory)
        knowledgeRuntime.getGlobal("reportFactory");
...

and for other variables(or facts ) the Command interface was used instead :

 List<Command> commands = new ArrayList<Command>();
    commands.add(CommandFactory.newSetGlobal(
        "validationReport", report));
    commands.add(CommandFactory
        .newInsertElements(getFacts(customer)));
    session.execute(CommandFactory
        .newBatchExecution(commands));

i m looking for accuracy in understanding when and which to use each method.