@chetan, when you make a call to dmn engine to evaluate decision table like below:
dmnEngine.evaluateDecisionTable(decision, variables);
Based on the provided DmnEngineConfiguration
engine will set the various handlers and listeners to the DefaultDmnDecisionContext:
evaluationListeners = configuration.getDecisionEvaluationListeners();
evaluationHandlers.put(DmnDecisionTableImpl.class, new DecisionTableEvaluationHandler(configuration));
Once DecisionContext
was build, it will invoke the below evaluateDecision() function:
public DmnDecisionResult evaluateDecision(DmnDecision decision, VariableContext variableContext);
In this function call, appropriate DmnDecisionLogicEvaluationHandler will be resolved and the evaluation of decisionTable is delegated to the handler.
Next, handler executes the evaluate function. This evaluate function resolves the handler based from the DMNDecision
input whether DecisionLiteralExpressionEvaluationHandler or DecisionTableEvaluationHandler.
DmnDecisionLogicEvaluationEvent evaluatedEvent = handler.evaluate(evaluateDecision, variableMap.asVariableContext());
Once handler is resolved, the evaluate()
finds the matching rules and set it to DmnDecisionTableEvaluationEvent
List<DmnDecisionTableRuleImpl> matchingRules = new ArrayList<DmnDecisionTableRuleImpl>();
DmnDecisionTableEvaluationEventImpl evaluationResult = new DmnDecisionTableEvaluationEventImpl();
evaluationResult.setMatchingRules(evaluatedDecisionRules);
Finally, all the matching rules are will be evaluated and added to the DmnDecisionLogicEvaluationEvent
.
Here’s the place where registered DmnDecisionTableEvaluationListener
will be get invoked.
for (DmnDecisionTableEvaluationListener evaluationListener : evaluationListeners) {
evaluationListener.notify(evaluationResult); //executes DmnDecisionTableEvaluationListener
}
Conclusion:
-
Then evaluated results are returned as DmnDecisionResult. DmnDecisionResult will not contains the matchingRules, it contains only the results of the rule execution output.
-
So the DmnDecisionTableEvaluationEvent
has the matchingRules which can be accessed from registering the DmnDecisionTableEvaluationListener
.