Looks like the problem is that there are two agenda filter classes:
org.drools.runtime.rule.AgendaFilter and org.drools.spi.AgendaFilter.

odrr.AgendaFilter is what is required by the StatefulKnowledgeSession, this 
then wraps it in a class to convert it to an ods.AgendaFilter which is what the 
internal classes use.
RuleNameEndsWithAgendaFilter seems to implement ods.AgendaFilter and not 
odrr.AgendaFilter which is what I'd expect - this is possibly a bug.
Your options are to create a simple wrapper which converts an ods.AgendaFilter 
to an odrr AgendaFilter so that when you pass it into the knowledge session 
that can then wrap it back to an odsAF. Alternatively you could just copy or 
extend RuleNameEndsWithAgendaFilter and give it the 'correct' interface.

Thomas

> -----Original Message-----
> From: [email protected] [mailto:rules-users-
> [email protected]] On Behalf Of Vignesh
> Sent: 09 September 2010 10:32
> To: [email protected]
> Subject: [rules-users] Firing Specific rules using KBase and
> StatefulKnowledgeSession
>
>
> Hi,
>
> We are not able to fire specific rules using KBase and
> StatefulKnowledgeSession,
>
> //Code snippet
>
> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
> ksession.fireAllRules(new RuleNameEndsWithAgendaFilter("test"));
>
> If we use the method directly we are getting the below compile time error,
> The method fireAllRules(int) in the type StatefulRuleSession is not
> applicable for the arguments (RuleNameEndsWithAgendaFilter)
>
> and when we cast it and used the same by
> ksession.fireAllRules((AgendaFilter) new
> RuleNameEndsWithAgendaFilter("test")); but getting the below exception,
> java.lang.ClassCastException: org.drools.base.RuleNameEndsWithAgendaFilter
>
> Same thing we are able to achieve using RuleBase and WorkingMemory as below,
>
> RuleBase ruleBase = agent.getRuleBase();
> WorkingMemory wrkMemory = ruleBase.newStatefulSession();
> int i=wrkMemory.fireAllRules(new RuleNameEndsWithAgendaFilter("read"));
>
> Any pointers on how to use this functionality for firing specific rules
> using KBase and StatefulKnowledgeSession, by filtering out rules based on
> rule names. Please help in this regard.
>
> Thanks,
> Vignesh
> --
> View this message in context: http://drools-java-rules-
> engine.46999.n3.nabble.com/Firing-Specific-rules-using-KBase-and-
> StatefulKnowledgeSession-tp1444889p1444889.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users


**************************************************************************************
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
[email protected] and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

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

Reply via email to