Guillaume,

I've just see the blog, very good job.
It's a very elegant and flexible solution. It seems that you've find a generic way to inject
generic helper class ( not only db ) in the drools endpoint.

I'm just thinking how to support this in the upcoming SpagicStudio to generate deliverables
for the new configuration :-)

Andrea Zoppello
Engineering Ing. Informatica


Guillaume Nodet ha scritto:
Nicely written, Andrea, thanks !
Btw, you may be interested in a recent change in servicemix-drools:
the ability to inject beans configured inside the xbean.xml into the rules definition file (such as a helper with a configured dataSource for example). See http://gnodet.blogspot.com/2007/06/accessing-databases-in-servicemix.html

On 6/29/07, Andrea Zoppello <[EMAIL PROTECTED]> wrote:
I've already done this by extendig not only the drools component but also,
the class org.apache.servicemix.drools.model.Message with a method like
this:รน

org.apache.servicemix.drools.model:

public String valueOf(String xpath) throws Exception {
        JAXPStringXPathExpression expression = new
JAXPStringXPathExpression(xpath);
        if (this.namespaceContext != null)
            expression.setNamespaceContext(this.namespaceContext);
        String res = (String)expression.evaluate(null, message);
        return res;
    }

at this point in you can use your dbHelper in drools as follow:

dbh.isDomestic(in.valueOf('/MESSAGE/@par1'),in.valueOf('/MESSAGE/@par2'))



in this example i assume the incoming message is something like:

    <MESSAGE par1="PAR1" par2="PAR2">
    </MESSAGE>

Andrea Zoppello
Engineering Ing. Informatica.



pksahoo ha scritto:

> Hi ,
>
> I am new to Drool and need some help . I have done integration of
> Drool with database.
>
> I am calling DB helper class memeber function in
> Drool.
>
> In my Drool file (.drl) file, I need to pass 2
> parameter as input . Basically, I have to provide
> source airport code and destination airport code to my
> rule engine. it will call the database and based on
> query, it will return domestic or international.
>
> How can I pass the input parameter to Drool as
> variable? Right now, it is hard coded in drool file
> like dbh.isDomestic("JFK", "YYZ") .  Here is the .drl
> file:
>
> package org.apache.servicemix.drools
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.servicemix.drools.model.Exchange;
>
> import loanbroker.DbHelper;
>
> global org.apache.servicemix.drools.model.JbiHelper
> jbi;
>
>
> rule TourType
>       when
>               me : Exchange( status == Exchange.ACTIVE, in : in !=
> null, operation ==
> "{urn:logicblaze:soa:creditagency}getCreditHistoryLength")
>       then
>               DbHelper dbh = new DbHelper();
>               jbi.answer("<TourTypeResponse><name>" +
>                       dbh.isDomestic("JFK", "YYZ") +
>                       "</name></TourTypeResponse>");
> end
>
>
> Please advise.
> Regards,
> Prasanta
>
>
>





Reply via email to