[rules-users] What should I insert into the working memory?

Swindells, Thomas TSwindells at nds.com
Sun Nov 28 08:47:17 EST 2010


Are you just performing validation or are you modifying the data as well?
If it is purely validation then I believe you can get away purely with inserting the root element - it's not at all efficient if you update any of the data (pretty much every rule would have to refire) but if you aren't updating the data then that doesn't matter - against that it may result in neater rules if you do put all the objects in the memory.

Thomas

> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org [mailto:rules-users-
> bounces at lists.jboss.org] On Behalf Of Chris Selwyn
> Sent: 28 November 2010 11:39
> To: Drools users
> Subject: [rules-users] What should I insert into the working memory?
>
> I am working on a project that is using Drools to perform validation of
> hierarchical XML messages.
>
> So I have passed the XSDs through JAXB and have a set of interrelated
> Java objects.
> One of these objects (naturally) represents the root of the messages and
> the others represent the intermediate and leaf nodes of the message.
>
> My question is: Should I traverse the tree and insert each object into
> the working memory or should I just insert the root object into the
> working memory?
>
> If I insert each object into the memory then I have a lot of flexibility
> about how I write my rules... I can start by focussing on the particular
> part of the message that I want to detect an error in.
> However, I then have to perform a whole bunch of "joining" clauses to
> correctly "connect up" to the other objects in the working memory.
> (This is how I am doing it at the moment... I have a mechanism that uses
> the Java Introspector. It identifies by package name which parts of the
> data model get inserted into the WM)
>
> On the other hand, I could just insert the root object into the WM. This
> means that I would have to write really complicated where clauses on the
> root object but very much simplifies the WM loading process.
>
> All of the examples that I have seen have a very simple flat
> (non-hierarchical) structure that don't really give a hint as to what a
> "best practice" might be.
>
> Any suggestions/insights welcome :-)
>
> Chris Selwyn
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************




More information about the rules-users mailing list