Thanks a lot Edson, you have been a big help.

And yeah I figured as much regarding the Eclipse IDE. Will try the approach you 
suggested.

Again thanks a lot.

________________________________
From: [email protected] 
[mailto:[email protected]] On Behalf Of Edson Tirelli
Sent: 15 July 2009 14:47
To: Rules Users List
Subject: Re: [rules-users] Getting hold of the Evaluator Registry


   Hmm, strange, I could swear those operators supported strings... but looking 
at the code, it is not there... :( anyway, patch welcome... ;)

   Regarding your questions:

1. Yes, in this case you could simply override the operators adding the support 
to Strings.

2. In Drools, any configuration can be done in one of 3 ways: system property, 
configuration file or API. They all work the same, the only difference being 
the Eclipse IDE: the eclipse IDE only picks up configurations on the 
configuration file. So, if you configure a custom operator using the API, your 
application will run just fine, BUT the eclipse DRL editor will show an error 
because it does not "run your API calls before parsing/compiling the content of 
the DRL editor". So, the best way to do it when working with the IDE is simply 
write configurations like this in the following file in the classpath of your 
eclipse project:

META-INF/drools.packagebuilder.conf

3. Yes, it will, but that is the old API. The recommended way for Drools 5 is 
to use the public APIs in the drools-api module.

   []s
   Edson
2009/7/15 Asif Iqbal <[email protected]<mailto:[email protected]>>

Edson,



Thanks for your replies they have really helped.



1)       I am still not sure about creating a new operator, since the '>=' 
operator already exists it just does not cater for strings, which I want to 
add. So would creating a new operator cause the existing one to be overrriden 
when added to the registry?



2)       Having looked at the examples and tests you emailed, I am still unsure 
how to actually wire in the changes, say for example I have replaced the 
existing '>=' evaluator or created a new evaluator so that '>='  now handles 
strings. When writing rules will the engine pick this up?.. or do I need to 
create a new jar by building?.. or do I need to update a configuration file?... 
im just not sure...



3)       Wouldn't the following also add the evaluator definition by replacing 
the existing one..



                  PackageBuilderConfiguration pkgb = new 
PackageBuilderConfiguration();

                  pkgb.getEvaluatorRegistry().addEvaluatorDefinition(new 
ComparableEvaluatorsDefinition());

                  PackageBuilder builder = new PackageBuilder(pkgb);



                  builder.addPackageFromDrl(source);

                  Package pkg = builder.getPackage();

                  // Add the package to a rulebase (deploy the rule package).

                  rules = RuleBaseFactory.newRuleBase();

                  rules.addPackage(pkg);



Thanks for your help...



________________________________

From: 
[email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Edson Tirelli
Sent: 14 July 2009 23:05
To: Rules Users List
Subject: Re: [rules-users] Getting hold of the Evaluator Registry



   I am working in one example of drools features where I implement a custom 
evaluator here:

http://anonsvn.jboss.org/repos/labs/labs/jbossrules/contrib/lotrc/src/main/java/org/drools/examples/lotrc/evaluators/IsAdjacentToEvaluatorDefinition.java

   I use the configuration file instead of API in the example:

http://anonsvn.jboss.org/repos/labs/labs/jbossrules/contrib/lotrc/src/main/resources/META-INF/drools.packagebuilder.conf

   []s
   Edson

2009/7/14 Edson Tirelli <[email protected]<mailto:[email protected]>>

   Asif,

   My recommendation is create a new operator for you instead of overriding 
existing ones. Although if you really want to replace the existing ones, 
setting the property or calling the API to register a new operator will 
override the default.

   See:

http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/builder/KnowledgeBuilderConfigurationTest.java

   Test method:

testEvaluatorConfiguration()

   []s
   Edson

2009/7/14 Asif Iqbal <[email protected]<mailto:[email protected]>>

Hi,



What I need to do is modify one of the evaluator classes specifically '<=', so 
that it can handle strings. Now I know I need to create a class similar to 
ComparableEvaluatorDefinition. But what I want to do is replace the existing 
one in the evaluator registry with my implementation which will include the 
additional String capability.



>From my understanding that should be all that is required. Unless im missing 
>something... now all I need to know is how do I get hold of the evaluator 
>registry?



Cheers



I



_______________________________________________
rules-users mailing list
[email protected]<mailto:[email protected]>
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com<http://www.jboss.com>



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com<http://www.jboss.com>

_______________________________________________
rules-users mailing list
[email protected]<mailto:[email protected]>
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com<http://www.jboss.com>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to