[rules-users] what is the difference between process variable & global variables?

gs76pl gstasica at pacemetrics.com
Wed Apr 13 07:39:35 EDT 2011


hi,

this seems like a basic question i should know the answer to after reading
some documentation but unfortunately after doing some tests with
onExitActions there seems to be some discrepancy between what doc reads and
how the process/action behaves. Could anyone verify my observations:

1. while documentation in "4.4. Data" reads "...Actions can access variables
directly, simply by using the name of the variable as a parameter name" in
fact this is INCORRECT as at that point actions expect a global object to be
in the session!! e.g. below code in onExitAction throws an exception if
tracker obj hasn't been defined as a global variable and entered into the
session (it doesn't matter that the process has tracker variable defined)

tracker.addVisitedNode("dasdf");

2. the only way of accessing process variables is via context object as
below

context.getVariable("tracker")

3. inserting/updating object in the session can be done 
a) context.getKnowledgeRuntime().insert("myFact");
b) insert("myFact");

looks like there is no difference here and the second one is simple a
shorter version of doing the same



--
View this message in context: http://drools.46999.n3.nabble.com/what-is-the-difference-between-process-variable-global-variables-tp2815658p2815658.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list