ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Using Drools in Your Enterprise Java Application
Subject:   Drools and Spring (Email and reply)
Date:   2005-08-28 13:11:12
From:   paul_browne
Paul,


I read both articles and I'm grateful. I will be pushing to try an use this in
future rule-based projects. However, I saw in the latter of the two articles, you
had a daoFactory providing a dao for a data request.


<java:condition>
daoFactory.getStockDao().isOnStockList(stockOffer.getStockName())
</java:condition>


Is it possible to have Spring set this dependency. In other words, is there an
existing Spring integration for Drools, or would this have to be an in-house module?
Thank you in advance.


Onyeje "Jay" Bose
http://www.jaybose.com



Jay,


Drools does come with a Spring Integration module (more info at http://drools.org/Spring+Integration). Most of the integration listed on this page deals with the rules , rather than where the rules get their data from.


While there are many ways to integrate Spring to the example you give , the easiest would be to follow standard Spring practice , and allow the framework to set the data source on the bean , then refer to that value (via a standard getter method) from the rule.


The Red-Piranha open source project has a sample of using a Dao with spring. More at http://cvs.sourceforge.net/viewcvs.py/red-piranha/CVSROOT/samples/
(follow the sample-db-access-code/ links)


Paul Browne
www.firstpartners.net