[rules-users] POJO accessors method in Drools facts

youssef azbakh azbakh01 at gmail.com
Mon Feb 27 06:31:14 EST 2012


Hi
I think that yo have to instanciate the object and insert it into the
working memory then you fire all rules like this :


<b>MyClass x= new MyClass();
			
			ksession.insert(x);
			ksession.fireAllRules();</b>

it will work without problem !

2012/2/27 aliosha79 <alex_orl1079 at yahoo.it>:
> 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/POJO-accessors-method-in-Drools-facts-tp3780363p3780363.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



-- 
Youssef AZBAKH
Elève ingénieur en 3ème année informatique.
Institut National de Statiqtique et d'Economie Appliquée (INSEA).




More information about the rules-users mailing list