0
如何在DRL文件中定義變量並向其添加值,DRL文件可以在規則之間用作靜態資源。如何在側面drools中定義變量並向它們添加值
我試圖用全球關鍵字,但是當我添加值添加到它,我也不會影響工作記憶裏面,因爲它在文檔中提到的。在我的情況下,我不能從應用程序端添加它。
實施例:
global java.util.List myList;
function java.util.List initMyList() {
List list = new ArrayList();
list.add(1);
return list;
}
rule "initListRule"
salience 1001
when
eval(myList == null)
then
myList = initMyList();
end
rule "checkIfListIsStillEmptyRule"
salience 1000
when
eval(myList != null)
then
System.out.println("MyList is Not null");
end
全球不存儲在存儲器沃然後,因爲它沒有從應用側設置myList中會始終爲空。有沒有其他方法來定義變量並將其填入DRL中?
感謝您的回答,如果假設我們定義了一個列表,通常我們有多個列表,沒有變量就不能區分兩個列表。 – Rami
只要您不需要對其動態更改做出反應,就可以使用多個全局。 – laune