<br>&nbsp;&nbsp; Michael,<br><br>&nbsp;&nbsp; Yes, the session.insertEvent() API is something other engines (like iLog JRules) have. I initially discarded that idea, but since you mentioned, we may need to reconsider it.<br>&nbsp;&nbsp; Anyway, the API would solve this part of the problem, but the whole scenario is:
<br>&nbsp;&nbsp; The engine must know at the compile time exactly what classes/interfaces used in rules are events, so that it can optimize the network. That is achievable by using any of the syntaxes bellow (I&#39;m not sure which one to use yet):
<br><br>import event a.b.c.Foo; (or)<br>import event a.b.c.*;<br><br>or explicit saying:<br><br>declare event a.b.c.Foo;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; Once the user declared that something is an event, do you think it is fair/acceptable to force the user to use a different API to insert events into the engine?
<br><br>session.insert(); for regular facts<br>session.insertEvent(); for events<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/11/8, Anstis, Michael (M.) &lt;<a href="mailto:manstis1@ford.com">manstis1@ford.com
</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Here&#39;s my 2 cents - as a non-contributor to Drools codebase ;-)<br><br>You could add insertEventFactTypeThingie to the API? Then you need just
<br>check that the class has been declared as an event in the DRL similar to<br>what must already happen for normal DRL imports. I personally don&#39;t have<br>issue with implementing a marker interface (this is what frameworks like
<br>Hibernate, EJB3 and Spring etc have been imposing for years). What &quot;wiring&quot;<br>does the POJO need to become an Event for use in Drools? Are you trying to<br>internalise too much at the risk of making the event mechanism inflexible?
<br><br>Cheers,<br><br>Mike<br><br>-----Original Message-----<br>From: <a href="mailto:rules-dev-bounces@lists.jboss.org">rules-dev-bounces@lists.jboss.org</a><br>[mailto:<a href="mailto:rules-dev-bounces@lists.jboss.org">
rules-dev-bounces@lists.jboss.org</a>] On Behalf Of Matthias<br>Sent: 08 November 2007 13:09<br>To: <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>Subject: Re: [rules-dev] Determining if a class is an event or not
<br><br>Edson Tirelli &lt;tirelli &lt;at&gt; <a href="http://post.com">post.com</a>&gt; writes:<br><br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;All,&nbsp;&nbsp; I reached a point where I need to make a design decision and<br>would<br>like your opinion about it.&nbsp;&nbsp; Imagine the following scenario:&nbsp;&nbsp; A user has a
<br>domain model like this:package a.b.c<br>&gt; ;public interface Event { ... }package x.y.z;public class MyEvent<br>implements<br>a.b.c.Event {...}&nbsp;&nbsp; Then, in his DRL file he writes:package p.q.r;import<br>event<br>a.b.c.*
;&nbsp;&nbsp;&nbsp;&nbsp;rule Xwhen<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Event( ... )then&nbsp;&nbsp;&nbsp;&nbsp;...end&nbsp;&nbsp; So, it is clear that a.b.c.Event should<br>be<br>handled as an event by the engine.&nbsp;&nbsp; At runtime, the user asserts an object<br>of<br>the class x.y.z.MyEvent into the working memory. Seems clear to me (and
<br>probably<br>to the user) that MyEvent should be handled as an event, since by DRL<br>semantics,<br>&gt; a.b.c.* are all events, and by OO class hierarchy concept, since<br>a.b.c.Event<br>is an event, x.y.z.MyEvent is an event too.&nbsp;&nbsp; My question is: how the engine
<br>knows that MyEvent is an event, since it only has the x.y.z.MyEvent<br>&gt;&nbsp;&nbsp;class as input?&nbsp;&nbsp; The only answer I have is that when the first MyEvent<br>instance is asserted into the working memory, we must get the class name and
<br>iterate over all event import declarations checking for a match. In case no<br>one<br>is found, we need to repeat the process for each interface and each class up<br>in<br>the MyEvent hierarchy. Once this process is complete, we cache the results
<br>in<br>the ObjectTypeConf.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;This may be a quite heavy process to be executed each time a fact of a<br>different class is asserted in the working memory for the first time, but I<br>can&#39;t think a different user-friendly way to solve the question.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;The alternatives would be intrusive, IMO, breaking the drools premise<br>to<br>work with user-defined POJOs as facts: use anotations to annotate classes<br>that<br>are events, or mandate users implement a specific interface for events.
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Any better idea?&nbsp;&nbsp;&nbsp;&nbsp;[]s&nbsp;&nbsp;&nbsp;&nbsp;Edson&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp; Edson Tirelli&nbsp;&nbsp;Software<br>Engineer<br>- JBoss Rules Core Developer&nbsp;&nbsp;Office: +55 11 3529-6000&nbsp;&nbsp;Mobile: +55 11<br>9287-5646<br>&gt;&nbsp;&nbsp; JBoss, a division of Red Hat&nbsp;&nbsp;&lt;at&gt;&nbsp;&nbsp;
<a href="http://www.jboss.com">www.jboss.com</a><br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-dev mailing list<br>&gt; rules-dev &lt;at&gt; <a href="http://lists.jboss.org">lists.jboss.org
</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>&gt;<br><br><br>Edson,<br><br>I got your striving not to mandate users implement a specific interface for
<br>events. However, why not at least introducing an empty event interface (i.e.<br>a<br>marker interface, similar to the Serializable interface in Java) the<br>user-defined event class(es) have to implement? This way, when inserting a
<br>MyEvent instance, you can simply check whether it implements the event<br>interface<br>(by means of &#39;instanceof&#39;). Moreover, while parsing the import statements of<br>a<br>rule file, it enables you to double-check whether all the &quot;event imports&quot;
<br>really<br>refer to classes implementing the (empty) event interface.<br>In this regard, for me another question raises: Without making any<br>restrictions<br>on the structure for a user defined event class, how do you make sure it has
<br>all<br>the&nbsp;&nbsp;required attributes of an event (which in my opinion must be a<br>timestamp,<br>at least) and how do you access them (necessary for temporal relationships)?<br>Having said this, in my opinion defining an empty event interface may not be
<br>sufficient; in addition, it must force the user to implement a method<br>returning<br>the event&#39;s occurrence date (i.e. the timestamp) at least... Or how would<br>you<br>handle this issue?<br><br>Matthias<br><br>_______________________________________________
<br>rules-dev mailing list<br><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
<br><br>_______________________________________________<br>rules-dev mailing list<br><a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-dev">
https://lists.jboss.org/mailman/listinfo/rules-dev</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>