Hi all,

I need to use drools servicemix component, and in my rules, i need to use a db helper object to
evaluate some rule conditions against database.

I've just read the very good approach, proposed in http://gnodet.blogspot.com/2007/06/accessing-databases-in-servicemix.html.

The only problem, that i've with this approach is that some of my customer, want to have in the dbhelper methods, a parameter that switch the datasource to use for a query:

for example they want to write something like:


package org.apache.servicemix.drools

import org.apache.servicemix.drools.model.Exchange;
import org.apache.servicemix.drools.model.DbHelper;
global org.apache.servicemix.drools.model.JbiHelper jbi;

   rule "Rule1"
   when
       me : Exchange( status == Exchange.ACTIVE, in : in != null );
       db : DbHelper ( );
eval( db.exist( in.valueOf("/ACTION/@name"), "STRING", "attribute", "name", "ds1" ) );
   then
       jbi.fault( "<ERROR> The value is already present in db </ERROR>" );
   end

   rule "Rule1"
   when
       me : Exchange( status == Exchange.ACTIVE, in : in != null );
       db : DbHelper ( );
eval( db.exist( in.valueOf("/ACTION/@name"), "STRING", "attribute", "name", "ds2" ) );
   then
       jbi.fault( "<ERROR> The value is already present in db </ERROR>" );
   end

where the last parameter of db.exist method identidies the datasource and they could have rules that
switch from ds1 to ds2.

To do this it could be enough to have an object that let's my helper to access the jndi context of servicemix.

To get this type of behaviour at the moment, we've a customized version of servicemix-drools, but
in future i'd like to rely on the standard component.

Is this possible to achieve this, maybe injectiong in a helper object that lets me to access to jndi of servicemix???


Thanks in advance


Andrea


Reply via email to