diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-01 20:35:28 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2021-01-01 20:35:28 +0100 |
commit | e4821f82249bddb443a1f6a6e403087cab659c6d (patch) | |
tree | ba6969c5bb04bc88476efa43a53c7c1ceb3a3ca6 /src/main/java/io/trygvis/rules/engine | |
parent | 866eafabd7398fd1485e7aa285345a7dcea480d0 (diff) | |
download | rules-sandbox-e4821f82249bddb443a1f6a6e403087cab659c6d.tar.gz rules-sandbox-e4821f82249bddb443a1f6a6e403087cab659c6d.tar.bz2 rules-sandbox-e4821f82249bddb443a1f6a6e403087cab659c6d.tar.xz rules-sandbox-e4821f82249bddb443a1f6a6e403087cab659c6d.zip |
Migrating to Drools.
Diffstat (limited to 'src/main/java/io/trygvis/rules/engine')
-rw-r--r-- | src/main/java/io/trygvis/rules/engine/Main.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/rules/engine/Main.java b/src/main/java/io/trygvis/rules/engine/Main.java new file mode 100644 index 0000000..3730c28 --- /dev/null +++ b/src/main/java/io/trygvis/rules/engine/Main.java @@ -0,0 +1,36 @@ +package io.trygvis.rules.engine; + +import io.trygvis.rules.acme.AcmeIo; +import org.drools.core.audit.WorkingMemoryConsoleLogger; +import org.drools.core.common.DefaultFactHandle; +import org.kie.api.KieServices; +import org.kie.api.event.rule.AgendaEventListener; +import org.kie.api.event.rule.RuleRuntimeEventListener; + +import java.io.IOException; + +public class Main { + public static void main(String[] args) throws IOException { + var io = new AcmeIo(); + + var objects = io.load("acme.yaml"); + + var services = KieServices.Factory.get(); + var container = services.getKieClasspathContainer(); + var session = container.newKieSession(); + + for (var object : objects) { + System.out.println("object = " + object); + session.insert(object); + } + + var logger = new WorkingMemoryConsoleLogger(session); + session.addEventListener((AgendaEventListener) logger); + session.addEventListener((RuleRuntimeEventListener) logger); + session.fireAllRules(); + + io.dump("phase-1", session.getFactHandles()); + + session.dispose(); + } +} |