[jboss-jira] [JBoss JIRA] (DROOLS-2537) Executable model - kcontext cannot be used as a RuleContext
Luca Molteni (JIRA)
issues at jboss.org
Thu May 10 10:13:02 EDT 2018
[ https://issues.jboss.org/browse/DROOLS-2537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13574387#comment-13574387 ]
Luca Molteni commented on DROOLS-2537:
--------------------------------------
The DSL is based on `org.drools.model.Drools`, which is a different interface than `org.kie.api.runtime.rule.RuleContext`
At runtime the object passed is an instance of `org.drools.modelcompiler.consequence.DroolsImpl`, which is both an implementation of RuleContext and Drools but as the DSL doesn't know about kie-api someone using it cannot assume the object is of that type.
One thing we could do is to rewrite the method using RuleContext as a parameter using a late binding downcast, something like this
{{
public class FactWithRuleContext {
public String getRuleName(final Object ruleContext) {
final RuleContext ruleContext1 = (RuleContext) ruleContext;
return ruleContext1.getRule().getName();
}
}}}
> Executable model - kcontext cannot be used as a RuleContext
> -----------------------------------------------------------
>
> Key: DROOLS-2537
> URL: https://issues.jboss.org/browse/DROOLS-2537
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 7.7.0.Final
> Reporter: Tibor Zimányi
> Assignee: Mario Fusco
>
> When using kcontext in RHS as a RuleContext, the execution throws incompatible types exception [1]. The problem could be that kcontext is translated to Drools and not to DroolsImpl in the model DSLs.
> PR with a reproducer is here: https://github.com/kiegroup/drools/pull/1896/files#diff-67291fa531041ec60d75478a86b936e9R103
> [1] https://gist.github.com/baldimir/94cd43fc10215dd3ef8dad16a0e830d8
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list