Search code examples
javadrools

Is there an equivalent of method WorkingMemory.assertObject in Drools 6.0.1?


I'm trying to upgrade my app from Drools 2.0 to 6.0.1. In my code, I have something like that :

        workingMem.assertObject(fact);

The thing is that there is no longer assertObject method in WorkingMemory class.

According to this website, this method do that :

"Objects are asserted into the WorkingMemory, which allows the rule-engine to be aware of its existence, and a fact handle is returned as a reference. Once asserted, the fact may be used to satisfy some portion of any rule's activation condition."

I can't find any equivalent in Drools 6.0.1. Is there any way to get around this ?


Solution

  • You'll find the method - renamed to insert due to the obvious clash with assert - in interface org.kie.api.runtime.rule.EntryPoint:

    FactHandle insert(Object object)
    
    Inserts a new fact into this entry point
    
    Parameters:
        object - the fact to be inserted 
    Returns:
        the fact handle created for the given fact
    

    EntryPoint is extended into interface KieSession, which is the pivot object for fact storage and engine activation.