Extensions

The release of the version 1.4.0 of MRules, coincided with the release of two extensions, allowing to add features to the core library.

The version 1.5.0 also came with two new extensions, allowing to use JDK 7 and JDK 8 specific features.

The version 1.9.0 came with the new Spring extension, allowing to ease MRules integration in a spring.io based project.

These extensions are available on the download page, with their source code. The source code is free to use and adapt.

JDK 7

This extension enrich the conversion framework to handle the Path object. It allows to convert data between File, URI and Path.

This extension may be used for JDK 1.7 +. No more configuration is needed than include the binary in the CLASS_PATH.

Maven usage to integrate it is advised. A transitive dependency allows to retrieve the library core. Only one dependency declaration is necessary.

POM example for Maven :

JDK 8

This extension enrich the conversion framework to handle the new java.time package. It allows to convert dates and times between the legacy java.util.Date type, the new Java 8 date and time representations, Calendar implementations, SQL types.

This extension may be used for JDK 1.8 +. No more configuration is needed than include the binary in the CLASS_PATH.

Maven usage to integrate it is advised. A transitive dependency allows to retrieve the library core. Only one dependency declaration is necessary.

POM example for Maven :

Spring

This extension provides Spring Factories in order to instanciate and inject rule engines like other Spring managed beans. See the “how to” and the demo project to learn how to use it.

This extension may be used for JDK 1.5 +. No more configuration is needed than include the binary in the CLASS_PATH.

Maven usage to integrate it is advised. A transitive dependency allows to retrieve the library core. Only one dependency declaration is necessary.

POM example for Maven :

Bytecode generation

When the rule engine accesses to input / output bean data (for read or write), Java Reflection API are used.

This extension allows not to use these API when possible, that is to say when accessed data is “public”. Bytecode will be generated at runtime, and directly used. Reflection API will however be used for “private” and “protected” data.

Java reflexion API has become faster and faster every version, and since JDK 1.7, it’s almost as fast as using standard getter / setter with native code. So using this extension will bring very few performance improvements at execution (less than 5%) but will greatly increase compilation time. It will be really useful in very few cases, but it’s a great example on how to develop your own extensions and how to use runtime compiler in Java.

This extension may be used for JDK 1.7 +. No more configuration is needed than include the binary in the CLASS_PATH.

POM example for Maven :

JSON REST Web Service

A web application allowing to execute remotely the rule engine is currently under development.

A pre-version is available, offering the following features:

  • Declaring one or more Rule Set as JNDI resources.
  • Remotely execute these rule sets using a JSON REST Web Service.

Rule Sets JNDI names must be built like “java:comp/env/rules/{name}”, then the engine execution url will be: “http://host/MRulesWS/run/{name}”.

The application is built to be deployed on Tomcat 8.0, but may be easily ported on any other web container. At this stage, it’s provided as a development base but is not destined to be used as is.

Development are being made to provide a production ready application, with easy deployment under the form of Docker containers.