BAEL-812: List of Rules Engines in Java (#2319)
* 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
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.easyrules</groupId>
|
||||
<artifactId>easy-rules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jeasy</groupId>
|
||||
<artifactId>easy-rules-core</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -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