0
votes

I have to start drools for different classes with separate drl files.

My first code looks like:

KieServices ks = KieServices.Factory.get();
                KieContainer kContainer = ks.getKieClasspathContainer();
                KieSession kSession = kContainer.newKieSession("ksession-rules");

 for (AccessA access : listA) {
                    FactHandle fh = kSession.insert(access);

                    kSession.fireAllRules(1);
                    kSession.delete(fh);
                }

There are some drl files in the Rule Folder for AccessA - AccessD

How can I fire these separate rules for the special accesses?

1

1 Answers

1
votes

You have two options - but see the last paragraph.

First: create separate knowledge bases and separate sessions for each of the four "access" categories.

Second: Put the rules for the four categories into four different agenda groups and set the focus before you insert the facts.

But since the facts from the four categories are objects of four different classes AccessA, AccessB, AccessC and AccessD, there is no reason to overengineer this rule base. Patterns will reflect the class name, and so the rules for B, C and D will not be activated when a fact of class AccessA is inserted.