JBoss Community

Re: Run the sample JBPM process with java code, but i also want the process instance to be displayed on jBPM-console.

created by Krishna Pitla in jBPM Development - View the full discussion

hi maciej,

 

Sorry for the late reply. Thanks a lot for your response.

I have used the state nodes like human task in the process.

 

The java code that i use to run the process is as below:

package com.sample;

 

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.logger.KnowledgeRuntimeLoggerFactory;

import org.drools.runtime.StatefulKnowledgeSession;

import org.jbpm.process.workitem.wsht.CommandBasedWSHumanTaskHandler;

import org.jbpm.test.JBPMHelper;

 

/**

* This is a sample file to launch a process.

*/

public class ProcessMain {

 

    public static final void main(String[] args) throws Exception {

       

        // load up the knowledge base

        KnowledgeBase kbase = readKnowledgeBase();

        //StatefulKnowledgeSession ksession = JBPMHelper.newStatefulKnowledgeSession(kbase);

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

       

        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

       

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

        // start a new process instance

        ksession.startProcess("KrpiSample");

        System.out.println("Process started ...");

    }

 

    private static KnowledgeBase readKnowledgeBase() throws Exception {

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        kbuilder.add(ResourceFactory.newClassPathResource("Krpi_sample.bpmn"), ResourceType.BPMN2);

        return kbuilder.newKnowledgeBase();

    }

        

}

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community