Following code will help you to understand and write the basic steps of Drools. It;s not a executable code. Hope this will help to write your logic.
RuleAdministrator mVRuleAdministrator = serviceProviderBean.getRuleServiceProvider().getRuleAdministrator();
LocalRuleExecutionSetProvider mVRuleExecutionSetProvider = mVRuleAdministrator.getLocalRuleExecutionSetProvider(null);
SpreadsheetCompiler mVCompiler = new SpreadsheetCompiler();
String mSDrl = mVCompiler.compile(new FileInputStream(INPUT_EXCEL_FILE), InputType.XLS);
Reader mVReader = new StringReader(mSDrl);
RuleExecutionSet cachedRuleSet = mVRuleExecutionSetProvider.createRuleExecutionSet(mVRuleReader, null);
String mSUri = cachedRuleSet.getName();
mVRuleAdministrator.registerRuleExecutionSet(mSUri, cachedRuleSet, null);
String serviceProviderClass = "org.drools.jsr94.rules.RuleServiceProviderImpl";
String serviceProvider = "http://drools.org";
RuleServiceProviderManager.registerRuleServiceProvider(
serviceProvider, Class.forName(serviceProviderClass));
RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider(serviceProvider);
RuleRuntime mVRuleRuntime = ruleServiceProvider.getRuleRuntime();
List mVRegistrations = mVRuleRuntime.getRegistrations();
StatelessRuleSession mVStatelessRuleSession =
(StatelessRuleSession) mVRuleRuntime.createRuleSession(
mSUri, new HashMap(), RuleRuntime.STATELESS_SESSION_TYPE);
mVInputList.add(null/* Add all objects for which rule should be executed */);
List mRResults = mVStatelessRuleSession.executeRules(mVInputList);
Posted by
Unknown
on
12:07 AM
Labels:
Tips n Tricks
Subscribe to:
Posts (Atom)