<div dir="ltr"><br>&nbsp;&nbsp; Hi Michael,<br><br>&nbsp;&nbsp; I was not able to reproduce the problem in JIRA-1766. If you still see the issue, can you please re-open the issue attaching a test case or modifying the test case I added for that issue?<br>
<br>&nbsp;&nbsp; Regarding your questions:<br><br>1) I think you already got it, but look, for instance at the MatchesEvaluatorsDefinition. It will give you a simple example on how to proceed. The idea behind that is that we need the Operators to be readily available from a registry, so that the parser can easily find them. That is why I used a static cache approach, where as soon as a EvaluatorsDefinition class is loaded, it will make a call to the static cache publishing its operators.<br>
<br>2) The multiplicity of classes is inherited from how operators were implemented in 4.0.x.You obviously don&#39;t need to do that. As single class can implement multiple operators ****as long as the class is stateless****. This is the only requirement, really: being stateless (kind of using the fly weight pattern). For an example, look at the file SetEvaluatorsDefinition and look at the BaseMemberOf inner class. So, all the logic is in there, but we still used subclasses just to set the constructor attributes and override the toString() method, but you could still implement everything in a single class I guess. <br>
&nbsp;&nbsp; Also, please remember that accessors and operators are the single most stressed piece of codes in the engine, so, if you need performance, make sure your operator is as much streamlined as possible.<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br>
<br><br><br><div class="gmail_quote">2008/9/15 Michael Zimmermann <span dir="ltr">&lt;<a href="mailto:list@incunabulum.de">list@incunabulum.de</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Edson,<br>
<br>
just spend some hours compiling the most recent drools version from svn<br>
trunk and migrating my application to this version. So far, most of the<br>
features work except<br>
- of one issue with BaseIntClassFieldReader, see JIRA ticket 1766.<br>
- and an incorrect import in SendIcal.java leading to a broken maven<br>
 &nbsp;build proces, see JIRA ticket 1767.<br>
<div class="Ih2E3d"><br>
Edson Tirelli wrote:<br>
&gt; &nbsp; &nbsp;It has an interface you can implement to add operators and the parser<br>
&gt; accepts a quote for custom operators. It is not yet the way I want it to<br>
&gt; be for Drools 5 final, but it works already.<br>
&gt;<br>
&gt; &nbsp; &nbsp;For more info, look at the EvaluatorDefinition interface in Drools 5<br>
&gt; and its several implementations for examples.<br>
<br>
</div>Having looked at the EvaluatorDefinition the implementation of custom<br>
operators seem to be straightforward now. Nice Work!<br>
<br>
1) One question though: In drools-core each subclass of BaseEvaluator<br>
calls &nbsp;the parent class as follows<br>
<br>
 &nbsp;public MyEvaluator()<br>
 &nbsp; &nbsp;super(ValueType.SOME_TYPE, Operator.MY_OPERATOR);<br>
<br>
with the operators created using the private (!) constructor<br>
Operator(id, negated) via some static variable in Operator.java.<br>
<br>
So, well, how do I hook up a custom operator to e. g. a drools package?<br>
There is a PackageBuilderConfiguration.addEvaluatorDefinition() method,<br>
yet currently the only way to define the operator symbol (&quot;==&quot; etc) is<br>
via a separate call to Operator.addOperatorToRegistry() first and using<br>
the return Operator instance to create my EvaluatorDefinition. Or do I<br>
get something wrong?<br>
<br>
2) Also, I am wondering about the large number of nearly identical<br>
internal classes required for each operator.Is there a specific reason<br>
why such an operator has to be defined for each possible object type<br>
separately?<br>
Is this due to the way the InternalReadAccessor is called to map to the<br>
current datatype in an operator call? And why not just call<br>
<br>
cu, Michael<br>
<br>
PS: Some details about my project come once I find a bit of time to<br>
write them down coherently :-)<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>