Drools

from Wikipedia, the free encyclopedia

Drools
Basic data

developer Red hat
Current  version 7.7.0
(April 4, 2018)
operating system Cross-platform
programming language Java
category Business rule engine
License ASL 2
http://www.drools.org/

Drools is a business rule management system (BRMS, roughly translated as "production control system") and is used to implement expert systems. Drools is a rule-based system and can itself react to different events.

The business rule management system uses the JSR-94 standard for the creation, maintenance and compliance of business processes within organizations. This standard defines a simple programming interface to link a rule engine with a Java platform .

JBoss Enterprise BRMS

JBoss Enterprise BRMS is a comprehensive platform for business rules management . The aim is the optimization of company resources and complex event processing (CEP, Complex Event Processing). It enables companies to use sophisticated decision-making logic in business applications, as the underlying business rulescan be quickly adapted to market conditions using propositional logic .

KIE (Knowledge is Everything) is the umbrella under which Drools and other related products such as OptaPlanner, jBPM, Guvnor, Drools WB, KIE WB and UberFire are collected from JBoss. KIE is also used as a collective term for the common aspects of the system; Uniform construction, provision and use for business processes.

Components of the Enterprise version:

  • JBoss Rule Engine - Drools Expert uses the Rete algorithm and the Drools Rule Language (DRL)
  • Complex Event Processing (Drools Fusion) - Used for complex event control
  • Drools Workbench with BPM application possibilities
  • Business Resource Planner (OptaPlanner) - Optimizes automated planning of business rules.
  • Developer tools
  • Business rule management and monitoring

Components of the community version:

  • Drools Workbench
  • Drools Expert (Business Rule Management)
  • Drools Fusion - Used for complex event controls
  • jBPM - processes and workflow
  • OptaPlanner - Optimizes automated planning

Drools

Drools is a Business Rule Management System (BRMS) software solution . It provides the basic equipment of a Business Rule Engine (BRE), a web application (Drools Workbench) and an Eclipse IDE plug-in for development.

What are rules

Rules have an "if .. then .." structure and consist of condition and consequence. They therefore have a premise and a conclusion ; Left-hand-side (LHS) and right-hand-side (RHS). The consequence of a rule is called an action. The condition of a rule checks facts about which the rule is applied. If a condition is confirmed, one speaks of "firing" a rule.

If such rules are implemented directly in the source code without the use of business rule management systems , this leads to problems in the maintenance and readability of the software . Business rule management systems are used to prevent these problems and also to implement conflict resolution. Clear advantages of a business rule engine are the explicitly formulated rules with the help of propositional logic and the declarative approach of the business rule engine.

Bedingung:
Mensch.hunger = true;

Konsequenz:
Mensch.essen();

Drools Rule Language

Drools has its own "native" rule language. The grammar of this language is easy to understand and only refers to the query of rules and conditions of an object.

A rules file is a file with a .drl extension. A .drl file can contain several rules, queries and functions as well as some resource declarations such as imports, as well as global and local attributes. It is also possible to distribute rules over several .drl files. Splitting rules across multiple files can help manage a large number of rules.

A .drl file is a simple text file with the following structure:

package
package-name


imports


globals


functions


queries


rules

A drools rule consists of a name, attributes (optional) and the components of a rule (LHS and RHS). Attributes are indications of how a rule should behave. LHS is the conditional part of a rule that follows a specific grammar. RHS is basically a block that executes the dialect-specific code as soon as a rule "fires".

rule
"name"


attributes

    when

LHS

    then

RHS

end

Drools example

This example shows a simple rule about admitting a person to a driving test. It examines a condition of the instance Applicant and sets the variable validto true or false depending on the result of the condition.

public class Applicant {
    private String name;
    private int age;
    private boolean valid;
    // getter and setter methods here
}
package com.company.license

rule "Is of valid age"
when
    $a : Applicant( age < 18 )
then
    $a.setValid( false );
end

First the class Applicant has to be created. After the data model has been created, a rule is formulated. This rule states that a person under the age of 18 will be assigned the value false.

When an instance of is inserted Applicantinto the business rule engine , it is evaluated against the restrictions of the rules. In this case there are two restrictions on a rule. There are two because the type is Applicantthe first object type restriction and Age <18 is the second field restriction.

An object type restriction including its field restrictions is referred to as a pattern. If an inserted instance meets both the object type restriction and all field restrictions, it is assumed to match. This $ais a binding variable that allows us to refer to the matching object. The dollar sign $is optional, but it helps distinguish variable names from field names.

Related systems

Web links

Individual evidence

  1. Product overview
  2. JBoss Enterprise BRMS Component Details on May 13, 2017.
  3. - Drool's website
  4. Drools - Drools - Business Rules Management System (Java ™, Open Source). Retrieved May 13, 2017 (English).
  5. Rainer Endl: Rule-based development of business information systems: Design of flexible information systems through explicit modeling of business logic . BoD - Books on Demand, 2004, ISBN 978-3-89936-263-3 ( google.de [accessed on May 13, 2017]).
  6. Drools Documentation. Retrieved May 15, 2017 .
  7. Chapter 6. User Guide - The Basics