Este conteúdo não está disponível no idioma selecionado.
3.2. JBoss Rules Theory
3.2.1. Methods in JBoss Rules Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
Methods are different to rules. They are called directly and are used to pass specific instances. A single call results in a single execution.
3.2.2. Method Example Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
A method looks like this:
3.2.3. Rule Example Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
A rule looks like this:
3.2.4. Cross-Products Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
When two or more sets of data are combined, the result is called a cross-product.
3.2.5. Cross-Product Constraining Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
Procedure 3.6. Task
- To prevent a rule from outputting a huge amount of cross-products, you should constrain the cross-products themselves. Do this using the variable constraint seen below:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following output will be displayed:room:office sprinkler:office room:kitchen sprinkler:kitchen room:livingroom sprinkler:livingroom room:bedroom sprinkler:bedroom
room:office sprinkler:office room:kitchen sprinkler:kitchen room:livingroom sprinkler:livingroom room:bedroom sprinkler:bedroom
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Result
Only four rows are outputted with the correct sprinkler for each room. Without this variable, every row in the Room table would have been joined with every row in the Sprinkler table resulting in many lines of output.
3.2.6. The Inference Engine Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The inference engine is the part of the JBoss Rules engine which matches production facts and data to rules. It will then perform actions based on what it infers from the information. A production rules system's inference engine is stateful and is responsible for truth maintenance.
3.2.7. Inference Example Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
In this example, a Person fact with an age field and a rule that provides age policy control is used. Inference is used to determine if a Person is an adult or a minor, then act on the result:
In the above snippet, every Person who is 18 or over will have an instance of IsAdult inserted for them. This fact is special in that it is known as a relation. We can use this inferred relation in any rule:
$p : Person() IsAdult( person == $p )
$p : Person()
IsAdult( person == $p )