Is there any API in drools to create the drl files dynamically by just passing values?

前端 未结 6 1741
鱼传尺愫
鱼传尺愫 2021-02-04 12:47

I know how to create DRL files inside KIE workbench by using all the methods. But what my problem is without using the KIE workbench, can we create the .drl fil

6条回答
  •  野性不改
    2021-02-04 13:15

    I interpret your question in two different ways.

    1. Is it possible to write rules for Drools without using the KIE workbench?

    Yes, it should support importing rules so all you need to do is open up a text editor and start typing. The rules are written as text using a fairly simple syntax that you can figure out in about 1-2 hours of reading. I do not know what your environment looks like but there should be a mechanism to parse and import a new rule. All rules you write will start out in a text editor looking like this:

    rule ""
        
    when
        
    then
        
    end
    

    You will add to the conditions and actions. Of course you will have to know what conditions you can create which is limited to your environment and likewise for the actions.

    2. Is it possible to create rules and use them programatically through some sort of API?

    Yes, I do it all of the time for the processing we do using the Java API. We have 2 types of rules that we use, static and dynamic. The static ones have pre-canned conditions and are written to perform the same comparisons (LHS) over and over and performing the same actions each time the conditions are met (RHS). The dynamic ones are created on the fly based upon a minimalistic set of object types and comparisons (LHS) specified by the user when they are created. The actions (RHS) are pre-canned but are selected for use depending on the need for the overall rule use. The entire rule is created as text then passed to the Drools parser before being added to the list of rules to evaluate.

    Hope this helps.

提交回复
热议问题