One Ring Install
Installing One Ring is as simple as any Java EE web app, and simpler than most. Here's the quick way to get running with Tomcat:
You can set the directory in a configuration file or via JNDI. To set it in JNDI make a context .xml file in the [tomcat home]/conf/Catalina/localhost/ directory called rulesEngine.xml that looks like this:
To use a configuration file you need to create a properties file called oneRing.properties then tell the web app where to find it by setting a system environment variable called ONE_RING_CONFIG, e.g.
In the oneRing.properties file you only need one line:
We recommend you set-up something like this:-
Once you're happy with the tests you can push or pull the rule changes to your production server and "update" it.
- These builds work with Java 7. Make sure you have Java 7 installed.
- If you haven't installed tomcat before, I recommend downloading the .zip package including tomcat below and just unpacking it to get started.
- If you haven't installed tomcat before, I recommend downloading the .zip package including tomcat below and just unpacking it to get started.
- Install Tomcat. see http://tomcat.apache.org/
- Copy the war rulesEngine-1.0.1.war file to the webapp folder as rulesEngine.war
- Make sure java is in your path and run apache-tomcat-7.0.22/bin/startup.sh
- Point your browser at http://localhost:8080/rulesEngine and you see the One Ring web interface after a short wait
- Edit rules in your editor and copy to the One Ring servers rules directory - by default at [server home directory]/.OneRing/rules
- Go to the web interface, click the rules menu link, then click the update menu item to read the new rule sets into the engine
Configuration
There is one configuration option: rulesDirectory, which tells One Ring where to load the rules from.You can set the directory in a configuration file or via JNDI. To set it in JNDI make a context .xml file in the [tomcat home]/conf/Catalina/localhost/ directory called rulesEngine.xml that looks like this:
<Context>
<Environment name="rulesDirectory" value="[some path to rules dir]/testRules" type="java.lang.String" override="false"/>
</Context>
<Environment name="rulesDirectory" value="[some path to rules dir]/testRules" type="java.lang.String" override="false"/>
</Context>
To use a configuration file you need to create a properties file called oneRing.properties then tell the web app where to find it by setting a system environment variable called ONE_RING_CONFIG, e.g.
# export ONE_RING_CONFIG=/[path to the file]/oneRing.properties
In the oneRing.properties file you only need one line:
oneRing.rules.directory=[some path to rules dir]/testRules
Recommended Setup
We started out with One Ring editing the rules and storing them in the HSQL database, however this doesn't provide a robust control over changes and the ability to test and transfer. We decided to fall back on the existing infrastructure we use every day to develop software, Version Controlled files. This lets us use our IDE or favourite editor to edit the rules, save the latest version in our (D)VCS, use our Continuous Integration server to test and possibly deploy the rules, and helps with deployment. So out went the editor and we split out the rules engine so that it can be used in the IDE or and script with jUnit to test your rules.We recommend you set-up something like this:-
- On your development system (rule designer) install an IDE or editor that understands groovy
- Associate files with the extension ".ruleset" with Groovy in your IDE
- Create a Groovy (or Java) project with a source directory for your rules
- Copy the engine.jar to the projects lib directory
- Create a Git (or mercurial) repository for your rules
- Create a unit test file like the following to test your rules
Once you're happy with the tests you can push or pull the rule changes to your production server and "update" it.