History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: DROOLS-466
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Michael Neale
Reporter: Charles Zhao
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
drools-legacy

Custom entity resolver support for RuleSetReader

Created: 14/Dec/05 05:00 PM   Updated: 18/Dec/05 10:10 PM
Component/s: io
Affects Version/s: 2.1
Fix Version/s: 2.5

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive drools-466.zip (12 kb)
2. Java Source File RuleSetReader.java (31 kb)



 Description  « Hide
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" >
]>
<rule-set name="RuleSet"
xmlns="http://drools.org/rules"
xmlns:java="http://drools.org/semantics/java"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/rules rules.xsd http://drools.org/semantics/java java.xsd">

<!-- RULE FRAGMENT INCLUDES HERE -->
&sub-rules;

</rule-set>

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.

Thanks.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Michael Neale - 14/Dec/05 06:40 PM
Would love to include this in 2.5 - a test case to show it off is all that is needed - are you able to provide one. A true unit test may be difficult, but if it is an integration test, I can include it in the Integration test suite.

Charles Zhao - 15/Dec/05 10:17 AM
Sounds good, I've attached the project I have that contains modified RuleSetReader as well as the test case. It requires maven to build.

Michael Neale - 18/Dec/05 10:10 PM
incorporated into 2.5