Hi Susan,

Pluto can work with pure java as well as with embedded python, the
difference is that you cannot embed the java scriptlets into the
database as text blobs (not currently anyway, see below). What I did was
have small condition and consequence java classes which have to be
compiled and made available in the application's classpath. You will
find some examples in:
pluto/test/com/cnwk/pluto/conditions
pluto/test/com/cnwk/pluto/consequences

The java files here are called in the HelloWorld and the PetStore (not
PythonPetStore) test rulesets. This is not really optimal from my point
of view, since I wanted to have no class level dependency from my main
application to the rules engine interface. Using this approach will
require that I re-distribute my condition and consequence jars into the
target application every time I changed them.

The disadvantage of using scriptlets in text blobs is that there may be
a syntax error in your script when you run the rules, but perhaps this
is not such a bad thing, since you are likely to do some unit testing on
the rule after you write it.

You can support pure Java scriptlets contained in database text blobs
using the approach I took with Python scriptlets but using BeanShell
instead of Jython. That is how its done (I think) with java scriptlets
in Drools2, but I did not really want that, since I thought it would be
easier for end users to pick up a scripting language like Python rather
than a full blown language such as Java.

-sujit

On Wed, 2006-04-05 at 13:04, Susan G Lee wrote:
> Also, is there an example like pluto that uses pure java?
> 
> 
> Thanks,
> Susan G. Lee
> 
> Distribution and New Ventures
> Depository Trust and Clearing Corporation 
> 55 Water Street, New York, NY 10041
> Phone: 212-855-2883
> E-mail: [EMAIL PROTECTED]
> 
> 
> 
> Sujit Pal <[EMAIL PROTECTED]> 
> 04/04/2006 07:25 PM
> Please respond to
> user@drools.codehaus.org
> 
> 
> To
> user@drools.codehaus.org
> cc
> 
> Subject
> RE: [drools-user] Storing rules in a database
> 
> 
> 
> 
> 
> 
> Hi Susan,
> 
> The junit examples are in the same zip bundle. I downloaded from the
> jboss rules site, and here they are in the test/com/cnwk/pluto
> directory.
> 
> So if you look at any of these tests:
> PetStoreTest.java
> PythonPetStoreTest.java
> HelloWorldTest.java
> 
> you will see this standard pattern:
>     public static Test suite() {
>         TestSuite suite = new TestSuite(PythonPetStoreTest.class);
>         TestSetup wrapper = new TestSetup(suite) {
>             protected void setUp() throws Exception {
>                 client = new DBClient(RuleTestUtils.getDataSource(),
> null);
>                 petStoreRuleSet =
> RuleTestUtils.getPetStoreDynamicPythonRuleSet();
>                 saveRule(client, petStoreRuleSet);
>             }
>             protected void tearDown() throws Exception {
>                 removeRule(client, petStoreRuleSet.getName());
>             }
>         };
>         return wrapper;
>     }
> 
> If you comment out the call to removeRule() and run the tests using "ant
> clean compile compile-test test", and assuming that you have your
> database set up to receive these rules (see doc/ruledb_pgsql.sql or
> doc/ruledb_mysql.sql for examples of what the schema looks like for
> PostgreSQL and MySQL), at the end of the test you should have three
> rulesets defined.
> 
> I guess I should have used something simpler like DbUnit to do this, but
> unfortunately I just learned how to use DbUnit last week in connection
> with something else I was doing :-(.
> 
> -sujit
> 
> On Tue, 2006-04-04 at 13:05, Susan G Lee wrote:
> > Thanks Sujit,
> > 
> > I can't find the link to download the junit examples.  can someone 
> provide 
> > the link?
> > 
> > 
> > Thanks,
> > Susan G. Lee
> > 
> > 
> > 
> > 
> > Sujit Pal <[EMAIL PROTECTED]> 
> > 04/04/2006 02:46 PM
> > Please respond to
> > user@drools.codehaus.org
> > 
> > 
> > To
> > user@drools.codehaus.org
> > cc
> > 
> > Subject
> > RE: [drools-user] Storing rules in a database
> > 
> > 
> > 
> > 
> > 
> > 
> > Hi Susan,
> > 
> > Sorry about the delay in replying.
> > 
> > If you look at the JUnit tests, there is code there to put in:
> > a) the Hello World ruleset.
> > b) the Petstore ruleset with Java conditions and consequences
> > c) the Petstore ruleset with Python conditions and consequences.
> > 
> > The JUnit tests populate these rulesets and then delete them on
> > completion, but if yuo comment out the delete logic and run the tests,
> > then your database should be populated.
> > 
> > -sujit
> > 
> > On Mon, 2006-04-03 at 10:15, Susan G Lee wrote:
> > > Does anyone have sample data for the tables used in this example?  I 
> > think 
> > > it would make it easier to understand if that's provided.
> > > 
> > > 
> > > Thanks,
> > > Susan G. Lee
> > > 
> > > 
> > > 
> > > 
> > > 
> > > "Ishafizan Ishak" <[EMAIL PROTECTED]> 
> > > 03/30/2006 12:49 AM
> > > Please respond to
> > > user@drools.codehaus.org
> > > 
> > > 
> > > To
> > > <user@drools.codehaus.org>
> > > cc
> > > 
> > > Subject
> > > RE: [drools-user] Storing rules in a database
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Appreciate the help, found it at
> > > 
> > 
> http://www.drools.org/Loading+and+managing+rules+dynamically+from+a+database
> 
> > 
> > > 
> > > 
> > > includes a web interface too. Very nice!
> > > 
> > > thanks
> > > i.ishak
> > > -----Original Message-----
> > > From: Michael Neale [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, March 30, 2006 1:13 PM
> > > To: user@drools.codehaus.org
> > > Subject: Re: [drools-user] Storing rules in a database
> > > 
> > > They should be in the articles section at www.drools.org (along with
> > > downloads - Sujits implementation works with the python semantics).
> > > 
> > > On 3/30/06, Ishafizan Ishak <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hi,
> > > >
> > > > " I found an example of storing rules in a database using hibernate
> > > > > technology "
> > > > " I think you may be referring to the article I submitted "
> > > >
> > > > Can u share me the links to these examples/articles pls?
> > > >
> > > > Thank u very much
> > > > i.ishak
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Susan G Lee [mailto:[EMAIL PROTECTED]
> > > > Sent: Thursday, March 30, 2006 5:11 AM
> > > > To: user@drools.codehaus.org
> > > > Subject: Re: [drools-user] Storing rules in a database
> > > >
> > > > Hi Sujit,
> > > >
> > > > Thank you so much for your input.  You have veen very helpful.
> > > >
> > > >
> > > > Thanks,
> > > > Susan G. Lee
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Sujit Pal <[EMAIL PROTECTED]>
> > > > 03/29/2006 03:58 PM
> > > > Please respond to
> > > > user@drools.codehaus.org
> > > >
> > > >
> > > > To
> > > > user@drools.codehaus.org
> > > > cc
> > > >
> > > > Subject
> > > > Re: [drools-user] Storing rules in a database
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Hi Susan,
> > > >
> > > > I think you may be referring to the article I submitted. An approach
> > > > using stored procedures should be similar, all the hibernate code 
> does
> > > > is to persist and retrieve the object mapping to and from the 
> > database,
> > > > so if you had stored procedures to do the same mappings, then that 
> > would
> > > > work too. The only thing to note is that not all databases support
> > > > stored procedures, and for those that do, stored procedure dialects 
> > are
> > > > different enough so the solution would be tied to a single database. 
> 
> > So
> > > > a solution with stored procedures would not be a generic one.
> > > >
> > > > Michael Neale has written a repository api for Drools3 which allows 
> > you
> > > > to plug in your repository implementation. The database 
> implementation
> > > > is based on hibernate, but it should be easy enough to replace the
> > > > mappings with stored procedures, if you really wanted to go that 
> > route.
> > > >
> > > > HTH
> > > > -sujit
> > > >
> > > > On Wed, 2006-03-29 at 11:46, Susan G Lee wrote:
> > > > > Hi,
> > > > >
> > > > > I found an example of storing rules in a database using hibernate
> > > > > technology.  Is there another example of using it w/ stored 
> > procedures
> > > > > calling the database to generate the rules? or is hibernate the 
> only
> > > > way?
> > > > >
> > > > >
> > > > >
> > > > > Thanks,
> > > > > Susan G. Lee
> > > >
> > > >
> > > >
> > > >
> > > >
> > > 
> > > 
> > 
> > 
> 
> 

Reply via email to