[rules-users] Drools get value from stateful session

forsakendoll forsakendoll at hotmail.com
Sat Nov 9 21:57:20 EST 2013


How can I get the value from a stateful session. As they say I can use this:

protected Collection findFacts( final StatefulKnowledgeSession session,
final String factClass )
{
        ObjectFilter filter = new ObjectFilter()
        {
            @Override
            public boolean accept( Object object )
            {
                return object.getClass().getSimpleName().equals( factClass
);
            }
        };

        Collection results = session.getObjects( filter );

        return results;
}

to get the value from the rules. Given the fact the code already red the
rules when I  tried this:

StatefulKnowledgeSession ksession =
aKnowledgeBase.newStatefulKnowledgeSession();

ksession.insert( aBean );
ksession.fireAllRules();

Collection result = findFacts( ksession,
"com.neu.als.thesis.db.beans.StudentBean" );
        
ksession.dispose();
for( Object test : result )
{
      System.out.println( test == null );
      System.out.println( test );
}

Nothing is printed. What is the proper way to get bean that I inserted in
the rules?




--
View this message in context: http://drools.46999.n3.nabble.com/Drools-get-value-from-stateful-session-tp4026712.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list