During OptaPlanner solving phrase, I wish to update a global variable. The changes of global variable will modify my next rules validation.
Result.java
package com.domain;
public static boolean status;
...
...
Sample.drl
import org.optaplanner.core.api.score.buildin.hardsoft.HardSoftScoreHolder;
import com.domain.Result;
global HardSoftScoreHolder scoreHolder;
rule "Sample Rule"
when
$PlanningEntity:PlanningEntity()
then
somelogic($PlanningEntity);
if(Result.status){
scoreHolder.addHardConstraintMatch(kcontext, -500);
}
end
function void somelogic(PlanningEntity planningEntity){
if(condition 1...){
Result.status = true;
}else if(condition 2...){
Result.status = false;
}else{
//Do Nothing
}
}
My Question:
How can I declare the static global variable per solving session. (To avoid multiple users doing the OptaPlanner solver at the same timing.)