[rules-users] Initialize Global

Anstis, Michael (M.) manstis1 at ford.com
Thu Oct 25 04:43:26 EDT 2007


Do you want a true "global" variable or a "fact" available to all rules?

Either way, you could have a rule to set it up...

Rule "init-global"
	When
	Then
		myGlobal.doSomethingToInitialiseIt();
End

Rule "init-fact"
	When
	$f : MyFact()
	Then
		$f.doSomethingToInitialiseIt();
End


-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of drools_user
Sent: 24 October 2007 18:35
To: rules-users at lists.jboss.org
Subject: [rules-users] Initialize Global


How do I initialize a global fact in the drl file?  I want use the JSR94 API
and avoid using the Drools API inside the Java code.  I would like to access
the same variable every execution of a stateful session without having to
reinstantiate the variable after each execution?

Basically I want to define a global like this:
# Define global variable
global List objectList ;

# Part that does not work
objectList = new ArrayList() ;
objectList.add("1");
objectList.add("2"); 


Thanks
-- 
View this message in context:
http://www.nabble.com/Initialize-Global-tf4685186.html#a13388685
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4159 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20071025/69711321/attachment.bin 


More information about the rules-users mailing list