I'm trying to migrate from drools 5 to drools 7. In version 6 there were changes in the spring integration. Based on the documentation drools:resources drools:resource was removed, however I couldn't find out how to achieve the same behavior with the new toolset. What I want is to have different kiebases with different rules, that are defined in drl files.
The documentation says that the resources can be defined using packages. Unfortunately in my case a package may contain several drl files and I want to filter some of them.
What I had in drools 5.x:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools-spring="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<drools-spring:kbase id="rules1And3">
<drools-spring:resources>
<drools-spring:resource source="classpath:rules/Rules1.drl"/>
<drools-spring:resource source="classpath:rules/Rules3.drl"/>
</drools-spring:resources>
</drools-spring:kbase>
<drools-spring:kbase id="rules2And3">
<drools-spring:resources>
<drools-spring:resource source="classpath:rules/Rules2.drl"/>
<drools-spring:resource source="classpath:rules/Rules3.drl"/>
</drools-spring:resources>
</drools-spring:kbase>
<bean id="ruleSessionAutoRefundAndPox" factory-bean="rules1And3"
factory-method="newStatelessKnowledgeSession"/>
<bean id="ruleSessionNonCashRefund" factory-bean="rules2And3"
factory-method="newStatelessKnowledgeSession"/>
</beans>
So here there were 3 files under the Rules. The first kbase only had rule 1 and rule 2 and the second had only rule 2 and rule3.
How it "should" look like in 7.x:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:kie="http://drools.org/schema/kie-spring"
xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://drools.org/schema/kie-spring http://drools.org/schema/kie-spring.xsd">
<kie:kmodule id="rules">
<kie:kbase name="rules1And3">
<!--loaded drl files-->
</kie:kbase>
<kie:kbase name="rules2And3">
<!--loaded drl files-->
</kie:kbase>
</kie:kmodule>
<!-- maybe these are unnecessary and instead ksessions should been defined within kbase elements-->
<bean id="sessionRules1And3" factory-bean="rules1And3"
factory-method="newStatelessKnowledgeSession"/>
<bean id="sessionRules2And3" factory-bean="rules2And3"
factory-method="newStatelessKnowledgeSession"/>
</beans>
Based on what I saw I'm not even sure if the very same behavior is achievable in the new version or maybe the whole approach is wrong, but what I want is to be able to define which drl files are loaded for a kiebase.
Thanks for any help!