Developing a workflow application with JBPM, relatively simply intuitive relative to using Shark. We have previously mentioned that the most basic components of a workflow management system include flow definition components, process execution components, and process client components. The following is a view from these three aspects, JBPM supports support for developing workflow applications.
Process definition
JBPM does not use the process definition language XPDL proposed by WFMC, but has developed a language called JPDL to define the process. Therefore, when developing an application, we finally need to generate a file processdefinition.xml that complies to this XML Schema to represent the defined process. It can be acquired by manually or automatically generates the visual definition tool.
JBPM provides an environment of development processes called Process Development Environment (PDE). You can execute the command ant create.pde in the JBPM root directory to generate a PDE work directory. The generated package structure is as follows:
The build.xml file is used to configure a process, which uses the ANT tool to parse the ProcessDefinition.xml file and store the relevant information required for the runflow to the database.
LIB stores all library files required for development and configuration flows, including JDBC drivers for the database.
SRC includes all source files and resources for development and configuration processes.
SRC / Config has only two files, JBPM.Properties and Log4j.properties. The JBPM.Properties file contains configuration information for the database. Therefore, the JDBC driver for replacing the database or database needs to be modified here.
SCR / Java stores Java source files.
SRC / Process stores workflow definition files (ProcessDefinition.xml) and related resource files such as images and form files.
SRC / TEST stores test code.
TARGET / CLASSES is the output directory of SRC / Java in the source code, stores compiled Class files.
Target / Par stores the PAR package generated by the command ant build.process.archives. The PAR package is actually packaged into ZIP forms in the SRC / Process.
TARGET / TEST-CLASSES stores the results of the test program.
TARGET / TEST-REPORT storage test report.
2. Execution of the process
JBPM packages the class library responsible for the execution process into jbpm.core.jar, which is also the core of the JBPM workflow engine. When developing a workflow application, simply put the JAR file below the corresponding lib directory. Developers can focus on developing a process model to complete the definition of the process without having to consider the details of the process execution.
3. Process client
The development of client components requires an application server as a servlet container, and we have selected Tomcat here. JBPM will develop a class required by WebApp into jbpm.web.jar, including custom TAG and Struts, and so on. When developing applications, the JAR is placed under Web-INF / LIB.
A workflow-based WebApp application is similar to the development of ordinary webapp. The package structure also maintains a consistent style:
Therefore, the main job we need to do is to complete the development of the JSP page required by the client application, you can use Struts to develop. It should be noted that we have to configure the JBPM.Properties file in the lib directory, mainly for database JDBC-driven configurations.
4. The creation of the system database
JBPM can support a variety of database systems, including MSSQL, Mysql, Oracle, HDBSQL, and more. It provides a flexible configuration, just modify the JBPM.Properties file, and copy the corresponding JDBC Driver to the lib directory. With the generate.ddl command of Ant, JBPM also supports automatically generating SQL scripts for creating system tables, and can generate scripts corresponding to various database systems, which is very convenient for database system replacement and system database creation. 5. Development process
The environment is configured as follows:
JBPM 2.0
Ant
1.6.2
Tomcat
5.0.27
SQL Server 2000
SQL Server 2000 Driver for JDBC
Take the Request a Payraise that is previously demonstrated as an example (see below), introduce the work that uses JBPM to develop a workflow application needs to be completed.
1) First, we need to complete the definition of the process. This includes not only defining processdefinition.xml, but also defines other resources used in the process execution. For example, the pictures, form, etc. used in web applications. You also need to configure form.xml, which determines different status and FORM relationships in the process, such as the request A Payraise state, you need the form:
Supplement ProcessDefinition.xml
Example:
XML Version = "1.0" encoding = "UTF-8"?>
3) We don't have to care about how will it be carried out, just give it to jbpm.core.jar.
4) The remaining additional a more heavy work is to develop a client application for the process. As mentioned earlier, the main job we need to do is to complete the development of the JSP page required for client applications. Including the login page, view your Tasklist page, perform Task's pages, etc. In addition, the logging and management interface of the process can be completed through the log. These are determined by the needs of the application.