diff --git a/.gitignore b/.gitignore index 19ce1c8..988fdb0 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ target/ rules-js/test/coverage **/node_modules/ +*.iml +.idea diff --git a/README.md b/README.md index 57f9d1d..a213c3c 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,15 @@ Simple Rule Engine from Ant's blog. Able to process MVEL and Javascript rules in JVM, or run on Node.js. +Version 2.2.1: +- Fixed https://github.com/maxant/rules/issues/4 - added checks to log level in order to improve performance. +- Updated dependencies to latest versions + Version 2.2.0: -See [http://blog.maxant.co.uk/pebble/2015/08/22/1440237900000.html](http://blog.maxant.co.uk/pebble/2015/08/22/1440237900000.html) => Support for Javascript rules in JVM via Nashorn. +- See [http://blog.maxant.co.uk/pebble/2015/08/22/1440237900000.html](http://blog.maxant.co.uk/pebble/2015/08/22/1440237900000.html) => Support for Javascript rules in JVM via Nashorn. Version 2.1.0: -See [http://blog.maxant.co.uk/pebble/2011/11/12/1321129560000.html](http://blog.maxant.co.uk/pebble/2011/11/12/1321129560000.html) and +- See [http://blog.maxant.co.uk/pebble/2011/11/12/1321129560000.html](http://blog.maxant.co.uk/pebble/2011/11/12/1321129560000.html) and [http://blog.maxant.co.uk/pebble/2014/10/03/1412371560000.html](http://blog.maxant.co.uk/pebble/2014/10/03/1412371560000.html) and also [http://blog.maxant.co.uk/pebble/2014/11/15/1416087180000.html](http://blog.maxant.co.uk/pebble/2014/11/15/1416087180000.html) for Node.js. diff --git a/rules-java8/pom.xml b/rules-java8/pom.xml index 65deca6..988bc63 100644 --- a/rules-java8/pom.xml +++ b/rules-java8/pom.xml @@ -4,7 +4,7 @@ ch.maxant rules-parent - 2.2.1-SNAPSHOT + 2.2.1 ../rules-parent rules-java8 @@ -33,7 +33,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 + 3.6.1 1.8 1.8 diff --git a/rules-parent/pom.xml b/rules-parent/pom.xml index 3ce7b2f..d5ec737 100644 --- a/rules-parent/pom.xml +++ b/rules-parent/pom.xml @@ -3,7 +3,7 @@ 4.0.0 ch.maxant rules-parent - 2.2.1-SNAPSHOT + 2.2.1 pom http://blog.maxant.co.uk/pebble/2011/11/12/1321129560000.html @@ -43,7 +43,7 @@ org.apache.maven.plugins maven-source-plugin - 2.4 + 3.0.1 attach-sources @@ -57,7 +57,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.3 + 2.10.4 UTF-8 @@ -76,7 +76,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.3 + 3.6.1 1.6 1.6 @@ -103,7 +103,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.6 + 1.6.7 true sonatype diff --git a/rules-scala/pom.xml b/rules-scala/pom.xml index 38ebfb8..542269c 100644 --- a/rules-scala/pom.xml +++ b/rules-scala/pom.xml @@ -4,7 +4,7 @@ ch.maxant rules-parent - 2.2.1-SNAPSHOT + 2.2.1 ../rules-parent diff --git a/rules/pom.xml b/rules/pom.xml index c4bbe94..d6b223b 100644 --- a/rules/pom.xml +++ b/rules/pom.xml @@ -4,11 +4,11 @@ ch.maxant rules-parent - 2.2.1-SNAPSHOT + 2.2.1 ../rules-parent - 2.2.6.Final + 2.3.1.Final rules jar @@ -32,7 +32,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.5 + 3.0.2 diff --git a/rules/src/main/java/ch/maxant/rules/Engine.java b/rules/src/main/java/ch/maxant/rules/Engine.java index fe5c753..920854c 100644 --- a/rules/src/main/java/ch/maxant/rules/Engine.java +++ b/rules/src/main/java/ch/maxant/rules/Engine.java @@ -17,20 +17,14 @@ */ package ch.maxant.rules; +import org.mvel2.MVEL; + import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; -import org.mvel2.MVEL; - /** * A Rule Engine. Can evaluate rules and execute {@link IAction}s or simply provide an * ordered list of the best matching {@link Rule}s.
@@ -400,9 +394,9 @@ public List getMatchingRules(String nameSpacePattern, Input input) String msg = r.getRule().getFullyQualifiedName() + "-{" + r.getRule().getExpression() + "}"; if(String.valueOf(o).equals("true")){ matchingRules.add(r.getRule()); - log.info("matched: " + msg); + if(log.isLoggable(Level.INFO)) log.info("matched: " + msg); }else{ - log.info("unmatched: " + msg); + if(log.isLoggable(Level.INFO)) log.info("unmatched: " + msg); } } diff --git a/rules/src/main/java/ch/maxant/rules/JavascriptEngine.java b/rules/src/main/java/ch/maxant/rules/JavascriptEngine.java index ffc2ddc..eb9d85a 100644 --- a/rules/src/main/java/ch/maxant/rules/JavascriptEngine.java +++ b/rules/src/main/java/ch/maxant/rules/JavascriptEngine.java @@ -17,27 +17,6 @@ */ package ch.maxant.rules; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.logging.Logger; -import java.util.regex.Pattern; - -import javax.script.Compilable; -import javax.script.CompiledScript; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineFactory; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; - import org.apache.commons.pool2.BasePooledObjectFactory; import org.apache.commons.pool2.ObjectPool; import org.apache.commons.pool2.PooledObject; @@ -45,6 +24,16 @@ import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPoolConfig; +import javax.script.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.*; +import java.util.Map.Entry; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.regex.Pattern; + /** * A Javascript based Subclass of {@link Engine}.
* ONLY TESTED WITH JAVA 8 AND NASHORN!!
@@ -61,15 +50,17 @@ public class JavascriptEngine extends Engine { static { ScriptEngine engine = ENGINE_MANAGER.getEngineByMimeType(MIME_TYPE); ScriptEngineFactory factory = engine.getFactory(); - log.info("Using JavaScript engine " + factory.getEngineName() + "/" - + factory.getEngineVersion() + "/" - + factory.getLanguageName() + "/" - + factory.getLanguageVersion() + "/" - + factory.getExtensions() + "/" - + factory.getMimeTypes() + "/" - + factory.getNames() + "/" - + "threading model: " + factory.getParameter("THREADING") - ); + if(log.isLoggable(Level.INFO)){ + log.info("Using JavaScript engine " + factory.getEngineName() + "/" + + factory.getEngineVersion() + "/" + + factory.getLanguageName() + "/" + + factory.getLanguageVersion() + "/" + + factory.getExtensions() + "/" + + factory.getMimeTypes() + "/" + + factory.getNames() + "/" + + "threading model: " + factory.getParameter("THREADING") + ); + } } private final class PoolableEngineFactory extends BasePooledObjectFactory { @@ -291,9 +282,9 @@ public List getMatchingRules(String nameSpacePattern, Input input) String msg = r.getFullyQualifiedName() + "-{" + r.getExpression() + "}"; if(String.valueOf(result).equals("true")){ matchingRules.add(r); - log.info("matched: " + msg); + if(log.isLoggable(Level.INFO)) log.info("matched: " + msg); }else{ - log.info("unmatched: " + msg); + if(log.isLoggable(Level.INFO)) log.info("unmatched: " + msg); } } //order by priority! diff --git a/rules/src/main/resources/releaseNotes.txt b/rules/src/main/resources/releaseNotes.txt index d9b6715..be89542 100644 --- a/rules/src/main/resources/releaseNotes.txt +++ b/rules/src/main/resources/releaseNotes.txt @@ -1,3 +1,7 @@ +2.2.1 - 201702212200 +====================== +Fixed https://github.com/maxant/rules/issues/4 and updated dependencies. + 2.2.0 - 201508220000 ====================== Added support for JavaScript rules in JVM, using Nashorn.