After stepping through the code a bit I learned that the Spring class
LocalRuleExecutionSetProviderImpl is looking for the key dsl in the properties
object that is passed in and that it expects the value object in the hash table
to be either a java.io.Reader or a String object containing the contents of the
dsl file. So I modified my configuration to pass in an instance of Reader for
the dsl file.
So I created a simple class, ReasourceAsReader, that is a FactoryBean that converts a Resource to a java.io.Reader. I then assigned this bean to the hashtable that is passed into the DefaultRuleSource as follows:
Code:
<bean id="ruleSource" class="org.springmodules.jsr94.rulesource.DefaultRuleSource">
<property name="ruleRuntime">
<ref local="ruleRuntime" />
</property>
<property name="ruleAdministrator">
<ref local="ruleAdministrator" />
</property>
<property name="source">
<value>classpath:com/sybase/it/cosmos/rules/order-release.drl</value>
</property>
<property name="bindUri">
<value>autoRelease</value>
</property>
<property name="rulesetProperties">
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="dsl">
<bean class="com.sybase.it.cosmos.spring.ResourceReader">
<property name="source">
<value>classpath:/com/sybase/it/cosmos/rules/order-release.dsl</value>
</property>
</bean>
</entry>
</map>
</property>
</bean
The code for the FactoryBean is as follows:
Code:
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
public class ResourceReader implements FactoryBean, InitializingBean {
private Resource source = null;
private java.io.Reader reader = null;
public void setSource(Resource source) {
this.source = source;
}
public void afterPropertiesSet() throws Exception {
if(source == null) {
throw new IllegalArgumentException("Resource cannot be null!");
}
EncodedResource er = new EncodedResource(source);
reader = er.getReader();
}
public Object getObject() throws Exception {
return reader;
}
public Class getObjectType() {
return java.io.Reader.class;
}
public boolean isSingleton() {
return true;
}
}
Now the dsl file is loaded but I'm receiving the following exception:
Code:
Caused by:
org.drools.rule.InvalidRulePackage:
org.drools.lang.ExpanderException
<at> 993028org.drools.lang.ExpanderException
<at> 128b33aorg.drools.lang.ExpanderException
<at> 10ea988org.drools.lang.ExpanderException
<at> 19c4844org.drools.lang.ExpanderException
<at> 14c8f24org.drools.lang.ExpanderException
<at> 1498526org.drools.lang.ExpanderException
<at> 1c4a760org.drools.lang.ExpanderException
<at> 1c8ce14org.drools.lang.ExpanderException
<at> 51b326org.drools.lang.ExpanderException
<at> 1c8997eorg.drools.lang.ExpanderException
<at> d54d3forg.drools.lang.ExpanderException
<at> 1c26386org.drools.lang.ExpanderException
<at> 1140cf6org.drools.lang.ExpanderException
<at> 15efa6aorg.drools.lang.ExpanderException
<at> 8a750aorg.drools.lang.ExpanderException
<at> 9e6e0org.drools.lang.ExpanderException <at> 14b389
at org.drools.rule.Package.checkValidity(Package.java:368)
Any ideas as to what might be causing this?
Thanks for the help...