Hi,
1) Your line 4 is fine you just need to do:
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
afterwards to 'associate' your packages with the knowledge base.
2) The KnowledgeBuilder is not serialisable though so I guess serialising
the KnowledgeBase IS the way to go. You can use DroolsObjectOutputStream to
serialise but it does not seem to work with large rule bases which defeats
the purpose in my case! Very annoying this serialisation business. I hope
you get it working.
Hamu, Dave wrote:
I'm not up to snuff on Drools 5.0 M4, however, there are two
observations that I have in regard to your question:
1) Given the code that you provided, line 4 is wrong. You cannot use a
static KnowledgeBaseFactory to instantiate a KnowledgeBase without
associating the KnowledgeBuilder instance. This is where my knowledge
of the APIs is not clear, but you will need to execute some additional
logic to move the knowledge-base rules from the KnowledgeBuilder to the
KnowledgeBase.
2) It's not clear what optimization that you are hoping to achieve by
serializing the Knowledge Base. Does it take a really long time to load
the drl? Also, have you looked at serializing the kbuilder? I don't
know if it's possible for certain, but that would be the next place that
I'd look.
Dave Hamu
Systems Analyst
AVNET, Inc.
8700 S. Price Rd.
Tempe, AZ 85284-2608
(480) 794-7909
dave.hamu(a)avnet.com
-----Original Message-----
From: David Boaz [mailto:davidb@dbmotion.com]
Sent: Wednesday, December 31, 2008 7:07 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] How to serialize a KnowledgeBase?
Hi all,
Im currently developing a new application using drools 5.0 M4. Im using
this style (from KnowledgeBuilder javadoc):
1- KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
2- kbuilder.add( ResourceFactory.newUrlResource( "file://myrules.drl" ),
ResourceType.DRL);
3- assertFalse( kbuilder.hasErrors() );
4- KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
Now, for optimization reasons, I want to save kbase. The problem is that
it is not serializable.
Probably, Im trying to serialize the wrong object.
can someone please guide me how to do that?
BTW, I have another question, How the KBFactory on line 4 knows the
builder used in lines 1 and 2? Will it actually work?
Thanks, David
--
View this message in context:
http://www.nabble.com/How-to-serialize-a-KnowledgeBase--tp21231939p21231
939.html
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users