Skip to content

Commit

Permalink
added the ability to delete dynamic rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dev committed Oct 9, 2023
1 parent abc97b9 commit fb997f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ public synchronized void reset() {
ruleProvider.reset();
}

public void removeDynamic(Method method, JRule jRule) {
contextList.removeIf((executionContext) -> executionContext.getMethod().equals(method));
ruleProvider.remove(jRule, method);
}

public boolean watchingForItem(String itemName) {
if (itemRegistry == null) {
// JRuleEngine not completely initialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public void reset() {
rules.clear();
}

public void remove(JRule rule, Method method) {
JRuleModuleEntry entry = rules.get(JRuleModuleEntry.createUid(rule, method));
if (entry != null) {
listeners.stream().forEach(e -> e.removed(this, entry));
entry.dispose();
}
}

public void add(JRuleModuleEntry entry) {
rules.put(entry.getUID(), entry);
listeners.stream().forEach(e -> e.added(this, entry));
Expand Down

0 comments on commit fb997f6

Please sign in to comment.