[rules-users] Re: access to in working memory generated objects

Marcus Ilgner marcus.ilgner at gmail.com
Wed Jun 18 07:32:10 EDT 2008


Hi,

On Wed, Jun 18, 2008 at 1:17 PM, Alexander Claus <styjdt at claus4joy.de> wrote:
>> I want to use rules which shall generate as a consequence a new java
>> object.
>> The GUI of my application shall display the new generated objekt.
>> but how can the GUI of my application get informed by the rule engine that
>> it has generated a new object (Warning)? And how the GUI or any other java
>> component can access this new generated object from outside?
>
> Have a look at org.drools.event.WorkingMemoryEventListener.
> I think you find yourself how to use it.
>
> Best regards.
> Alexander Claus

another approach would be to register some service as a global to your
working memory. Then, when creating the object in the RHS of your
rule, you call some method on it like this

rule "Value below threshold"
    when
        FactX ( property  < threshold)
    then
        Warning warning = new Warning( "Under threshold" );
        service.addWarning(warning);
        insert(warning);
end

Best regards
Marcus



More information about the rules-users mailing list