HelloProcess Example using JBPM5 Eclipse Plug-in
Posted by bpmn2user in bpmn2 user's Blog on Feb 27, 2011 4:03:33 PMHere is an example that shows the required steps to create a HelloWorld example with jBPM5 plug-in in Eclipse.
First install jBPM5 plugin using the steps (http://community.jboss.org/people/bpmn2user/blog/2011/02/27/eclipse-plug-in-installation-for-jbpm5) or using the install script (http://kverlaen.blogspot.com/2011/01/jbpm-50-released.html).
A simple example (http://people.redhat.com/kverlaen/jBPM5-guvnor-integration.swf) is considered here to show the features of jBPM5 eclipse plug-in.
'Hello Task' is created as follows. Attached files (HelloProcess.bpmn, HelloTask.ftl and Hello.ftl) can be imported into the HelloProcess project created in http://community.jboss.org/people/bpmn2user/blog/2011/02/27/eclipse-plug-in-installation-for-jbpm5.
The user form for the task 'HelloTask' is created using the pattern {TaskName}.ftl as shown below.
The 'HelloProcessTest.java' is created to read the 'HelloProcess.bpmn' file as shown below (also find the complete file as an attachement below):
public class HelloProcessTest {
public static final void main(String[] args) {
try {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
/*
* Add the required users
*/
TaskServiceSession taskSession = taskService.createSession();
taskSession.addUser(new User("Administrator"));
taskSession.addUser(new User("krisv"));
/* Start Mina server for HT*/
MinaTaskServer server = new MinaTaskServer(taskService);
Thread thread = new Thread(server);
thread.start();
System.out.println("Server started ...");
/*Create the knowledge base for HelloProcss.bpmn */
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = createSession(kbase);
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "testlog", 1000);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
System.out.println(" started the humantask");
ksession.startProcess("Hello");
logger.close(); }
Select the 'Human Task View' using Window->ShowView->Drools Task->Human Task View. Start the program 'HelloProcessTest.java' and look for the tasks using the userID 'krisv'. 'Hello Task' can then be selected to perform tasks such as 'Start', 'Complete' etc.
-
HelloTask.ftl.zip 278 bytes
-
Hello.ftl.zip 285 bytes
-
HelloProcess.bpmn.zip 1.1 KB
-
HelloProcessTest.java.zip 1.3 KB
Comments