0

以下代码行直接来自文档

ksession.addEventListener(new DebugWorkingMemoryEventListener());

eclipse中提示如下错误

WorkingMemoryEventManager 类型中的方法 addEventListener(WorkingMemoryEventListener) 不适用于参数 (DebugWorkingMemoryEventListener)

4

1 回答 1

1

您可能 importorg.drools.event.DebugWorkingMemoryEventListener而不是org.drools.event.rule.DebugWorkingMemoryEventListener.

在我们的例子中,以下代码可以正常工作:

import org.drools.event.rule.DebugWorkingMemoryEventListener;
import org.drools.event.rule.ObjectInsertedEvent;
import org.drools.event.rule.ObjectRetractedEvent;
import org.drools.event.rule.ObjectUpdatedEvent;
...
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
ksession.addEventListener(new DebugWorkingMemoryEventListener() {
    @Override
    public void objectInserted(ObjectInsertedEvent event) {
        System.out.println(event);
    }

    @Override
    public void objectRetracted(ObjectRetractedEvent event) {
        System.out.println(event);
    }

    @Override
    public void objectUpdated(ObjectUpdatedEvent event) {
        System.out.println(event);
    }
});
于 2013-04-10T15:29:10.783 回答