<br>&nbsp;&nbsp; Well, we can&#39;t let the the exception escape the consequence block, since it would invalidate the working memory. <br>&nbsp;&nbsp; So, we have 2 options I think:<br><br>* If we make the validation framework enforce valid values, we need it to raise an exception that is catch by a transparent consequence catch block and is handled the same way we already handle them, but stopping rule firing.
<br><br>* If we make the validation framework just warn about invalid values, we can create a warning mechanism so that users can handle such warnings, but let the value to be set and continue running the engine as if no problem was found.
<br><br>&nbsp;&nbsp; I don&#39;t see many other options on that... I still prefer first option.<br><br>&nbsp;&nbsp; My 0.02c.<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2008/1/8, Mark Proctor &lt;<a href="mailto:mproctor@codehaus.org">
mproctor@codehaus.org</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;">Michael Neale wrote:<br>&gt; I don&#39;t like the catch block idea at all. We have a rule language not
<br>&gt; a programming language.<br>How do we deal with invalid sets? Without a catch block, ther &quot;then&quot;<br>scoped or &quot;modify&quot; scoped, we have only two choices - always throw an<br>exception, do nothing and just expose a validator variable. Considering
<br>we don&#39;t want to add &#39;if&#39; statements into the consequence how would the<br>user then handle processing the validator variable?<br>&gt;<br>&gt;<br>&gt; Sent from my iPhone<br>&gt;<br>&gt; On 08/01/2008, at 6:49, Mark Proctor &lt;
<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:<br>&gt;<br>&gt;&gt; I&#39;m thinking about an ontology constraint system, based around field<br>&gt;&gt; setter validation. However I cannot decide how to handle invalid
<br>&gt;&gt; changes in a consequence or in external java code. I&#39;ll may leverage<br>&gt;&gt; the JSR 303 - Bean Validation - <a href="http://jcp.org/en/jsr/detail?id=303">http://jcp.org/en/jsr/detail?id=303</a>.<br>&gt;&gt;
<br>&gt;&gt; Although I have several concerns with the spec, one is that it always<br>&gt;&gt; validates objects and passes in the field as an object - with<br>&gt;&gt; primitive intensive stuff that can add an overhead, due to auto
<br>&gt;&gt; boxing. I&#39;m more tempted to pass in the main Object itself and users<br>&gt;&gt; can then use the FieldExtractor to read the field as they require,<br>&gt;&gt; either as an Object or a primitive with full co-ercion - the
<br>&gt;&gt; FieldExtractor would be injected. Further to that I can&#39;t see how you<br>&gt;&gt; would make the validator session aware, and doing it via constructor<br>&gt;&gt; injection would mean a validator per session which is not desirable.
<br>&gt;&gt; I spoke to the spec lead and he mentioned using LocalThread<br>&gt;&gt; variables. However we can have multiple sessions in the same thread,<br>&gt;&gt; just not executing at the same time, which means the current
<br>&gt;&gt; executing session would need to set itself on that localthread<br>&gt;&gt; variable - basically context switching, which I don&#39;t like.<br>&gt;&gt;<br>&gt;&gt; We should have a variable that lists the validator errors for the
<br>&gt;&gt; current working memory action phase, for user interrogation - much<br>&gt;&gt; like Hibernate Validator (RI for JSR 303) allows you to list<br>&gt;&gt; validation errors on a insert or update on a session.<br>
&gt;&gt;<br>&gt;&gt; But in rule engines we have other considerations:<br>&gt;&gt; The first fundamental question is do we allow invalid changes or do<br>&gt;&gt; we always roll them back? My prefernce, much like a database, is the
<br>&gt;&gt; data model as seen by the engine is always valid.<br>&gt;&gt;<br>&gt;&gt; Now if we assume the invalid change must be rolled bank or not<br>&gt;&gt; applied how do we expose this to the user:<br>&gt;&gt; -Throw an exception, up to them if they catch and it will exit the
<br>&gt;&gt; engine if not caught.<br>&gt;&gt; -Do nothing, roll back the change and continue executing the<br>&gt;&gt; consequence as normal, they can check the validator variable if they<br>&gt;&gt; need to.<br>&gt;&gt; Allow for &quot;catch&quot; like blocks either after each modify block, or
<br>&gt;&gt; after the &quot;then&quot; block. Do we have one large catch block, or do we<br>&gt;&gt; have some sort of type matching....<br>&gt;&gt;<br>&gt;&gt; Currently my preference is for a &quot;catch&quot; block after the &quot;then&quot;
<br>&gt;&gt; block. I&#39;m tempted to just have one large catch block and users can<br>&gt;&gt; do an iteration of the validator variable doing &quot;if&quot; checks; we can<br>&gt;&gt; always add in type matching later. The catch block can either resume
<br>&gt;&gt; or throw an exception; on resumption it will attempt to validate the<br>&gt;&gt; bean again, if it&#39;s changed, if it&#39;s still invalid the process repeats.<br>&gt;&gt;<br>&gt;&gt; Mark<br>&gt;&gt; _______________________________________________
<br>&gt;&gt; rules-dev mailing list<br>&gt;&gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev
</a><br>&gt; _______________________________________________<br>&gt; rules-dev mailing list<br>&gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@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>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></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<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>