このコンテンツは選択した言語では利用できません。

3.5. Constraints


You can use constraints in a multitude of locations in your rule flow. You can, for example use them in a Split node using OR or XOR decisions, or as a constraint for a State node. The Rules Flow Engine supports two types of constraints:
  • Code constraints are Boolean expressions, evaluated directly immediately upon arrival. You can write them in either of these two dialects: Java and MVEL. Both have direct access to the globals and variables defined in the process.
    Here is an example of a constraint written in Java, person being a variable in the process:
    return person.getAge() > 20;
    Copy to Clipboard Toggle word wrap
    Here is the same constraint written in MVEL:
    return person.age > 20;
    Copy to Clipboard Toggle word wrap
  • Rule constraints are the same as normal JBoss Rules conditions. They use the JBoss Rules Rule Language's syntax to express what are potentially very complex constraints. These rules can, (like any other rule), refer to data in the working memory. You can also refer to globals directly.
    Here is an example of a valid rule constraint:
    Person( age > 20 )
    Copy to Clipboard Toggle word wrap
    This searches the working memory for people older than twenty.
Rule constraints do not have direct access to variables that have been defined inside the rule flow. You can, however, possible to refer to the current process instance inside a rule constraint, by adding the process instance to the working memory and matching it to the process instance in your rule constraint.
Red Hat has added special logic to make sure that a processInstance variable of the type WorkflowProcessInstance will only match the current process instance and not to other process instances in the working memory. You, however, are responsible for inserting the process instance into the session and, updating it, using, for example, either Java code or an on-entry or on-exit or explicit process action.
The following example of a rule constraint will search for a person with the same name as the value stored in the process variable name:
processInstance : WorkflowProcessInstance()
Person( name == ( processInstance.getVariable("name") ) )
# add more constraints here ...
Copy to Clipboard Toggle word wrap
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat