Search code examples
droolsdrools-guvnor

What is the difference between the two FactType interfaces?


I'm using Drools 5.3.5 and a declarative Fact Model defined in guvnor. I have both drools-core-5.3.5.Final.jar and knowledge-api-5.3.5.Final.jar on the classpath of the application interacting with the rules engine.

Each of these JARs contains an interface called FactType:

drools-core-5.3.5.Final.jar   -> org.drools.rule.FactType  
knowledge-api-5.3.5.Final.jar -> org.drools.definition.type.FactType

I see that org.drools.KnowledgeBase.getFactType() returns org.drools.definition.type.FactType objects; so what is org.drools.rule.FactType used for? Should my code always make use of the knowledge-api FactType?


Solution

  • It's possible that org.drools.rule.FactType is some trash that's been left over after some refactoring. A grep for the full class name doesn't return a hit. (I think I've seen other duplicates but forgive me for not searching for them.)

    The -api- jar evolved during 5.x as an intent to collect all of the stable IFs in one jar.

    By all means: stick with the classes you find in the "stable" javadoc, i.e., org.drools.definition.type.FactType. This is the only way (at least, the best effort) to maintain compatibility when upgrading to later versions.