This is what you might do:
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add( ResourceFactory.newFileResource( "Movie.drl" ),
ResourceType.DRL );
if( kBuilder.hasErrors() ){
for( KnowledgeBuilderError err: kBuilder.getErrors() ){
System.out.println( err.toString() );
}
throw new IllegalStateException( "DRL errors" );
}
OutputStream os = new FileOutputStream( "Movie.pkg" );
ObjectOutputStream oos = new ObjectOutputStream( os );
oos.writeObject( kBuilder.getKnowledgePackages() );
// And now, from the file containing the binary knowlewdge packages:
InputStream is = new FileInputStream( "Movie.pkg" );
ObjectInputStream ois = new ObjectInputStream( is );
@SuppressWarnings("unchecked")
Collection<KnowledgePackage> kpkgs = (Collection<KnowledgePackage>) ois.readObject();
ois.close();
kBase.addKnowledgePackages( kpkgs );
-W
Hello Everybody,
I'm a newbie to Drools, so please excuse me, if question is very fundamental.
I'm not using drools with eclipse or brms.
I would like to convert the drl file which I had created using a text editor to the binary form ie. in pkg format (serialized), which can be used im my Java application.
Is there a tool, or a code snippet which gives me an idea as to how this is done.
Regards,
kp
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users