A Java Based Decision Table Rules Engine


DTRulesDTRules QR

To execute DTRules, you need to install Java.  You need at least version 1.6.  You want to install the JDK (or Java for Developers).  Oracle seems to change their website frequently, so if the links we provide here are bad, let us know and we will fix them.

You may wish to install Eclipse.  Eclipse for Java EE Developers, or IDE for Java Developers will work fine.  Most versions will, so if you need a particular cut of Eclipse for your application, then just use that.  Assuming you can figure out how to compile Java projects, everything will work fine.

Avoid Building, and just use DTRules Binaries

DTRules 4.3 is available in the maven repo1 repositories. You can download binaries directly from the maven repository by selecting the  dtrules jar and the compileutil jar.

If you are building your application using maven, then you can add these dependencies to your pom.xml file:


Once you have added these dependencies to your pom file, you still need to a at least a couple of classes to compile your decision tables, and to test them.  The easiest way to set those things up is to grab the example projects from the Source Repositories.  I will try and add more discussion on how to do that here, as it really isn’t that hard or involved.

Install and Build DTRules

We keep the source in a Git repository, hosted at Github.  You can find the DTRules Repository here.

Setting up a Github account would be a good idea.  But even if you don’t want to do that, their instructions for installing Git are pretty good.  And with git installed, you can more easily navigate examples and such.  You can get around this if you like (how is noted below).

Last you need Maven.

Once you have these tools installed and working, you are ready to download and build DTRules.

You can use Git to pull the DTRules/DTRules repository down using this command:

Git clone git://github.com/DTRules/DTRules.git

Or you can browse to the [https://github.com/DTRules/DTRules DTRules Repository] and download a zip or tar of the source (your choice). You have the option of picking the branch or tag of the source you care to download. (See the Repository Overview below). Extract the source where you wish on your drive. You will get a DTRules folder with all the Rules Engine source and sampleprojects source.

Once you have the source in place, open up a Bash Shell (Git provides this for you, Windows Users!) and cd to the DTRules directory. Type:

mvn clean install

This should build cleanly. Then if you are going to use Eclipse, type:

mvn eclipse:eclipse

then fire up eclipse, and click:

File->import->General->Existing Projects into Workspace

You may need to define M2_REPO in eclipse. Pick one of the projects,

  1. Right click on a project
  2. properties -> Java Build Path -> Libraries -> Add Variable -> Configure Variables -> New
    1. Name M2_REPO
    2. Path -> click folder.
      1. navigate to your .m2/repostory/
      2. click ok
    3. click ok

Repository Overview

  1. Go to the [https://github.com/DTRules/DTRules DTRules].
  2. Click “Switch Tags” to view or select one of the current releases. At this time, the following releases are available:
    1. 2.0 — The 2008 release, the first production release of DTRules
    2. 3.0 — The 2010 release
    3. 4.1 — The March 2011 release
    4. 4.2 — Should be available soon, and is identical to 4.1 but with maven support
  3. Click “Switch branches” to view available development builds. The available development builds include
    1. 5.0-SNAPSHOT adds a number of features and is required for the CHIP and ChipApp examples. Also includes maven support

To Download

This section assumes that you just want to download the source for DTRules. Obviously you can use Git to clone the repository and go to town with whatever branch or tag you wish. However, many people just want to look at the examples and poke around with DTRules without messing with git. Luckily Github supports this sort of thing.

  1. Go to the [https://github.com/DTRules/DTRules DTRules].
  2. On the right hand side, select “Download Source”.
  3. From here you can choose one of the releases to download, and you are done.
  4. Or you can select “view [n] other downloads” and pick a branch (such as 5.0-SNAPSHOT).
  5. You can select whether you want a Zip or Tar.
  6. Unzip or untar this file in your Eclipse workspace. This will include DTRules, the Compilers, and Sample projects.
  7. Have fun. In versions after 4.3 you may have to do your own configuring in Eclipse to get the projects up to snuff. Or use maven, as described above.

Useful Tools

The Decision Tables are maintained in spreadsheets, so any one of a number of spreadsheet programs will be necessary. (Excel, Google Docs, Open Office, etc. all work fine).

You may also want to use an XML editor. Under windows, I am fond of XML Marker as it makes nice tables of the XML without any effort on my part.  But Eclipse also works very well, as does Notepad++.

You will need Java. And for most of our examples, we assume you are working from Eclipse. In fact, Eclipse isn’t really necessary, as we have not released any Eclipse plug-ins as of yet.

Download the Reservations example

  1. Go to the [http://github.com/PaulSnow/ Paul Snow’s Repositories] and select the PaulSnow/Reservations repository.
  2. You can find the “Download Source” icon in the top right of the page.
  3. Select either Zip or Tar (your choice).
  4. Unzip or untar this file into your Eclipse workspace

Dependency Details

The Rules Engine runtime has no dependencies. This means you can deploy Decision Table based rules in your application using only the DTRules.jar. Nothing else is needed unless you intend to support modifying and compiling your Rules as part of your application.

For development, DTRules uses the following libraries:

* Apache POI — Java API To Access Microsoft Format Files
* CUP — LALR Parser Generator in Java
* JFlex — The Fast Scanner Generator for Java

Of course, Maven handles the dependencies for you, but if you are setting up your application by hand, your list of dependencies is pretty small.