use of org.drools.ruleunits.impl.sessions.RuleUnitExecutorImpl in project drools by kiegroup.
the class InterpretedRuleUnit method internalCreateInstance.
@Override
public RuleUnitInstance<T> internalCreateInstance(T data) {
KnowledgeBuilder kBuilder = new KnowledgeBuilderImpl();
Class<? extends RuleUnitData> wmClass = data.getClass();
String canonicalName = wmClass.getCanonicalName();
// transform foo.bar.Baz to /foo/bar/Baz.drl
// this currently only works for single files
InputStream resourceAsStream = wmClass.getResourceAsStream(String.format("/%s.drl", canonicalName.replace('.', '/')));
kBuilder.add(new InputStreamResource(resourceAsStream), ResourceType.DRL);
InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addPackages(kBuilder.getKnowledgePackages());
ReteEvaluator reteEvaluator = new RuleUnitExecutorImpl(kBase);
return new InterpretedRuleUnitInstance<>(this, data, reteEvaluator);
}
Aggregations