[rules-users] Using RuleDescr, PackageDescr... Classes from org.drools.lang.descr

Wolfgang Laun wolfgang.laun at gmail.com
Tue Aug 25 02:09:47 EDT 2009


These classes are not part of the "stable API", which is considered safe,
i.e., not
threatened by future changes. Also, the lack of javadoc is appalling. And
if that's not enough, creating and maintaining any but the simplest LHS
compositions programmatically is a mind-straining exercise, for which
you need a very, very good reason,...

A much easier way for generating rules programmatically is based on
templates.

If your goal is simply speeding up the Knowledge Base initialization
process,
then the standard procedure is to use (Drools 5):

// create precompiled package
OutputStream os = new FileOutputStream( "src/main/rules/x/y.pkg" );
ObjectOutputStream oos = new ObjectOutputStream( os );
oos.writeObject( kBuilder.getKnowledgePackages() );
oos.close();

// load precompiled packag
InputStream is = new FileInputStream( "src/main/rules/movie/Movie.pkg" );
ObjectInputStream ois = new ObjectInputStream( is );
@SuppressWarnings("unchecked")
Collection<KnowledgePackage> kpkgs = (Collection<KnowledgePackage>)
ois.readObject();
ois.close();
kBase.addKnowledgePackages( kpkgs );

This is equivalent to
kBase.addKnowledgePackages( kBuilder.getKnowledgePackages() );
but can, obviously, done by different programs.
-W

2009/8/24 Ashish Soni <learnspring at gmail.com>

> Hi,
>
> Please let me know if it is good idea to use classes from
> org.drools.lang.descr package directly to create a rulebase and then use it
> for execution ?
>
> Thanks,
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090825/2d51bb9e/attachment.html 


More information about the rules-users mailing list