Skip to content

Instantly share code, notes, and snippets.

@fmbenhassine
Last active May 24, 2018 20:56
Show Gist options
  • Save fmbenhassine/5d14f99dc85f431a85d48eeb8133997d to your computer and use it in GitHub Desktop.
Save fmbenhassine/5d14f99dc85f431a85d48eeb8133997d to your computer and use it in GitHub Desktop.
easy rules 1.3 with java 6 sample #EasyRules
import org.easyrules.annotation.Action;
import org.easyrules.annotation.Condition;
import org.easyrules.annotation.Rule;
import org.easyrules.api.RulesEngine;
import org.easyrules.core.AnnotatedRulesEngine;
public class Main {
public static void main(String[] args) {
RulesEngine rulesEngine = new AnnotatedRulesEngine();
rulesEngine.registerRule(new MyRule());
rulesEngine.fireRules();
}
@Rule
public static class MyRule {
@Condition
public boolean when() {
return true;
}
@Action
public void then() {
System.out.println("it works!");
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<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>test</groupId>
<artifactId>test-easyrules-java6</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.easyrules</groupId>
<artifactId>easyrules-core</artifactId>
<version>1.3.0</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment