We use drools for validation rules in our application. Some of these rules are dependent on which CRUD operation is being performed at the time, so as part of our validation aspect we insert a CrudMode enum with the current action (by annotating the advised method). e.g.

@Validate(validators = BusinessRulesValidator.class, mode = CREATE)
public void create(@DTO SomeDTO incomingDto)

In our rules we can then go:

CrudMode(this == CrudMode.CREATE)

The second way we use it (and this one I don't like so much) is that our validation aspect runs both before and after a method (PRE and POST). We use an agenda-group to to indicate which phase a rule should be included which works fine, however we were finding that some conditions were relatively expensive which had performance implications. Our solution was to also include a ValidationPhase enum as a fact and use that to short-circuit the rules. I reckon there is probably a better way to achieve this however we didn't spend a lot of time thinking about it.

cheers
Steve  

-------------------------------------------------------------------
Steven Williams



On Thu, Nov 14, 2013 at 12:40 AM, Wolfgang Laun <wolfgang.laun@gmail.com> wrote:
Just curiosity.

On 13/11/2013, Steven Williams <stevearoonie@gmail.com> wrote:
> I use something like the following in rules to good effect:
>
> Country( this == Country.USA )

Granted, you can add any number of attributes to an enum so that it's
just another way of writing a static set of bean objects. But is there
a "good effect" to be had from a pattern that merely ascertains the
presence of an enum instance
in the Working Memory?

Other than this, a pattern like
   City( country == Country.USA )
doesn't require the insertion of the Country enums.

Cheers
Wolfgang
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users