Search code examples
droolsbusiness-ruleskie

Listing the functions in a KieBase


I am uploading three drl files with three functions in each drl. Can I get the list that contains all the 9 functions that are loaded in my KieBase.


Solution

  • Yes you can.

    From the KieBase you can get the list of KiePackages and for each of them you can get the name of the functions defined in them.

    This simple code will list all the functions in a KieBase:

    KieBase kbase = ...
    List<String> functions = kbase.getKiePackages().stream()
        .flatMap(p -> p.getFunctionNames().stream())
        .collect(toList());
    

    Hope it helps,