Hi, I want to replace an outdated function defined in a drl file without
touching that file, is this possible? (in 5.5.0)
The java application part that loads the resources cannot be touched as
well. It is configured to read all the drl files from a predefined folder, I
am only allowed to add-in new drl files.
Here are what I have tried:
1. Create a new drl file with the new function with same package name and
same function name
This works *only* if the new file is loaded after the old file.
As I cannot change how the java application loads the resources, I cannot
guarantee the new file is always loaded after the old one, so I tried the
next method.
2. Create a new drl file with the new function with same function name. Add
a rule with high salience and call
drools.getKnowledgeRuntime().getKnowledgeBase().removeFunction("old_package",
"oldFunc");
Function newFunc =
((org.drools.impl.KnowledgeBaseImpl)drools.getKnowledgeRuntime().getKnowledgeBase()).getRuleBase().getPackage("new_package").getFunctions().get("oldFunc");
// a new implementation with the same name
((org.drools.impl.KnowledgeBaseImpl)drools.getKnowledgeRuntime().getKnowledgeBase()).getRuleBase().getPackage("old_package").addFunction(newFunc);
But this didn't work. When the rules are fired, it complains about the
old_package cannot find the function anymore.
Could anyone from the Drools team provide some help on this?
Thanks a lot!
--
View this message in context:
http://drools.46999.n3.nabble.com/Replacing-an-old-function-in-drl-tp4024...
Sent from the Drools: User forum mailing list archive at
Nabble.com.