[jboss-user] [jBPM] - Re: Instantiating the KnowledgeBase

vasiliki oikonomidou do-not-reply at jboss.com
Fri Mar 4 03:02:08 EST 2011


vasiliki oikonomidou [http://community.jboss.org/people/voikonomidou] created the discussion

"Re: Instantiating the KnowledgeBase"

To view the discussion, visit: http://community.jboss.org/message/591097#591097

--------------------------------------------------------------
Hi Julio,

If you want to upload a knowledge base which includes the process definitions from guvnor repository the code you require is the following:

ProcessBuilderFactory.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());
ProcessMarshallerFactory.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());        ProcessRuntimeFactory.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());
BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());        

KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);       
        kagent.applyChangeSet( 
                ResourceFactory.newUrlResource(
                " http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor"
                + "/package/defaultPackage/LATEST/ChangeSet.xml")); 


And then you take the knowledgeBase from the KnowledgeAgent like this :
KnowledgeBase kbase = kagent.getKnowledgeBase();

In order to take the process you want from within the knowledgeBase you create a knowledgeSession :
 StatefulKnowledgeSession ksession =
                    JPAKnowledgeService.newStatefulKnowledgeSession(kbase, config, env);

And finally something like  "ksession.getProcessInstances()" will gine you the collection of all the processes that lie inside the guvnor repository.

Regards,

Vasiliki.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/591097#591097]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110304/3d361a4e/attachment.html 


More information about the jboss-user mailing list