[rules-users] Precompile Rules & Flows
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Nov 18 08:13:59 EST 2010
// 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 at 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 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/20101118/c9377209/attachment.html
More information about the rules-users
mailing list