JBPM Learning (a)--integration with SSH

Source: Internet
Author: User
Tags aop config xmlns zip ssh jboss mysql database jbpm


Learn jbpm before you learn about JBPM.


Encyclopedia:
JBPM, the full name is the Java Business Process Management (orchestration Management), which covers business process management, workflow, service
An open-source, flexible, and extensible executable process language framework in areas such as collaboration. JBPM is a public source code project that uses it to follow
ASL (Apache License Version 2.0) and the EULA (JBoss End User License Agreement) agreement.


JBPM Features
Is that its business logic definition does not employ some of the current specifications, such as Wfmc´s XPDL, BPML, EbXML, BPEL4WS, etc., but uses
Its own definition of JBoss JBPM Process definition Language (JPDL). JPDL that a business process can be seen as a
UML State diagram. JPDL is a detailed definition of each part of the state diagram, such as the start, end state, and the transitions between States, through the pattern
Process definition and visually describe the business process.


Another feature of JBPM is that it uses Hibernate to manage its database. Hibernate is one of the most popular data stores in the Java World at present.
Tier solution, JBPM is supported as long as it is a database supported by Hibernate. Separation of data management functions through HIBERNATE,JBPM
Go out and focus on the handling of business logic.


Work flow


1) JBPM operation requires database support, so the system is designed with the database selected. As long as it is a database supported by Hibernate, JBPM
is supported. The initialization of the database can be done automatically by JBPM, or SQL statements can be generated from the Ant generate.ddl task, jbpm externally from
Create the required tables.
2) Use JPDL to define the workflow and generate the Processdinination.xml file. GUI tools can be used GPDL, but currently only supports jBPM1.0,
And a lot of bugs. The DTD definition file for XML is in the JBPM download package.
3) Ant CREATE.PDE generates a working directory of PDE packages. Place the Processdinination.xml file and other required files in the specified directory
, use ant build.precess.archives to generate PDE packages. The format of the PDE package takes the jar.
4) Change the relevant properties of the PDE working directory/src/config/jbpm.properties, mainly to set the relevant database connection information. Note To add
The JDBC driver for the database is placed in the Lib directory of the PDE working directory.
5) Ant Deploy.process.archives deploys the PDE just generated to the database. is actually inserting some relevant data into the database.
6) Develop the appropriate workflow using the JBPM API function.








JBPM Official website: http://www.jboss.org/jbpm/
Download Link: http://sourceforge.net/projects/jbpm/files/






My project is built using the SSH framework. The project has been set up before talking about the jbpm.
On this basis we integrate JBPM into my project.


One, download the JBPM jar package.
Download Link: http://sourceforge.net/projects/jbpm/files/
I am using jbpm4.4 this version, should be relatively stable for this version, and the corresponding data on the Internet is also very good to find.
After unpacking, look at the directory structure:


Doc: Inside is the relevant document. Includes development wizards, APIs, and user wizards.


Examples: a sample.


Install: Installation script (this is important).


Lib: third-party jar package.


SRC:JBPM the source code. (This source is actually less than the file in the Jbpm.jar package, it should be the core source code bar)


Jbpm.jar:JBPM's jar Package


******************************************************************************
The following is a detailed view of the install directory.
Downloads: Empty.
JDBC: A sample of the properties file for the linked database configuration (link database string) is given in this directory, for example, if we make
With MySQL database,

Mysql.properties File Contents:


Jdbc.driver=com.mysql.jdbc.driver
Jdbc.url=jdbc:mysql://localhost:3306/jbpmdb
jdbc.username=jbpm
jdbc.password=jbpm
Understand one and know what other documents are for.


SRC: This directory gives scripts for creating databases, jbpm configuration files, and using Hibernate configuration in different databases
Different data sources and use Hibernate files and use various samples under the spring configuration. In short, you are using Hibernate and spring
When you want to configure the data source, in various ways, this directory has a template. There are also configuration of logs and messages. The GPD catalogue is
Eclipse
Plug-in package.


Build.xml:ant the build file.


********************************************************************************
All that should be said is about knowing, and now add the jar package and introduce it to the classpath.


Second, install the Eclipse plugin.
Find Jbpm-gpd-site.zip under the JBPM-4.4\INSTALL\SRC\GPD.
Find the menu help, Install new software in Eclipse.
Click the Add button, pop-up box, name to write, click Archive. button to find the Jbpm-gpd-site.zip.
Restart eclipse after installation.
JBoss JBPM can be seen in the menu, window->preferences.




Three, create the database.
You can see 4 folders under Jbpm-4.4\install\src\db:
create,drop,upgrade-4.0-to-4.1,upgrade-4.1-to-4.2.
Each directory corresponds to a hsqldb,mysql,oracle,postgresql script.


I'm going to use MySQL database to find the Jbpm.mysql.create.sql file under Create and put the
SQL execution. This creates the tables that you need. You can write some data to the table first, there is a Jbpm-4.4\install\src\demo
Example.identities.sql is the script that inserts the test data


From the picture above, we can see that there are 18 sheets.
What are these tables for?
From the Internet to find some information, first do a bit of understanding, and then detailed study:


--------------------------------------------------------------------------


1 resource pool and run-time table structure:


JBPM4_DEPLOYMENT,JBPM4_DEPLOYPROP,JBPM4_LOB storage Process Definition related deployment information
Jbpm4_execution is mainly to store the execution information of JBPM4, execution mechanism instead of JBPM3 token mechanism
Jbpm4_task Store A activities (activity) that requires a person to complete, and activities that require a person to participate in the completion are called task
Jbpm4_participation participant table, store participant information, type of participant
Candidate, Client, Owner, replaced assignee, and viewer.
The specific participant can be either a single user or a user group


Jbpm4_swimlane swimlane table. Swimlane is a runtime Process Role.
With Swimlane, multiple tasks can be assigned to the same actor at once


Jbpm4_job is the definition of a timer.
Jbpm4_variable is the temporary variable at the time of the occurrence.


2 Historical database table structure:


Jbpm4_hist_procinst and Jbpm4_hist_actinst Store The history of process instance and activity instance respectively
Jbpm4_hist_detail Save variable Change record
Jbpm4_hist_var Save Historical variables Jbpm4_hist_task TASK history information


3 Authentication Table Structure


Jbpm4_id_group, Jbpm_id_membership, jbpm4_id_user these three sheets are very common,
Basic permissions control, on the user certification aspects of the recommendations or develop a set of self-contained components, the function is too simple,
There are many requirements in use that are difficult to meet


In addition to the 17 tables mentioned above, there is also an engine parameter table, which is a separate table, which is not listed separately in this paper.




--------------------------------------------------------------------------








Four, configure the jbpm.


First give me the engineering structure and spring configuration.


Applicationcontext.xml

<?xml version= "1.0" encoding= "UTF-8"?> <beans xmlns= "Http://www.springframework.org/schema/beans" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP" xmlns:tx= " Http://www.springframework.org/schema/tx "xsi:schemalocation=" Http://www.springframework.org/schema/beans HT Tp://www.springframework.org/schema/beans/spring-beans-2.0.xsd Http://www.springframework.org/schema/tx http://w Ww.springframework.org/schema/tx/spring-tx-2.0.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP HTTP://WWW.SPRINGFR Amework.org/schema/aop/spring-aop-2.0.xsd Http://www.springframework.org/schema/context Http://www.springframewo Rk.org/schema/context/spring-context-2.5.xsd "> <bean id=" propertyconfigurer "class=" Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer "> <property name=" Locations "> &lt ;list> <value>classpath:configure.properties</value> </list> </property> </bean> <bean id= "sessionfactory" class= "Org.springframew Ork.orm.hibernate3.LocalSessionFactoryBean "> <property name=" hibernateproperties "> <props> <pro P key= "Hibernate.dialect" >${hibernate.dialect}</prop> <prop key= "Hibernate.query.substitutions" > true=1,false=0</prop> <prop key= "hibernate.jdbc.batch_size" >25</prop> <prop key= "hibernate.sh Ow_sql ">true</prop> <prop key=" Hibernate.format_sql ">false</prop> <prop key=" Hibernate.gen Erate_statistics ">false</prop> <prop key=" Hibernate.cache.use_query_cache ">false</prop> < Prop key= "Hibernate.cache.region_prefix" >direct</prop> <prop key= "Hibernate.cache.use_structured_
				Entries ">false</prop> <prop key=" Hibernate.cache.provider_class ">org.hibernate.cache.ehcachep Rovider</prop> <prop Key= "Hibernate.query.factory_class" >org.hibernate.hql.ast.astquer ytranslatorfactory</prop> <prop key= "Hibernate.transaction.factory_class" >org.hibernate.transacti on. Jdbctransactionfactory</prop> <!--automatically create tables-<!--<prop key= "Hibernate.hbm2ddl.auto" & Gt;update</prop>-</props> </property> <property name= "DataSource" ref= "data Source "/> <property name=" mappinglocations "> <list> <value>classpath:/org/first/c
	       Onfig/lsyuser.hbm.xml</value> <value>classpath:/org/second/config/LsyDep.hbm.xml</value> </list> </property> </bean> <bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPool Eddatasource "destroy-method=" Close "> <property name=" maxpoolsize "value=" ${c3p0.maxpoolsize} "/> <prope Rty name= "minpoolsize" value= "${c3p0.minpoolsize}"/> <property Name= "MaxIdleTime" value= "${c3p0.maxidletime}"/> <property name= "maxstatements" value= "${c3p0.maxStatements} "/> <property name=" acquireincrement "value=" ${c3p0.acquireincrement} "/> <property name=" Idleconnectiontestperiod "value=" ${c3p0.idleconnectiontestperiod} "/> <property name=" DriverClass "value=" ${ Jdbc.driverclassname} "/> <property name=" Jdbcurl "value=" ${jdbc.url} "/> <property name=" user "value=" ${ Jdbc.username} "/> <property name=" password "value=" ${jdbc.password} "/> </bean> <bean id=" Jdbctem Plate "class=" org.springframework.jdbc.core.JdbcTemplate "> <property name=" DataSource "> <ref bean= "DataSource"/> </property> </bean> <bean id= "TransactionManager" class= "org.sp Ringframework.orm.hibernate3.HibernateTransactionManager "> <property name=" sessionfactory "ref=" Sessionfactory "/> </bean> <bean id=" TransactionproxytemPlate "class=" Org.springframework.transaction.interceptor.TransactionProxyFactoryBean "abstract=" true "> < Property Name= "TransactionManager" ref= "TransactionManager"/> <property name= "Transactionattributes" > < props> <prop key= "query*" >PROPAGATION_REQUIRED</prop> <prop key= "*" >propagation_required</ prop> </props> </property> </bean> <!--feature Module Introduction--<import resource= "classpath:/ Org/first/config/context_first.xml "/> <import resource=" Classpath:/org/second/config/context_second.xml "/
 > </beans>

Configure.properties

# applicationcontext.xml #

# c3p0 Connection Pool
c3p0.maxpoolsize=3
c3p0.minpoolsize=1
c3p0.maxidletime=1800
c3p0.maxstatements=0
c3p0.acquireincrement=2
c3p0.idleconnectiontestperiod=

#oracle  
#jdbc. Driverclassname=oracle.jdbc.driver.oracledriver
#jdbc. url=jdbc:oracle:thin:@ 10.55.15.66:1521:cdbank
#jdbc. username=ccdb
#jdbc. password=ccdb
#hibernate. dialect= Org.hibernate.dialect.Oracle9Dialect

#mysql
jdbc.driverclassname=com.mysql.jdbc.driver
jdbc.url =jdbc:mysql://127.0.0.1:3306/mydb
jdbc.username=root
jdbc.password=root
hibernate.dialect= Org.hibernate.dialect.MySQLInnoDBDialect

Now start modifying the configuration.
1. Add the Jbpm.cfg.xml configuration file in the source folder as follows:

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

<jbpm-configuration>

  <import resource= " Jbpm.default.cfg.xml "/>
  <import resource=" Jbpm.tx.spring.cfg.xml "/> <import
  resource=" Jbpm.jpdl.cfg.xml "/>
  <import resource=" Jbpm.bpmn.cfg.xml "/> <import
  resource=" Jbpm.identity.cfg.xml "/>
  <import resource=" jbpm.businesscalendar.cfg.xml "/> <import resource
  = "Jbpm.console.cfg.xml"/>
  <import resource= "Jbpm.jobexecutor.cfg.xml"/>
  
  < process-engine-context>
    <string name= "spring.cfg" value= "Applicationcontext.xml"/>
  </ Process-engine-context>

</jbpm-configuration>

This can be found under the JBPM-4.4\INSTALL\SRC\CFG\JBPM path Spring.jbpm.cfg.xml.
In this file is the above content.


2. Modify the spring Applicationcontext.xml file.
Increase:

<!--jbpm Start-to
	<bean id= "Springhelper" class= "Org.jbpm.pvm.internal.processengine.SpringHelper"/ >

    <bean id= "Processengine" factory-bean= "Springhelper" factory-method= "Createprocessengine"/>
	<!--jbpm end-->

Above is the Applicationcontext.xml file under the reference jbpm-4.4\install\src\cfg\spring.
Note that there are some differences inside, there is a configuration about sessionfactory as follows;

  <bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
    < Property Name= "Configlocation" value= "Classpath:jbpm.hibernate.cfg.xml"/>
    <property name= "DataSource" ref= "DataSource"/>
  </bean>

That is, Sessionfactory's configuration has been put into the classpath:jbpm.hibernate.cfg.xml alone.
We can do this, single I am accustomed to using the properties file configuration (as above).
This jbpm.hibernate.cfg.xml is actually the file that we configure hibernate with,
We have also provided a lot of templates under Jbpm-4.4\install\src\cfg\hibernate, and we can find the configuration of the template and change it to our own according to whether we use spring and how to configure the data source.


Note here that we use the properties file to configure the sessionfactory, comparing the given template to the
<mapping resource= "Jbpm.repository.hbm.xml"/>
<mapping resource= "Jbpm.execution.hbm.xml"/>
<mapping resource= "Jbpm.history.hbm.xml"/>
<mapping resource= "Jbpm.task.hbm.xml"/>
<mapping resource= "Jbpm.identity.hbm.xml"/>
The above 5 Xxx.hbm.xml must be introduced into Hibernate, these files are already in the jar package, we just need to configure Sessionfactory
Can be introduced when:


	<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" > <property Name= "Hibernateproperties" > <props> <prop key= "Hibernate.dialect" >${hibernate.dialect}</prop > <prop key= "hibernate.query.substitutions" >true=1,false=0</prop> <prop key= "HIBERNATE.JDBC.BATC H_size ">25</prop> <prop key=" Hibernate.show_sql ">true</prop> <prop key=" hibernate.format_s QL ">false</prop> <prop key=" Hibernate.generate_statistics ">false</prop> <prop key=" Hiberna Te.cache.use_query_cache ">false</prop> <prop key=" Hibernate.cache.region_prefix ">direct</prop > <prop key= "hibernate.cache.use_structured_entries" >false</prop> <prop key= "hibernate.cache.pr Ovider_class ">org.hibernate.cache.EhCacheProvider</prop> <prop key=" Hibernate.query.factory_class " >org.hibernate.hql.ast.astquerytranslatorfactory</prop> <prop key= "Hibernate.transaction.factory_class" > Org.hibernate.transaction.jdbctransactionfactory</prop> <!--automatically create tables-<!--<prop Key = "Hibernate.hbm2ddl.auto" >update</prop> </props> </property> <property name= "D Atasource "ref=" DataSource "/> <property name=" mappinglocations "> <list> <value >classpath:/org/first/config/LsyUser.hbm.xml</value> &LT;VALUE&GT;CLASSPATH:/ORG/SECOND/CONFIG/LSYDEP. Hbm.xml</value> <value>classpath:jbpm.repository.hbm.xml</value> <valu
	         E>classpath:jbpm.execution.hbm.xml</value> <value>classpath:jbpm.history.hbm.xml</value> <value>classpath:jbpm.task.hbm.xml</value> <value>classpath:jbpm.identity.hbm.xml</
value> </list> </property> </bean> 


I will continue to do a test module to initially use the JBPM development process




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.