JBoss Rules Improves its Syntax
We are waiting for the next stable version of JBoss Rules (v.4.0), which promises to offer a full access to all features already implemented in JBoss Rules 4.0 Milestone Release 2. These features convert JBoss Rules platform/rule engine into a reasonable, open-source alternative to other commercial products from the business market.
Use of && and || inside of the columns
It simplifies the syntax by allowing the construction of some filter expressions that previously were done
using predicate expressions or eval structures i.e.
$driver:Diver(age >= 16 && < 25 && location != "CA" || != "NY" )
Implicit binding for predicate and return value expressions
$driver:Driver(premium -> (numberOfAccidents * 150)) $driver:Driver(premium == (numberOfAccidents * 150))
There is no need to obtain first a variable for the attribute numberOfAccidents, in order to use it in a return value expression, like in example above. The expression is build using the directly the numberOfAccidents attribute.
Direct access to the properties of the patterns
$carModel:CarModel() $car:Car(carBasePremium == $carModel.basePremium)
basePremium is a property of the
Nesting of conditional elements inside first-order logic quantifiers and negation
Existentially quantified expressions e.g.
exists Car(price >= 20000 && <= 45000 )
semantically maps to the existentially quantified formula:
∃x (Car(x)∧ price(x) >= 20000 ∧ price(x) <=45000)
Universally quantified expressions e.g.
forall Car(price == 45000) corresponds to the universally quantified formula:
∀x (Car(x)∧ price(x) == 45000)
not Car(price >= 45000) is semanticaly the same as the following logical formula:
∀x ¬(Car(x)∧ price(x) >= 45000)
Use of this keyword, as a property for constraining a fact.
$car:Car($carModel:carModel) CarModel(this == $carModel)
Support of MVEL dialect
We can specify the MVEL dialect by using the new rule attribute dialect.
// The Java dialect rule "Young_Driver" when $car:Car($carModel:carModel , price <= 45000, isConvertible == false) $carModel:CarModel(hasHighTheftProbability == false, modelType == "compact") then $carModel.setBasePremium(250); modify($carModel); end // The MVEL dialect rule "Young_Driver" dialect "mvel" when $car:Car(price <= 45000, isConvertible == false) $carModel:CarModel(hasHighTheftProbability == false, modelType == "compact") from $car.carModel then $carModel.basePremium = 250; modify($carModel); end
MVEL is an expression language based on Java syntax, but having its own specific features.
- MVEL uses the
fromkeyword to bound
$carModelobject variable to the
DRL syntax obtains the same result by using a bound variable expression (e.g.
carModel == $carModel).
- Like in UML MVEL allows direct referencing to object properties i.e. a path expression such as
corresponds to Java setter/getter depending of the context of usage. For example
$bp = $carModel.basePremium;corresponds
to the standard getter call
$bp = $carModel.getBasePremium();but
$carModel.basePremium = 250;maps into