Created
August 19, 2014 17:49
-
-
Save gowrishankarin/e72f4e0dddbdaf694e6a to your computer and use it in GitHub Desktop.
Drools Knowledge Base and Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); | |
kbuilder.add(ResourceFactory.newFileResource("/home/shankar/Public/licenseApplication.drl"), ResourceType.DRL); | |
if( kbuilder.hasErrors() ) { | |
System.err.println(kbuilder.getErrors().toString()); | |
} | |
org.kie.internal.KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); | |
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); | |
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); | |
Applicant applicant = new Applicant(); | |
applicant.setName("Gowri Shankar"); | |
applicant.setAge(21); | |
//assertTrue(applicant.isValid()); | |
ksession.execute(applicant); | |
/* | |
GRADLE DEPENDENCIES | |
compile('org.apache.commons:commons-jci-core:1.1') | |
compile("org.drools:drools-core:6.0.1.Final") | |
compile('org.drools:drools-compiler:6.0.1.Final') | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.prodapt.m2m.na.drools | |
rule "Is of valid age" | |
when | |
$a : Applicant( age < 18 ) | |
then | |
$a.setValid(false); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment