zhang shuai created DROOLS-5633:
-----------------------------------
Summary: 【looking for help】I want to load class from string instead of from
source, but it always failed
Key: DROOLS-5633
URL:
https://issues.redhat.com/browse/DROOLS-5633
Project: Drools
Issue Type: Feature Request
Reporter: zhang shuai
Assignee: Mario Fusco
I want to dynamically load rules(drl files) and java classes. And now I can load drl by
the below way. But I dont know how to dynamically load java classes by String type.
For example: I have a drl which is including class Person, so the Person must be existed
in my project. However my service is running, I can not restart the serbice, and I have
Person class in my database as String type. How can I load the String Person to kiebase?
please help me, thank you very much!
{code:java}
public static void loadRulesFromStr(InternalKnowledgeBase kBase, List<String> drls)
{
KnowledgeBuilderConfiguration kbc =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(kbc);
for (String drl : drls) {
kBuilder.add(ResourceFactory.newByteArrayResource(drl.getBytes()),
ResourceType.DRL);
}
if (kBuilder.hasErrors()) {
System.out.println(kBuilder.getErrors().toString());
}
kBase.addPackages(kBuilder.getKnowledgePackages());
}
{code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)