We are using Drools to build a validation framework and need to support reusable rule files that can be imported into ruleset files. We've searched around and seems the only way is to use xml entities (it would be very nice if drools has built-in import support though). Here is an example of how we use xml entity to import the rule file:
<?xml version="1.0" ?>
<!DOCTYPE rule-set [
<!ENTITY sub-rules SYSTEM "rules/sub-rules.java.drl" >
xs:schemaLocation="http://drools.org/rules rules.xsd http://drools.org/semantics/java java.xsd">
<!-- RULE FRAGMENT INCLUDES HERE -->
The problem is that we have to be able to import rule files from classpath as well. The solution came to my mind was to provide our own entity resolver that deals with rule files. But currently drools' RuleSetReader provides resolveEntity implementation that only resolves xml schemas and doesn't allow us to hook in another entity resolver.
So I would propose to change RuleSetReader to support custom entity resolver. Attached is the modified version of RuleSetReader I used to fix the problem locally, and hope you guys will add the support to drools.