[rules-users] Using immutable Globals in the new Command API

Dan Seaver dan.seaver at ge.com
Thu Apr 30 12:55:29 EDT 2009


In the M5 release, I could use a Boolean global as an Out type parameter and
changes I made to the global would be maintained in the results. In CR1, I
use the CommandFactory to add the global with out set to true, and I get
back the initial value of the Boolean, not the updated value. 

Here's a code snippet:
		List<Command< ? >> commands = new ArrayList<Command< ? >>();
		commands.add(CommandFactory.newInsertElements(sessionFacts));
		commands.add(CommandFactory.newSetGlobal("result", null, true));
		Command< ? > execution = CommandFactory.newBatchExecution(commands);
		BatchExecutionResults results = session.execute(execution);

Here's the rule that fires:
	rule 'Initialize'
	dialect 'mvel'
	when
	then
		drools.getWorkingMemory().setGlobal("result", new Boolean(false));
		logger.debug("Initialized result to false");
	end


In M5, result would have a value of false.
In CR1, result has a vaule of null.

Am I doing something wrong with the new command structure?
Is this behavior expected, or is it supposed to work like it did in M5?

Thanks for any assistance.
Dan
-- 
View this message in context: http://www.nabble.com/Using-immutable-Globals-in-the-new-Command-API-tp23320281p23320281.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list