views:

39

answers:

1

I am experimenting with OpenRules and Java and I'd like to store all my rules in a database only. If I understand the documentation correctly, I need to have one "Main.xls" in which to store the environment settings. Now the question: Is there a way to completely circumvent this one physical .xls file? Best case would be, if I could just call something like

defineOpenRulesDatabase();    
OpenRulesEngine engine = new OpenRulesEngine("db:myFile.xls");
engine.run();

where the method defineOpenRulesDatabase() defines all the settings which are defined in the db.properties file mentioned in the documentation.

Any idea on this?

A: 

Yes. According to the documentation, you can pass in any URL which Java supports (i.e. anything for which URL.openStream() will return something useful).

So you can simply embed the Jetty web server in your application, create a servlet which returns the file and then call OpenRulesEngine() with the URL of the servlet.

Or you could download the file from the DB and use File.createTempFile() to create a temporary file to set up the rules engine.

Or you could file a bug against the project and ask for another constructor which allows you to pass in an InputStream.

[EDIT] I guess you've already seen this document which explains how to put the rules into a database. From what I see, it's not possible to create the rule engine without an existing Main.xls file at least in your classpath.

But that file doesn't have to contain much:

rules/main/Main.xls the main file for a rules engine to start with. It contains only the Environment table

So you can simply put a static file in the classpath and load all the rules from the DB.

Aaron Digulla
According to the docs: "OpenRules uses an URL pseudo-protocol notation", that's at least how I understand it, too. The jetty version is not possible here. All three approaches have the problem of not being able to include rules from a subdirectory.I WOULD file a bug if I got ANY response from the developers ...
DaDaDom
See my edits for a possible solution.
Aaron Digulla