[jboss-dev-forums] [jBPM Development] - Re: [jbpm 5.0] Dynamic process creation
Stephen McConnell
do-not-reply at jboss.com
Tue Jan 3 09:18:39 EST 2012
Stephen McConnell [http://community.jboss.org/people/zino] created the discussion
"Re: [jbpm 5.0] Dynamic process creation"
To view the discussion, visit: http://community.jboss.org/message/644382#644382
--------------------------------------------------------------
Atul:
I have absolutly no idea if this will be useful or not - but for what it's worth, I found the following fragment of code under a samples package.
I've hilighted the lines that may help.
> package org.jbpm.bpmn2;
> import org.drools.KnowledgeBase;
> import org.drools.builder.KnowledgeBuilder;
> import org.drools.builder.KnowledgeBuilderFactory;
> import org.drools.builder.ResourceType;
> import org.drools.io.ResourceFactory;
> import org.drools.runtime.StatefulKnowledgeSession;
> import org.jbpm.bpmn2.xml.XmlBPMNProcessDumper;
> import org.jbpm.ruleflow.core.RuleFlowProcess;
> import org.jbpm.ruleflow.core.RuleFlowProcessFactory;
> public class ProcessFactoryTest extends JbpmJUnitTestCase {
>
> public void testProcessFactory() {
> RuleFlowProcessFactory factory = RuleFlowProcessFactory.createProcess("org.jbpm.process");
> factory
> // header
> .name("My process").packageName("org.jbpm")
> // nodes
> .startNode(1).name("Start").done()
> .actionNode(2).name("Action")
> .action("java", "System.out.println(\"Action\");").done()
> .endNode(3).name("End").done()
> // connections
> .connection(1, 2)
> .connection(2, 3);
> RuleFlowProcess process = factory.validate().getProcess();
> * KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();*
> * kbuilder.add(ResourceFactory.newByteArrayResource(*
> * XmlBPMNProcessDumper.INSTANCE.dump(process).getBytes()),*
> * ResourceType.BPMN2);*
> * KnowledgeBase kbase = kbuilder.newKnowledgeBase();*
> * StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();*
> * ksession.startProcess("org.jbpm.process");*
> }
>
Please let me know how this goes.
If it works then it needs to be included in the User's Guide (or perhaps an equivalent that uses a nice utility method that keeps some of the noise out of the picture).
Cheers, Steve.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/644382#644382]
Start a new discussion in jBPM Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2035]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20120103/ef25b8af/attachment.html
More information about the jboss-dev-forums
mailing list