[
http://jira.jboss.com/jira/browse/JBRULES-1430?page=comments#action_12402420 ]
Mark Proctor commented on JBRULES-1430:
---------------------------------------
Just as a reminder there is no function interface, it's just a static method call.
But you can do something like this:
function void addRule(String pkgName, String rule, RuleBase ruleBase ) {
PackageBuilder builder = new PackageBuilder();
builder.addPackgeFromDrl( new StringReader( rule ) );
ruleBase.addPackage ( builder.addPackage() );
}
rule X
when
then
String rule = "package org.drools.test\n global java.util.List list\n rule xxx\n
when\n i:Integer()\nthen\n list.add(i);\nend";
addRule( "org.domain", rule, drools.getWorkingMemory().getRuleBase() );
end
There is nothing stopping you passing drools.getWorkingMemory() and
drools.getWorkingMemory().getRuleBase() as parameters.
The extra work needed, as described above, just to achieve this isn't trivial. But we
will consider any robust patches you have.
Improve Function feature
------------------------
Key: JBRULES-1430
URL:
http://jira.jboss.com/jira/browse/JBRULES-1430
Project: JBoss Drools
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: All
Affects Versions: 4.0.4
Environment: all
Reporter: longDuck dong
Priority: Minor
The current design of the Function is a bit limiting. for example, if I want to write a
function to insert, update or retract facts, the current design does not support it.
According to the docs
http://downloads.jboss.com/drools/docs/4.0.4.17825.GA/html/ch06s04.html, functions are
just helper methods. It would be more powerful if the function always passes the
workingmemory to the function. This way, the functions can easily access the globals or
access the rule engine. Basically, something similar to JESS funcall
http://herzberg.ca.sandia.gov/docs/70/api/jess/Funcall.html.
It also makes it easier for developers to encapsulate common actions in the consequence
in a function and use it easily from a DSL. The pattern is well proven in CLIPS, JESS and
haley.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira