[rules-users] Example for using globals in Drools3.0.6
JLL
jll at labocollard.be
Wed May 30 05:38:46 EDT 2007
after reread some of my source files
you don't need to initialize $mock so ...
in the rule file
don't forget to import your Mock
and
global Mock mock
in the when
conditions
in the then statement
mock.setMyString("hello world");
JLL wrote:
>
> hi
>
> i thing using a string could cause some problems
> better use your own object named like "Mock" containing a string with
> setter and getter
>
> in the java code assert the object in working memory with
> MemoryManager.getWorkingMemory().setGlobal("mock", mock);
>
> in the rule file
> don't forget to import your Mock
> and
> global Mock mock
>
> in the when
> $mock : Mock( )
> and other conditions
>
> in the then statement
> $mock.setMyString("hello world");
>
> after the rule fire the value must have been changed ...
>
> hope it's clear enough
> friendly
>
> JLL
>
>
> Joj wrote:
>>
>> Hi,
>>
>> In the document, its written that "They are typically used to return
>> data" under globals section. How can I return a global value to the
>> calling method? In other words, how can I receive it in Java code? Can
>> anybody explain with a simple example?
>>
>> And please identify the changes required if I need to get the value of
>> global in the example below:
>>
>> ........
>>
>> global String status
>>
>> rule "FindStatus"
>> when
>> student: Student ( mark >= 50 )
>> then
>> status = "passed";
>> end
>>
>>
>> In this case, there's no need of a global variable, I know. But, anyway,
>> how can I get its value on the calling method?
>>
>>
>> Thanks in advance,
>> Jojan
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Example-for-using-globals-in-Drools3.0.6-tf3838437.html#a10870403
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list