[rules-users] drl to pkg
Wolfgang Laun
wolfgang.laun at gmail.com
Sun May 3 08:34:47 EDT 2009
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
2009/5/2 Perumaal Krishnaraj <perumaal.k at gmail.com>
> 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 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/20090503/43dd358f/attachment.html
More information about the rules-users
mailing list