Extensions

MRules products are shipped with several extensions, pursuing various objectives:

  • Add feature which are not included in the library core.
  • Use external products features (Spring, versions supérieures du JDK)
  • Link some of our products between them.

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

Business Rule Engine DSL

This extension brings a new way to configure the MRules Business Rule Engine, by writing rules in a syntax close to natural language.

For the moment, the syntax has been created in English. But translation is in progress in other languages.

For example, the following syntax is completely valid:

for each numbers starting from 10 ending at 20 increment by 5 set current element into $elementCourant then set current index into $indexCourant then execute all of
 print $elementCourant
 print $indexCourant
end of for

This extension is extensible itself:

  • If you have developed your own addons to cover specific needs, it is easy to add syntactic elements to integrate them into the grammar.
  • Adding a translation or changing the syntax of an existing grammar is also possible.

More information on using this extension on its dedicated page.

DSL Editor Web Component

This extension proposes a Web component, created for Vaadin, allowing to edit a text respecting a DSL created via our product “MRules Grammar Engine”.

This editor offers natively:

  • A simple and intuitive auto-completion.
  • Syntax validation when typing.

This extension must be derived to include the grammar to edit and some configuration elements. This is the case of :

  • The Business Rule Engine DSL Editor Web Component extension.
  • The JSON Editor Demo.

This editor is based on ACE Editor, embeded in an open source Vaadin Component we have forked and improved and which can be found here on GitHub.

Business Rule Engine DSL Editor Web Component

This extension proposes a Web component, created for Vaadin, allowing to edit the configuration of our product “MRules Business Rule Engine”, by using the syntax “natural language” (cf extensions above).

This component can be used in a standalone mode (a Spring Boot package is proposed) or integrated into an existing application to offer a business rules administration page.

Html documentation generator for grammars

This extension extends the grammar engine, in order to export generated documentation in html format. Its usage is illustrated in the DSL editor web component or in the JSon Grammar Demo.

Also, the online documentation of the BRE grammar syntax is generated by this extension.

It’s based on the jtwig templating system and can be easily extended or personalized.

It can be used with JDK 1.8 +.

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 can be used with 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 :

<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">
    <dependencies>
        <!-- Adding dependency -->
        <dependency>
            <groupId>com.massa.mrules.extensions</groupId>
            <artifactId>mrules-ext-jdk7</artifactId>
        </dependency>
    </dependencies>
</project>

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.

If used with the Business Rule Engine, it overrides some of the default global variables providers (#DATETIME, #DATE, #TIME) to handle the java.time types.

This extension can be used with 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 :

<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">
    <dependencies>
        <!-- Adding dependency -->
        <dependency>
            <groupId>com.massa.mrules.extensions</groupId>
            <artifactId>mrules-ext-jdk8</artifactId>
        </dependency>
    </dependencies>
</project>

Monitoring

This extension allows to take advantage of the statistic data collected by rulesets an exposed with JMX, in order to transpose it into an exportable format compatible with modern monitoring stacks (Open Metrics, Prometheus, …).

To achieve this, the extension is based on Micrometer. The Spring extension allows to configure it easily. The health insurance demo allows to see it in action.

This extension can be used with JDK 1.8 +.

POM example for Maven :

<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">
    <dependencies>
        <!-- Adding dependency -->
        <dependency>
            <groupId>com.massa.mrules.extensions</groupId>
            <artifactId>mrules-ext-monitoring</artifactId>
        </dependency>
    </dependencies>
</project>

Spring

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

This extension may be used for JDK 1.6 +. 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 :

<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">
    <dependencies>
        <!-- Adding dependency -->
        <dependency>
            <groupId>com.massa.mrules.extensions</groupId>
            <artifactId>mrules-ext-spring</artifactId>
        </dependency>
    </dependencies>
</project>

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 :

<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">
    <dependencies>
        <dependency>
            <groupId>com.massa.mrules.extensions</groupId>
            <artifactId>mrules-ext-native-properties</artifactId>
        </dependency>
    </dependencies>
</project>

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.