Activiti configuration instance and Spring integrated configuration, activitispring

Source: Internet
Author: User

Activiti configuration instance and Spring integrated configuration, activitispring


Public class TestDB {public static void main (String [] args) {// 1. Create the Activiti configuration object instance ProcessEngineConfiguration configuration = ProcessEngineConfiguration. createStandaloneProcessEngineConfiguration (); // 2. set database connection information // set database address configuration. setJdbcUrl ("jdbc: mysql: // localhost: 3306/activiti_test? CreateDatabaseIfNotExist = true "); // database driver configuration. setJdbcDriver ("com. mysql. jdbc. driver "); // user name configuration. setJdbcUsername ("root"); // password configuration. setJdbcPassword ("123456"); // sets the database table creation policy (no table creation by default) configuration. setDatabaseSchemaUpdate (ProcessEngineConfiguration. DB_SCHEMA_UPDATE_TRUE); // 3. use the configuration object to create a process engine instance (check whether the environment information such as database connection is correct) ProcessEngine processEngine = configuration. buildProcessEngine (); System. out. println (processEngine );}
Public void testDBByProperties () throws Exception {// 1. Load the activiti. cfg. xml file named "classpath" and create the ProcessEngine processEngine = ProcessEngineConfiguration.
CreateProcessEngineConfigurationFromResource ("activiti. cfg. xml ").
BuildProcessEngine (); System. out. println (processEngine); // or private ProcessEngine processEngine = ProcessEngines. getdefadefaprocessengine (); this method is the same as above by default }}

Activiti. cfg. xml

<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: context = "http://www.springframework.org/schema/context" xmlns: tx = "http://www.springframework.org/schema/tx" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http: // Composer http://www.springframework.org/schema/tx/spring-tx-3.0.xsd "> <bean id =" processEngineConfiguration "class =" org. activiti. engine. impl. cfg. StandaloneProcessEngineConfiguration "> <! -- Database connection configuration --> <property name = "jdbcUrl" value = "jdbc: mysql: // localhost: 3306/activiti_test? CreateDatabaseIfNotExist = true "> </property> <property name =" jdbcDriver "value =" com. mysql. jdbc. driver "> </property> <property name =" jdbcUsername "value =" root "> </property> <property name =" jdbcPassword "value =" mikesirius "> </property> <! -- Create a table policy --> <property name = "databaseSchemaUpdate" value = "true"> </property> </bean> </beans>

Spring Integration

<Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: context = "http://www.springframework.org/schema/context" xmlns: tx = "http://www.springframework.org/schema/tx" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http: // Consumer http://www.springframework.org/schema/tx/spring-tx-3.0.xsd "> <bean id =" processEngineConfiguration "class =" org. activiti. spring. SpringProcessEngineConfiguration "> <! -- Data source --> <property name = "dataSource" ref = "dataSource"/> <! -- Configure the Transaction Manager and unify the transaction --> <property name = "transactionManager" ref = "transManager"/> <! -- Set the table creation policy --> <property name = "databaseSchemaUpdate" value = "true"/> </bean> <bean id = "processEngine" class = "org. activiti. spring. processEngineFactoryBean "> <property name =" processEngineConfiguration "ref =" processEngineConfiguration "/> </bean> <! -- Bean id repositoryService RepositoryServicie repositoryService = processEngine. getRepositoryService (); --> <bean id = "repositoryService" factory-bean = "processEngine" factory-method = "getRepositoryService"/> <bean id = "runtimeService" factory-bean = "processEngine" factory -method = "getRuntimeService"/> <bean id = "taskService" factory-bean = "processEngine" factory-method = "getTaskService"/> <bean id = "hi StoryService "factory-bean =" processEngine "factory-method =" getHistoryService "/> <bean id =" formService "factory-bean =" processEngine "factory-method =" getFormService "/> <! -- Process-related Service --> <bean id = "workflowService" class = "activitiweb. service. impl. workflowServiceImpl "> <property name =" repositoryService "ref =" repositoryService "> </property> <property name =" runtimeService "ref =" runtimeService "> </property> <property name = "taskService" ref = "taskService"> </property> <property name = "formService" ref = "formService"> </property> <property name = "historyService" ref = "historyService"> </property> </bean> </beans>

 

Core API Introduction

  1. ProcessEngine

The most core class in Activiti, and other classes are from him.

ProcessEngine processEngine = ProcessEngines. getdefaprocesprocessengine ();

The following Service can be generated through the get of processEngine

RepositoryService

Management Process Definition

RuntimeService

Execution Management, including starting, advancing, and deleting process instances

TaskService

Task Management

HistoryService

History Management (Management of executed data)

IdentityService

Organization Management

FormService

An optional service for task form Management

ManagerService

 

  2. RepositoryService

Is the repository service class of Activiti. The so-called repository refers to two files in the process definition document: bpmn files and process images.

  3. RuntimeService

Is the process execution service class of activiti. You can obtain a lot of information about process execution from this service class.

  4. TaskService

Is the Task Service class of activiti. You can obtain task information from this class.

  5. ProcessDefinition

Process Definition class. You can obtain resource files from here.

  6. ProcessInstance

The execution instance of the process definition. For example, if Fan Bingbing takes a day off, she must apply for a process instance. A process instance includes all running nodes. We can use this object to learn the progress and other information of the current process instance.

From the source code, we can see that ProcessInstance is Execution, and ProcessInstance inherits Execution.

 7. Execution

Activiti uses this object to describe every node in the process execution. In the case of no concurrency, it is the same as ProcessInstance.

 

The Activiti core configuration file configures the basic parameters of the Process Engine creation tool and the database connection pool parameters.

Define database configuration parameters:

JdbcUrl: The jdbc url of the database.

JdbcDriver: Drivers for different database types.

JdbcUsername: The username used to connect to the database.

JdbcPassword: Password used to connect to the database.

Database connections configured based on JDBC parameters use the defaultMyBatisConnection Pool. The following parameters can be used to configure the connection pool (from the MyBatis parameter ):

JdbcMaxActiveConnections: The maximum value of connections in the active state in the connection pool. The default value is 10.

JdbcMaxIdleConnections: Maximum number of idle connections in the connection pool.

JdbcMaxCheckoutTime: The maximum time the connection is taken out. If it exceeds the time limit, it will be forcibly recycled. The default value is 20000 (20 seconds ).

JdbcMaxWaitTime: This is an underlying configuration, so that the connection pool can print a log and try again to obtain a connection when the connection cannot be obtained for a long time. (Avoid silent operation failures due to misconfiguration ). The default value is 20000 (20 seconds ).

 

    


How to integrate activiti with springmvc

This is caused by your upgrade to 5.15.
The consequence of the upgrade is java. lang. ClassNotFoundException: org. activiti. validation. ProcessValidator.
No problem with upgrading in maven format
I have a rough look at the solution to this problem on the official website. I want to use the solution version 5.15.1 to solve this BUG.

Www.activiti.org/download.html

Key configurations of Spring integration with Hibernate

It is mainly spring to manage hibernate and configure hibernate in spring configuration;

<! --
Annotation declares the transaction management transaction-manager = "txManager says who is the person who manages the transaction
-->
<Tx: annotation-driven transaction-manager = "txManager"/>

<! -- Definition of annotation of a plane -->
<Aop: aspectj-autoproxy/>

<! --
Bind a new Hibernate Session instance, close and remove the <bean
Id = "hibernateInterceptor"
Class = "org. springframework. orm. hibernate3.HibernateInterceptor">
<Property name = "sessionFactory"> <ref bean = "sessionFactory"/>
</Property> </bean>
-->

<Bean id = "sessionFactory"
Class = "org. springframework. orm. hibernate3.LocalSessionFactoryBean">
<Property name = "configLocation" value = "classpath: hibernate. cfg. xml">
</Property>
</Bean>
<! -- Manage things -->
<Bean id = "txManager"
Class = "org. springframework. orm. hibernate3.HibernateTransactionManager">
<Property name = "sessionFactory" ref = "sessionFactory"/>
</Bean>
This is the key Configuration

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.