View Full Version : DSL and drools
cfuser
Aug 11th, 2006, 10:21 AM
Is there any way of passing in a DSL? I see that there are ruleset/provider/registration properties, but not sure how to pass in the DSL reference. Any ideas (or is this even possible)? TIA.
:
<bean id="ruleSource"
class="org.springmodules.jsr94.rulesource.DefaultRuleSour ce">
<property name="ruleRuntime">
<ref local="ruleRuntime" />
</property>
<property name="ruleAdministrator">
<ref local="ruleAdministrator" />
</property>
<property name="source">
<value>com/xyz/rules/basicRules.drl</value>
</property>
<property name="bindUri">
<value>basicRules</value>
</property>
</bean>
:
Suzanne Overman
Oct 5th, 2006, 09:41 AM
I have the same question. In trying to switch from a .drl to a drl that uses a dsl, I added the line in the .drl file to specify the dsl.
expander metric_rules.dsl
But, when I run, I get the error message:
Unable to use expander. Make sure a expander or dsl config is being passed to the parser. [ExpanderResolver was not set].
In the Drools forums, it states that even though you specify the .dsl file in the .drl and have it in the classpath, you must also inform PackageBuilder of the dsl too. Looks like the way this is done is passing the dsl into the package builder like so:
Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/metric_rules.dsl" ) );
builder.addPackageFromDrl( source, dsl );
I do not see how to get at the package builder from the Spring Modules to set the dsl.
dennys
Oct 16th, 2006, 11:38 AM
Hi cfuser, Suzanne!
I am new this way... I found a solution... Well...
In the rulesetProperties set de dsl property, in body of de property set the text of the dsl file...
example:
<entry key="dsl"><value><![CDATA[[when]There is an Instance with field of "{value}"=i: Instance(field=="{value}")
[when]Instance is at least {number} and field is "{value}"=i: Instance(number > {number}, location=="{value}")
[then]Log : "{message}"=System.out.println("{message}");
[then]Set field of instance to "{value}"=i.setField("{value}");
[then]Create instance : "{value}"=assert(new Instance("{value}"));
[when]There is no current Instance with field : "{value}"=not Instance(field == "{value}")
[then]Report error : "{error}"=System.err.println("{error}");
[then]Retract the fact : '{variable}'=retract({variable}); //this would retract bound variable {variable}
[then]Enviar aviso que não está sendo gerado polling para o projeto=System.out.println("Não está sendo gerado polling para o projeto.");
[when]Esta sendo gerado polling para o projeto=ProjectModel( methodNoWithParam == true )
]]></value></entry>
Good codes! Bye!
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.