[rules-users] How to serialize a KnowledgeBase?

Hamu, Dave Dave.Hamu at Avnet.com
Wed Dec 31 12:11:50 EST 2008


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 at avnet.com


-----Original Message-----
From: David Boaz [mailto:davidb at dbmotion.com] 
Sent: Wednesday, December 31, 2008 7:07 AM
To: rules-users at 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.






More information about the rules-users mailing list