Reputation:
Basically I want to store a class reference as global variable from spring service class and use the same inside the DRL file to access method and properties of global reference.
Upvotes: 1
Views: 3390
Reputation: 596
Inside your service class use below code:
StatelessKnowledgeSession knowledgeSession;
CustomClass reference;
knowledgeSession.setGlobal("global1", reference);
knowledgeSession.execute(fact);
Inside DRL file
import CustomClass;
global CustomClass global1
Use reference inside any rule.
Upvotes: 2
Reputation: 67
you have to set the object ref into the kieSession as below
kieSession.setGlobal("serviceName", serviceRef);
and in your drools file import the global reference
global com.example.Service serviceName
Upvotes: 2