<br> All,<br><br> I reached a point where I need to make a design decision and would like your opinion about it.<br> Imagine the following scenario:<br><br> A user has a domain model like this:<br><br>package a.b.c
;<br>public interface Event { ... }<br><br>package x.y.z;<br>public class MyEvent implements a.b.c.Event {...}<br><br> Then, in his DRL file he writes:<br><br>package p.q.r;<br>import event a.b.c.*; <br>rule X<br>when
<br> Event( ... )<br>then<br> ...<br>end<br><br clear="all"> So, it is clear that a.b.c.Event should be handled as an event by the engine.<br> At runtime, the user asserts an object of the class x.y.z.MyEvent into the working memory. Seems clear to me (and probably to the user) that MyEvent should be handled as an event, since by DRL semantics,
a.b.c.* are all events, and by OO class hierarchy concept, since a.b.c.Event is an event, x.y.z.MyEvent is an event too.<br><br> My question is: how the engine knows that MyEvent is an event, since it only has the x.y.z.MyEvent
class as input?<br> The only answer I have is that when the first MyEvent instance is asserted into the working memory, we must get the class name and iterate over all event import declarations checking for a match. In case no one is found, we need to repeat the process for each interface and each class up in the MyEvent hierarchy. Once this process is complete, we cache the results in the ObjectTypeConf.
<br> This may be a quite heavy process to be executed each time a fact of a different class is asserted in the working memory for the first time, but I can't think a different user-friendly way to solve the question.
<br><br> The alternatives would be intrusive, IMO, breaking the drools premise to work with user-defined POJOs as facts: use anotations to annotate classes that are events, or mandate users implement a specific interface for events.
<br><br> Any better idea?<br><br> []s<br> Edson<br><br><br><br> <br><br><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>