KIE :: Public API 9.44.0.Final API

KIE provides a knowledge-centric API, where rules and processes are first class citizens. The majority of KIE API is considered stable and should not change, experimental classes and APIs will be marked as such.

The most common interfaces you will use are:

  • org.kie.api.KieBase
  • org.kie.api.runtime.KieSession
  • org.kie.api.runtime.StatelessKieSession
  • org.kie.api.runtime.KieContainer
  • org.kie.api.builder.ReleaseId
  • org.kie.api.builder.KieScanner

Factory classes, with static methods, provide instances of the above interfaces. A pluggable provider approach is used to allow provider implementations to be wired up to the factories at runtime. The Factories you will most commonly use are:

  • org.kie.api.KieServices
  • org.kie.api.command.KieCommands
  • org.kie.api.io.KieResources

Typical example of loading and using knowledge resources (rules, processes, etc) found on classpath. By convention the KIE API expects file META-INF/kmodule.xml which is a marker file and also enables additional configuration. For very basic usage the file can just contain <kmodule xmlns="http://www.drools.org/xsd/kmodule"/>:

  KieServices kieServices = KieServices.Factory.get();
  KieContainer kieContainer = kieServices.getKieClasspathContainer();
  KieSession kieSession = kieContainer.newKieSession();
  try {
    kieSession.insert(new Fibonacci(10));
    kieSession.fireAllRules();
  } finally {
    kieSession.dispose();
  }

Drools 8 introduced Rule Unit API as a recommended style which provides an atomic module defining a set of rules and a set of strongly typed data sources:

  MeasurementUnit measurementUnit = new MeasurementUnit();
  RuleUnitInstance<MeasurementUnit> instance = RuleUnitProvider.get().createRuleUnitInstance(measurementUnit);
  try {
    measurementUnit.getMeasurements().add(new Measurement("color", "red"));
    List<Measurement> queryResult = instance.executeQuery("FindColor").stream().map(tuple -> (Measurement) tuple.get("$m")).collect(toList());
  } finally {
    instance.dispose();
  }

Package
Description
Base KIE API classes.
 
 
 
 
 
 
All classes to create definitions, as built by the KieBuilder from artifact resources, can be found here.
The classes that make up a Process definition.
The classes that make up a Rule definition.
 
Comprehensive event API for all parts of the platform.
Events emitted while updating the definitions in the KieBase.
Events emitted by the KieScanner.
Events emitted while process instances are executing.
Events emitted while rules are executing.
Process Fluent API allows programmer to build an in memory representation of a bpmn file.
This information can later be used to build a KIE resource and execute the process .
 
 
 
 
 
io library for working with Resources
Logger classes used to log the KieRuntime's execution.
 
Marshalling classes are used to marshall and unmarshal StatefulKieSessions
 
 
 
 
The runtime engine classes, including KieSession and StatelessKieSession.
 
 
 
The process runtime classes.
 
The rule runtime classes.
 
 
Classes related to calendars and time.