The domain in this sense represents the business area (for example, life insurance or billing). Rules are expressed with the terminology of the problem domain. This means that domain experts can understand, validate, and modify these rules more easily.
You can think of the DSL as a translator. It defines how to translate sentences from the problem-specific terminology into rules. The translation process is defined in a .dsl
file. The sentences themselves are stored in a .dslr
file. The result of this process must be a valid .drl
file.
Building a simple DSL might look like this:
[condition][]There is a Customer with firstName {name}=$customer : Customer(firstName == {name}) [consequence][]Greet Customer=System.out.println("Hello " + $customer.getFirstName());
Code listing 1: Simple DSL file simple.dsl