On 09/02/2012, Salina Fung/UFL - ICIL <salina(a)icil.net> wrote:
We have 2 rules - rule 1 and rule 2, both have
declared variable @role(event)
This is not a "variable" in the sense of the word as 99.99% use it.
The "declare EventImpl @role(event)...end tells Drools that
facts of type EventImpl are facts with extended semantics,
i.e., a timestamp and duration, and Fusion functions can
be applied. Read the documentation!
In the program with statements to define the rule
<<
String rule1 = "package test001 import com.icil.event.*; declare EventImpl
@role(event) end rule \"test 001\" when Integer() then
System.out.println(\"rule test 001: there is an integer\"); end ";
String rule2 = "package test002 import com.icil.event.*; declare EventImpl
@role(event) end rule \"test 002\" when Integer() then
System.out.println(\"rule test 002: there is an integer\"); end ";
>
and then try to load these two into the same knowledge base using Drools
5.3,
will get an runtime exception. But Drools 5.2, this is ok, with
no error.
I'm not trying to guess the exception.
Then in Drools 5.2
We try to print the address of the variable 'event' in the RHS of both
rules, the
address is the same in both rules, which means they are sharing the same
instance?
"event" is merely a word in the DRL text, recognized and discarded by
the DRL parser. So I'd be *very* much surprised if you can obtain its
"address" at runtime, in the RHS.
It's a pity that you don't show the code with which you print the
"address"
of something. In Java, that's quite an unusual thing to do.
Please don't report about things without showing them, in full.
-W
Is it the declared variables with the same name in separate
rules being loaded in the same knowledge base, will just
have ONE instance?
Thanks
Salina