JBoss Rules Summary

Source: Internet
Author: User
Tags jboss jboss application server

Learning JBoss rules for a few days, I translated some of the important things I've seen, hoping to provide a little help to the students who want to learn about JBoss rules.

1. Introduction to JBoss Rules

JBoss Rules (Drools) has an easy-to-access enterprise policy, easy-to-adjust, and easy-to-manage open source business rules engine that meets industry standards for speed and efficiency. Business analysts or auditors can use it to easily review business rules to verify that the code rules are executing the required business rules.
The predecessor of JBoss Rules is Codehaus, an open source project called Drools. Recently incorporated into JBoss, it was renamed JBoss rules and became the rule engine for JBoss application server.
Drools is the implementation of the rule engine based on the Charles Forgy Rete algorithm, which is tailored for Java. With the Oo interface Rete, the business rules have a more natural expression.

Now that JBoss rules is a business rule engine, we need to know what rules are, that's the rule, first. In JBoss rules, how the rule is represented

1.1 rule file

A rule file is usually a file that ends with a. drl extension. In a DRL file, you can have multiple rules, functions, and so on. However, you can also distribute your rules across multiple files, which facilitates the management of a large number of rules. A DRL file is a simple text file.

Structure of the 1.2 rule

A rule structure is roughly as follows:

Rule "Name"
ATTRIBUTES
When
LHS
Then
RHS
End

As you can see, this is very simple. The usual punctuation is unnecessary, and even the double quotes of "name" are not required. Attributes is a simple and optional way to prompt the behavior of the rule. LHS is the conditional part of the rule and needs to be written according to certain syntax. RHS is basically a block of code that allows Java syntax to be executed (groovy and C # will be supported in the future). Any variables that are used in LHS can be used in RHS.

Note: The space at the beginning of each line is not important unless specifically specified in the DSL (domainspecific Language) language.

2. What is a rule engine then?

The rule engine, developed by the inference engine, is a component embedded in an application that separates business decisions from application code and writes business decisions using predefined semantic modules. Accept data entry, interpret business rules, and make business decisions based on business rules.

3. Benefits of using the rule engine

Declarative Programming : The Rules engine allows you to describe what to do rather than how to do it

Separation of logic from data: Data is stored in system objects and logically stored in rules. This fundamentally breaks the situation where data and logic are coupled in an object-oriented system

Speed and Scalability: The Rete algorithm, the leaps algorithm, and the derived drools Rete and leaps algorithms provide a very efficient match to the system data objects.

Knowledge Centralization: By using rules, an executable rule base is created. This means that the rules library represents the only correspondence of a real business strategy, and ideally readable rules can be used as documents

Tool Integration: Tools such as Eclipse, which may be on a web-based interface in the future, provide a way to modify and manage rules, get instant feedback, and content validation and patching. The review and debugging tools are also available

EXPLANATION mechanism: By documenting the decisions and decisions of the rule engine, the rules system provides a good "interpretation mechanism"

Easy-to-understand rules: By creating an object model and a DSL (domain definition language), you can write rules in a way that is close to natural language. This allows non-technical and domain experts to use their own logic to understand the rules (because the maze of programs has been hidden)

4, suitable for the use of the Rule engine system occasions

Using traditional code development is more complex and cumbersome

Although the problem is not complex, it is fragile with traditional code development, which is often modified

No elegant algorithms.

Business rules change frequently

There are many business experts, do not understand the technical development

5, not suitable for the use of the Rule engine system occasions

Although the rules system looks good, it is not possible to use the rules system anywhere. Many simple, fixed business systems can be used without a rule system. The rule system also cannot be used as an indicator of important business processes and cannot be used as a workflow engine.

There are many programmers who consider the rule system as a dynamic modification configuration. That is, a part of the code logic is extracted outside, unified storage. Thus, when some configuration changes, by modifying the rules, you can modify part of the logic of the code. If you use the rules only for this occasion, consider using a scripting engine. such as BeanShell, JEXL, groovy and so on.

JBoss Rules Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.