testFunctions.drl
package org.drools.examples.functions;
function String sayHello(String msg) {
return "Hello " + msg + "!";
}
rule "using a function"
when
eval(true)
then
System.out.println(sayHello("TEST"));
end
Example_Functions.java
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-rules-functions");
kSession.fireAllRules();
kSession.dispose();