[rules-users] Creating a KnowledgeBase using a KnowledgeAgent, KnowledgeAgentConfiguration and KnowledgeBaseConfiguration

Tina Vießmann tviessmann at stud.hs-bremen.de
Mon Aug 23 05:03:54 EDT 2010


  Hi,

I want to create a KnowledgeBase using stream processing mode, getting 
its resources from an change-set xml and getting the updated when 
resources are changed. So far I'm aware I need a KnowledgeAgent and a 
configuration for the kagent and the kbase.
My code is:

    // create knowledge base

    // knowledge base configuration
    KnowledgeBaseConfiguration kbaseConf =
    KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
    kbaseConf.setOption(EventProcessingOption.STREAM);

    // knowledge base
    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConf);


    // create knowledge agent

    // create knowledge agent configuration
    KnowledgeAgentConfiguration kagentConf =
    KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
    //enable incremental knowledge base build
    kagentConf.setProperty("drools.agent.newInstance", "false");
    //create knowledge agent
    KnowledgeAgent kagent =
    KnowledgeAgentFactory.newKnowledgeAgent("AITS CEP Engine Agent",
    kbase, kagentConf);


    // apply change-set XML to knowledge agent
    kagent.applyChangeSet(ResourceFactory.newClassPathResource("changeset.xml"));

    //  get updated knowledge base object
    kbase = kagent.getKnowledgeBase();

    // create session
    session = kbase.newStatefulKnowledgeSession();


Can it be done in a more compact way?

Thank you! :)
Tina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100823/d52e2672/attachment.html 


More information about the rules-users mailing list