Hi Edson,
Many thanks for you answer!
It is surprising that, on one hand, the
"drools.default.packagebuilder.conf" file contains... :
drools.evaluator.soundslike =
org.drools.base.evaluators.SoundslikeEvaluatorsDefinition
... and on the other hand, EvaluatorRegistry.java contains:
this.addEvaluatorDefinition( new SoundslikeEvaluatorsDefinition() );
and the source code for the Soundslike operator contains:
public static final Operator SOUNDSLIKE =
Operator.addOperatorToRegistry( "soundslike", false );
All of this, at first sight, let me puzzled on how to really plug a
custom operator. I'll give a try with the property file!
Any intuition ;-) of how difficult it might be to modify (besides
SuggestionCompletionEngine and HumanReadable) the business rule editor
Eclipse plugin for a "gentle" integration of the operator?
Best regards,
Bruno.
Edson Tirelli a écrit :
The instantiation is done automatically, based on configuration
or
API call. More details in here:
http://blog.athico.com/2010/06/creating-pluggable-oprators.html
But basically, for eclipse to pick it up, best to add to a
configuration file:
drools.evaluator.MyIdentifierForMyOperators = my.pkg.MyEvaluatorDefinition
Please note that all drools operators are implemented like that
and wired through configuration file as seen here:
https://svn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/sr...
So, adding your own custom operators is no different. Just define
your own configuration file in the META-INF directory of your
application package and it will work.
Edson
2010/10/25 Swindells, Thomas <TSwindells(a)nds.com>:
> For that to work the class also needs to be instantiated - ie it would only get
created once something in eclipse has touched the class.
>
> Thomas
>
>
>> -----Original Message-----
>> From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
>> bounces(a)lists.jboss.org] On Behalf Of Edson Tirelli
>> Sent: 25 October 2010 14:58
>> To: Rules Users List
>> Subject: Re: [rules-users] Custom operator
>>
>> If you look at the implementation of one of the existing operators
>> (e.g. MatchesEvaluatorDefinition) you will see this in the beginning
>> of the class:
>>
>> public static final Operator MATCHES =
>> Operator.addOperatorToRegistry( "matches", false );
>>
>> Do the same on your own implementations and it should be fine.
>>
>> Edson
>>
>>
>>
>> 2010/10/25 Bruno Freudensprung <bruno.freudensprung(a)temis.com>:
>>
>>> Hello,
>>>
>>> It seems that the logic behind the "operator" drop-down list comes
from
>>> the
>>>
"org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine"
>>> and "org.drools.eclipse.rulebuilder.modeldriven.HumanReadable"
classes.
>>> That's for the "rule authoring" perspective.
>>> I've also seen that the business rule editor involves the DrlParser
>>> class. So, in a "rule parsing" perspective, I guess I need to find
a way
>>> to register my custom operator into the EvaluatorRegistry used by the
>>> Eclipse plugin (and I don't know where this can be done).
>>>
>>> Do you think I am on the right track? Is there a risk that code
>>> modifications will involve so many classes that, in the end, adding a
>>> custom operator to the business rule editor will be a difficult task for
>>> someone very new to Drools (like me)?
>>>
>>> Thanks in advance,
>>> Best regards,
>>>
>>> Bruno.
>>>
>>> Bruno Freudensprung a écrit :
>>>
>>>> Hello,
>>>>
>>>> I'd like to implement a custom "lucenematches" operator
that would
>>>> enable writing conditions like:
>>>> $d : Doc(text lucenematches "(foo AND bar) OR roam~0.8")
>>>>
>>>> As I've taken a look at the following post on athico
>>>> (
http://blog.athico.com/2009/05/imperfect-evaluations.html), and seen
>>>> that the appendix B of the "Drools JBoss Rules 5.0 Developer's
Guide"
>>>> book that deals with custom operators, I am rather confident that I will
>>>> find my way in implementing my operator (if not, I'll post here again
:-)).
>>>>
>>>> However, I wonder if it will be possible to add my
"lucenematches"
>>>> operator to the "operator" drop-down list of the Eclipse's
Business Rule
>>>> Editor.
>>>> Does anyone have an idea?
>>>>
>>>> Best regards,
>>>>
>>>> Bruno.
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> --
>> Edson Tirelli
>> JBoss Drools Core Development
>> JBoss by Red Hat @
www.jboss.com
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)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(a)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
>
**************************************************************************************
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>