[rules-users] How to get all rules filed, drools camel server

srikanthmalli srikanthmalli at gmail.com
Mon Sep 16 14:08:23 EDT 2013


Here is what I did, it works fine but just wanted to make sure this is right
way, please experts confirm.


public class CustomAgendaEventListener extends DefaultAgendaEventListener
implements AgendaEventListener {
    public static final String RULE_ACTIVATED_LIST_IDENT =
"RuleActivatedList";
    public void beforeActivationFired(BeforeActivationFiredEvent bafe) {
        final Rule rule = bafe.getActivation().getRule();
        RuleData rul = new RuleData();
        rul.setRuleName(rule.getName());
        rul.setRuleType(rule.getPackageName());
        rul.setRuleMetaData(rule.getMetaData());

        List<RuleData> rulesActivatedList = (List)
bafe.getKnowledgeRuntime().getGlobal(RULE_ACTIVATED_LIST_IDENT);

        if (null == rulesActivatedList)
        {
            rulesActivatedList = new ArrayList<RuleData>();
            rulesActivatedList.add(rul);
            try{
                Globals globals = bafe.getKnowledgeRuntime().getGlobals();
                globals.set(RULE_ACTIVATED_LIST_IDENT, rulesActivatedList);
            }
            catch (Exception e)
            {
                System.out.println("Error adding RuleActivatedList to
Gloabl");
                e.printStackTrace();
            }
        }
//        System.out.println("*********Before:*********" +
rule.getPackageName() + "." + rule.getName());
    }

}



--
View this message in context: http://drools.46999.n3.nabble.com/How-to-get-all-rules-filed-drools-camel-server-tp4025983p4025984.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list