Reputation: 1
I am try to make some experience with Drools framework. During my test I try the following test
@Test public void testDrools() {
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
assertSame(session.getKnowledgeBase(), kbase);
}
Why this test fails? Is it not true that session has a reference to KnowledgeBase
used for its creation? I am a little bit confused about that. Maybe some one can help me to understand it.
Thank you very much in advance. Alberto
Upvotes: 0
Views: 369
Reputation: 3901
This is an implementation detail and happens mostly because Drools had to maintain backward compatibility with Drools 4.x versions. Both kbase and session.getKnowledgeBase() are wrappers over the real knowledge base, and because of that you have 2 wrappers, but there is only one actual instance of the knowledge base that both wrappers point to.
Upvotes: 1