BAEL-812: moving examples to rule-engines folder (#2461)
* spring beans DI examples * fix-1: shortening examples * List of Rules Engines in Java * BAEL-812: Openl-Tablets example added * BAEL-812: artifacts names changed * BAEL-812: moving rule-engines examples to rule-engines folder * BAEL-812: removing evaluation article files * BAEL-812: folder renamed * BAEL-812: folder renamed * BAEL-812: pom.xml - parent added
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
ee9152a091
commit
f2efbd9a67
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.easyrules;
|
||||
|
||||
import org.jeasy.rules.annotation.Action;
|
||||
import org.jeasy.rules.annotation.Condition;
|
||||
import org.jeasy.rules.annotation.Rule;
|
||||
|
||||
@Rule(name = "Hello World rule", description = "Always say hello world")
|
||||
public class HelloWorldRule {
|
||||
|
||||
@Condition
|
||||
public boolean when() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Action
|
||||
public void then() throws Exception {
|
||||
System.out.println("hello world");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.easyrules;
|
||||
|
||||
import org.jeasy.rules.api.Facts;
|
||||
import org.jeasy.rules.api.Rules;
|
||||
import org.jeasy.rules.api.RulesEngine;
|
||||
import org.jeasy.rules.core.DefaultRulesEngine;
|
||||
|
||||
public class Launcher {
|
||||
public static void main(String... args) {
|
||||
// create facts
|
||||
Facts facts = new Facts();
|
||||
|
||||
// create rules
|
||||
Rules rules = new Rules();
|
||||
rules.register(new HelloWorldRule());
|
||||
|
||||
// create a rules engine and fire rules on known facts
|
||||
RulesEngine rulesEngine = new DefaultRulesEngine();
|
||||
rulesEngine.fire(rules, facts);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user