[rules-users] OSGI, classloading, and imports in KnowledgeBuilder

Lasse.Wallentin at APCC.com Lasse.Wallentin at APCC.com
Fri Sep 4 08:16:20 EDT 2009


Hi Marcel,
 
>  I'm running into the exact same problem as you did. I have an OSGI 
bundle 
> where I embed Drools and all the dependencies and I'm deploying it on 
FUSE
> 4.0 . I tried passing the classloader posted on this thread to Drools 
but
> still the same problem. I don't understand when you talk about the 
imports
> where they should be placed and which imports.

The imports I was talking about was the ones embeded in the Descision 
tables.

Depending on your spreadsheet editor the imports may have a tendency to 
hide themselves ;-(

A neat trick when working with Decision Tables is to convert them to the 
rule format.

Something like the below lines will achieve this:

public String compile(String path) {
        String drlStr = "";
 
        try {
                Resource pathResource = 
ResourceFactory.newClassPathResource(path, getClass());
                DecisionTableConfiguration dtableconfiguration = 
KnowledgeBuilderFactory.newDecisionTableConfiguration();
 dtableconfiguration.setInputType(DecisionTableInputType.XLS);
                drlStr = 
DecisionTableFactory.loadFromInputStream(pathResource.getInputStream(), 
dtableconfiguration);
        } catch (IOException e) {
                e.printStackTrace();
        }
        return drlStr;
}
 

Kind regards

Lasse Wallentin



More information about the rules-users mailing list