You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Die Rule-Engine stellt die Basis-Technologien für die regelbasierte Verarbeitung einiger Komponenten bereit.
Diese wird unter anderem von der Rewrite-Komponente und der Transformations-Komponente verwendet.

Components and semantics

The Rule-Engine has several components

Working Memory

The working memory exists of all objects that have to be processed by rules. For the transformation, for example, the working memory consists of all logical operators that should be transformed by rules into their physical counterpart.

To interact with the working memory in a rule, there are the following methods:

  • insert: adds a new object to the working memory.
  • retract: removes an object from the working memory
  • update: informs the working that an object has been changed
  • updateAll: runs update for a collection of objects
  • getCollection: Returns a list of all objects that are currently in the working memory
  • getAllOfSameTyp(K k): This method returns all objects that have the same type like the given object k. For example, getAllOfSameTyp(new SelectAO()) can be used to return all SelectAOs that are currently part of the working memory

Important is the retract method. If an object is never removed from the working memory by using retract, although there are rules, it may be possible to get into an infinity loop!

 

Inventory

The inventory consits of all necessary objects for the current rule engine instance. This is, normally, the set of all rules and the RuleFlowGroups (see below).

Each time when the rule engine is invoked, the rule engine creates a copy of the inventory. This is needed so that rules can not be changed if they are in use. Furthermore, it allows nested runs of the rule engine, e.g. to run a transformation within another transformation without influecing each other.

The rule engine consists of a two-stage hierarchy: First, there is a list of RuleFlowGroups and, secondly, each RuleFlowGroup has a set of Rules.

RuleFlowGroup

Die Rule-Engine ermöglicht es Gruppen zu definieren, die als RuleFlowGroup bezeichnet werden. Jede Regel wird einer dieser Gruppen zugeordnet.
Die Engine führt dann jede Gruppe hintereinander aus. Aus diesem Grund gibt es eine feste Ordnung aller Gruppe. Dabei darf jedoch eine Gruppe mehrmals innerhalb dieser Liste vorkommen.

Bei der Ausführung einer RuleFlowGroup wird jede Regel innerhalb einer Gruppe getestet, ob sie ausgeführt werden kann. Dabei gibt es folgende zwei Möglichkeiten:

  • Wenn keine ausgeführt werden konnte, dann ist die RuleFlowGroup beendet und die nächste RuleFlowGroup wird gestartet.
  • Wurde eine Regel innerhalb einer RuleFlowGroup ausgeführt, wird der aktuelle Durchgang der RuleFlowGroup abgebrochen und die gesamte RuleFlowGroup von vorne wiederholt. Das heißt, dass auch Regeln erneut geprüft werden, die ggf. vorher noch nicht ausführbar waren.

Rules

Jede Regel ist einer RuleFlowGroup zugeordnet.
Bei einem Durchlauf der RuleFlowGroup wird folgendes für jede Regel in der RuleFlowGroup gemacht:

  • zunächst geprüft, ob der generische Typ der Regel einem Objekt im Working Memory entspricht.
  • Entspricht ein Objekt dem generischen Typ
    • Nein: Prüfe das nächste Objekt im Working Memory
    • Ja: führe die Methode isExecutable der Regel mit dem Objekt aus
  • Ist isExecutable nicht gegeben, dann breche ab und prüfe das nächste Objekt aus dem Working Memory
  • Ist isExecutable wahr, dann rufe execute aus
  • Wie oben beschrieben wird danach die RuleFlowGroup neugestartet.

 

  • No labels