[rules-users] Drools facts using POJO accessor methods error

Wolfgang Laun wolfgang.laun at gmail.com
Mon Feb 27 07:15:50 EST 2012


As soon as you use eval(), you are in Java-land where String
comparisons should not be made using "==".

There's nothing wrong with the second form, i.e., you can write (using
Drools 5.3.0)

   MyClass (getClassName() == "Class1")

although the simpler form is usually preferred:

  MyClass( className == "Class1" )

-W


On 27/02/2012, aliosha79 <alex_orl1079 at yahoo.it> wrote:
> Hi,
> i have some troubles to undestand how drools processes FACTS. I have a POJO
> class resulted from an UnMarshal jaxb processing like this:
>
> public MyClass {
>
> protected String className = "Class1";
>
> public getClassName(){
>         return className;
> }
>
> public setClassName(String className){
>         this.className = className
> }
>
> }
>
>
> Now i have to compose a drl file with a rule like this:
>
>
> when
>         $Class : MyClass()
>         eval ($Class.getClassName() == "Class1")
> then
>         System.out.println("ok!!!");
> end
>
>
> This syntax doesn't rise errors BUT doesn't match the real name... no ok
> message are printed.
>
>
> when
>         $Class : MyClass (getClassName() == "Class1")
> then
>         System.out.println("ok!!!");
> end
>
> This syntax raises me a null pointer exception!!!
>
>
> What's the right syntax?
> Can i use the accessor methods building drools facts?
> Thanks a lot!
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-facts-using-POJO-accessor-methods-error-tp3780387p3780387.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list