[rules-users] Benefits of pluggable operators

Thomas Grayson tgrayson at bluemetal.com
Fri May 24 10:54:44 EDT 2013


What are the benefits of using pluggable operators (implementations of org.drools.base.evaluators.EvaluatorDefinition such str, matches, or before) versus simply making an equivalent function call?  I've read the Creating pluggable operators<http://blog.athico.com/2010/06/creating-pluggable-oprators.html> blog post.  Apart from saying that the Eclipse plugin can recognize these operators, it doesn't really make a case for why I'd want to create my own implementation.  One might argue that operators enhance reusability, but a static method offers much the same benefit.  Does a pluggable operator have any optimization, caching, or other advantage?

For example, here are two ways to match the start of a string in a property of a fact, one using  the "str[startsWith]" operator and another with Java's String.startsWith method:

declare Fact
    key : String @key
end

rule "Use operator"
    when
        Fact(key str[startsWith] "abc")
    then
        // do something
end

rule "Use method"
    when
        Fact(key.startsWith("abc"))
    then
        // do something
end

Does one of these perform better than the other?

Best wishes,
Tom

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130524/9b22e970/attachment-0001.html 


More information about the rules-users mailing list