Monday, July 8, 2013

Drools Core

  1. create a knowledge builder to load processes from various resources (for example from the classpath or from file system)
  2. create a knowledge base from the builder
  3. instantiate a session based on the knowledge base
  4. start executing processes
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"), ResourceType.DRF);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ProcessInstance processInstance = ksession.startProcess("com.sample.MyProcess");
ksession.fireAllRules();

No comments:

Post a Comment