// Yesterday: serialize a KP collection
OutputStream os = new FileOutputStream( pkgPath );
ObjectOutputStream oos = new ObjectOutputStream( os );
oos.writeObject( kBuilder.getKnowledgePackages() );
oos.close();
// Today: load serialized packages
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
InputStream is = new FileInputStream( pkgPath );
ObjectInputStream ois = new ObjectInputStream( is );
@SuppressWarnings("unchecked")
Collection<KnowledgePackage> kpkgs = (Collection<KnowledgePackage>)
ois.readObject();
ois.close();
kBase.addKnowledgePackages( kpkgs );
You may, of course, add more packages, compiled now.
-W
2010/11/18 Yaniv Itzhaki <iyaniv(a)gmail.com>
Hi,
I wanted to know if it is possible to precompile rules/flows and load them on demand?
Currently i am using the following code:
*KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
for (String file : files) {
//(missing code) get files from directory and add them to KnowledgeBuilder (source
files - rules and flows)
kbuilder.add(ResourceFactory.newFileResource(file), type);
}
*
* private KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase();
kb.addKnowledgePackages(kbuilder.getKnowledgePackages());*
*
*
Is there an option to add already precompiled files into KnowledgeBase and not compile
them only during the initialization phase?
Thanks
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users