Helloword instances of the JBPM API

Source: Internet
Author: User
Tags jbpm

1. Create a new JBPM project

2. Under the SRC directory

Create a new HelloWorld package to import the following five files: helloworld.jpdl.xml

<?xml version= "1.0" encoding= "UTF-8"?>

<?xml version= "1.0" encoding= "UTF-8"? ><process name= "HelloWorld" xmlns= "HTTP://JBPM.ORG/4.4/JPDL" >   <start name= "Start1" g= "66,16,48,48" >      <transition name= "to submit Application" to= "Submit Request" g= "   -71,-17"/> </start>   <end name= "End1" g= "66,348,48,48"/> <task   name= "Submit a Request" g= "44,96,92,52" assignee= "employee" >      <transition name= "to department manager approval" to= "department manager approval" g= " -95,-17"/>   </task>   <task name= "department manager approval" G = "44,180,92,52" assignee= "department manager" >      <transition name= "to general manager approval" to= "general manager Approval" g= " -83,-17"/> </task   >   <task name= "general manager Approval" g= "44,264,92,52" assignee= "General Manager" >      <transition name= "to End1" to= "End1" g= "- 47,-17 "/>   </task></process>


Helloworld.png


Jbpm.cfg.xml

<?xml version= "1.0" encoding= "UTF-8"?><jbpm-configuration> <import  resource= " Jbpm.default.cfg.xml "/>  <import resource=" Jbpm.businesscalendar.cfg.xml "/> <import resource=  "Jbpm.tx.hibernate.cfg.xml"/>  <import resource= "Jbpm.jpdl.cfg.xml"/> <import resource=  " Jbpm.bpmn.cfg.xml "/>  <import resource=" Jbpm.identity.cfg.xml "/>  <!--Job Executor is excluded For running the example test cases.  -<!--to enable timers and messages in production with, this should is included-  <!--  <im Port resource= "Jbpm.jobexecutor.cfg.xml"/>  --></jbpm-configuration>

Jbpm.hibernate.cfg.xml

<?xml version= "1.0" encoding= "Utf-8"? ><! DOCTYPE hibernate-configuration Public "-//hibernate/hibernate configuration DTD 3.0//en" "Http://hibern       Ate.sourceforge.net/hibernate-configuration-3.0.dtd ">
Please change the relevant configuration information here

Log4j.properties

# # # Direct log messages to stdout # # #log4j. appender.stdout= org.apache.log4j.consoleappenderlog4j.appender.stdout.target=system.outlog4j.appender.stdout.layout= Org.apache.log4j.patternlayoutlog4j.appender.stdout.layout.conversionpattern=%d{absolute}%5p%c{1}:%L-%m%n### Direct messages to File Hibernate.log # # # #log4j. appender.file=org.apache.log4j.fileappender# log4j.appender.file.file=hibernate.log#log4j.appender.file.layout=org.apache.log4j.patternlayout#  Log4j.appender.file.layout.conversionpattern=%d{absolute}%5p%c{1}:%l-%m%n### set log levels-for more verbose logging Change ' info ' to ' Debug ' # # #log4j. Rootlogger=error, stdout#log4j.logger.org.hibernate=info# log4j.logger.org.hibernate=debug### Log HQL Query parser activity#log4j.logger.org.hibernate.hql.ast.ast=debug### Log just the sql#log4j.logger.org.hibernate.sql=debug### log JDBC bind parameters # # # #log4j. logger.org.hibernate.type= info#log4j.logger.org.hibernate.type=debug### Log Schema Export/update # # # #log4j. logger.org.hibernate.tool.hbm2ddl=debug### log HQL Parse trees#log4j.logger.org.hibernate.hql=debug### log Cache Activity # # # log4j.logger.org.hibernate.cache=debug### Log Transaction activity#log4j.logger.org.hibernate.transaction=debug## # log JDBC Resource acquisition#log4j.logger.org.hibernate.jdbc=debug### enable the following line if you want WN Connection ###### leakages when using Drivermanagerconnectionprovider # # # Log4j.logger.org.hibernate.connection.drivermanagerconnectionprovider=trace

2. Build JBPM environment, that is, import the corresponding jar package, not listed here, if you want to, please comment, and privately talk about my

3. Create a new package, such as Hellowordapi

and create a new class under this package, as follows

Package Cn.itcast.oa_hellowordapi;import Java.util.list;import Org.jbpm.api.configuration;import Org.jbpm.api.processengine;import Org.jbpm.api.task.task;import Org.junit.test;public class HelloWord_API {private        Static Processengine processengine=new Configuration (). Setresource ("Jbpm.cfg.xml"). Buildprocessengine ();//Build Table @Test Ddl.auto=update public void Createschema () throws exception{new Org.hibernate.cfg.Configuration ()//. Configure (" Jbpm.hibernate.cfg.xml "). Buildsessionfactory (); }//deployment process definition @testpublic void deployprocessdefinition () throws Exception {Processengine.getrepositoryservice (). Createdeployment ()//.addresourcefromclasspath ("Helloword/helloworld.jpdl.xml"). Addresourcefromclasspath (" Helloword/helloworld.png "). deploy ();} Start the process instance @Test public void Startprocessinstance () throws Exception {Processengine.getexecutionservice (). Startprocessi   Nstancebykey ("HelloWorld"); }//Query My personal task List @testpublic void Findmypersonaltasklist () throws Exception {String userid1= "employee";//sTring userid2= "department manager";//string userid3= "General manager"; System.out.println ("---------" +userid1+ "--------"); List<task> Tasks=processengine.gettaskservice (). Findpersonaltasks (USERID1); for (Task Task:tasks) { System.out.println (Task.getid () + "---" +task.getname () + "-----" +task.getassignee ());}} Handle Task @testpublic void Compeletetask () throws Exception {String userid= "10009";p rocessengine.gettaskservice (). Completetask (userId);}}

Run Tests to

Helloword instances of the JBPM API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.