I have a .drl file which serves as a common file for functions for my various rule files.
This .drl file which holds my common functions is in package com.sample.common. (file: a_common.drl)
I have a rule file which is also in package com.sample.common and the rules execute just fine. (file: rule1.drl)
I have a rule file which is in package com.sample.common.anotherpackage and the rules fail due to the function call not being available. (file: rule2.drl)
If I have read the various posts on this subject correctly, there is no easy way to make both of my rule files ( rule1.drl & rule2.drl ) access the common rule file a_common.drl unless I change the package name of rule2.drl to com.sample.common...
I am aware that I could do something by adjusting Java code outside of the .drl files; however, in my case I need to stick to working with functions in .drl files.
File: a_common.drl
package com.sample.common
function boolean getFirstX(String string, int x){
...somecode
return (string != null);
}
function boolean getNextX(String string, int x){
...somecode
return (string != null);
}
File: rule1.drl ( function getFirstX works fine )
package com.sample.common
rule "Hello World"
when
eval( getFirstX("somevalue") )
then
....do something
end
File: rule2.drl ( function getFirstX is not found )
package com.sample.common.anotherpackage
rule "Hello World"
when
eval( getFirstX("somevalue") )
then
....do something
end
question from:
https://stackoverflow.com/questions/65924085/drools-function-access 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…