How to set up a KB without KnowledgeBaseManager?

0 views
Skip to first unread message

brigh...@gmail.com

unread,
Mar 14, 2008, 3:38:05 AM3/14/08
to take rule compiler
I've been using Take in our project. There is a external fact store
implementing with DBMS in our KB. I can generate interfaces and run
the app while Take dynamically generates the implementations, compiles
and loads them. But it will generate and use a new version of impl
every time the app runs. How can I set up a KB with its bindings using
the generated impl without using the KnowledgeBaseManager?

Thanks in advance.

cheers, BP

Jens Dietrich

unread,
Mar 14, 2008, 4:12:51 AM3/14/08
to take-rule...@googlegroups.com
Hi there,

The typical use case would be that you recompile the classes if one of
the following conditions is true:
- your app starts
- you want to recompile because the rules have changed

To achieve this, access the kb through a wrapper that caches the kb (as
instance variable) with lazy initialization, and reset this variable to
null if you want to trigger recompilation.

If you want to keep the kb between application startups, try the
following (I have not tried this, but it should work): serialize the kb.
To deserialize, you will need to use the custom classloader as typically
the working directory is outside the normal application classloader
classpath. For binary serialization, overridding resolveClass in
ObjectInputStream should do the trick (your kb must also implement
Serializable)!. I am not sure how it works fo XMLDecoder, but this
shoudl be possible as well.
Or, even simpler, store the package name of the implementation class in
a config file, and use a URLClassLoader to load the KB class from there
and instantiate it with newInstance() !

Hope this helps, Jens

Reply all
Reply to author
Forward
0 new messages