Download presentation
Presentation is loading. Please wait.
Published byAubrey Whitehead Modified over 8 years ago
1
Getting Activiti to “Talk” to an External Database Koorosh Vakhshoori Software Architect/Senior developer at Synopsys Inc.
2
Getting Activiti to “Talk” to an External Database Koorosh Vakhshoori Software Architect/Senior developer at Synopsys Inc.
3
Synopsys Inc. Provider of best-in-class solutions enabling designers to accelerate the creation and verification of complex integrated circuits (IC) and system-on-chip (SoC) designs from concept to silicon.
4
Use Cases (Insert/Update) Reporting Logging Dashboard
5
Use Cases (Retrieve) Populating some form field Signal for action or NO action Photo from Flickr by carterse
6
Simple Article Review Workflow
8
Do Not Reinvent the Wheel! Alfresco framework Other open source components Photo from Flickr by Balaji.B
9
Components Alfresco framework alfresco-global.properties Spring framework Dependency injection JdbcTemplate Activiti Listener Service task
10
Components Alfresco framework alfresco-global.properties Spring framework Dependency injection JdbcTemplate Activiti Listener Service task
11
alfresco-global.properties ### database connection properties ### external_db.driver=org.gjt.mm.mysql.Driver external_db.username=activiti_app external_db.password=activiti_password external_db.name=ext_db external_db.url=jdbc:mysql://localhost:3306/ext_db?useUnicode=yes &characterEncoding=UTF-8
12
Dependency Injection - 1 <bean id=“extDataSource“ class="org.apache.commons.dbcp.BasicDataSource“ destroy-method="close"> <property name="driverClassName“ value="${external_db.driver}"/>
13
Dependency injection - 2 <bean id="AbstractUserTaskDelegate“ parent="baseJavaDelegate" abstract="true“ depends-on="activitiBeanRegistry"/> <bean id="LogActionClass" parent="AbstractUserTaskDelegate" class="com.example.activiti.workflow.LogActionListener">
14
Listener Code package com.example.workflow.listener; … public class LogTaskCommentListener extends BaseJavaDelegate implements TaskListener { public void notify(DelegateTask task) { … String query = "INSERT INTO article_actions (user, article_id, action) VALUES (?, ?, ?)"; jdbcTemplate.update(query, new Object[] { userName, articleId, action }); } public void setExtDBSource(DataSource extDBSource) { this.jdbcTemplate = new JdbcTemplate(extDBSource); }
15
Listener Code package com.example.workflow.listener; … public class LogTaskCommentListener extends BaseJavaDelegate implements TaskListener { public void notify(DelegateTask task) { … String query = "INSERT INTO article_actions (user, article_id, action) VALUES (?, ?, ?)"; jdbcTemplate.update(query, new Object[] { userName, articleId, action }); } public void setExtDBSource(DataSource extDBSource) { this.jdbcTemplate = new JdbcTemplate(extDBSource); }
16
Watch Out Database configuration Connection time out Connection pool size Consider corner cases Database not reachable
17
Unit Testing Challenges Review Alfresco source code AbstractActivitiComponentTest.java
18
Unit Testing Components Junit framework Mock framework (mockito) Spring framework SpringJUnit4ClassRunner JdbcTemplate H2 database engine
19
Unit Testing Components Junit framework Mock framework (mockito) Spring framework SpringJUnit4ClassRunner JdbcTemplate H2 database engine
20
Test Execution Flow Initialize H2 schema Record behavior (mock) Run test scenario Validate database table Drop table and cleanup
21
Test Execution Flow Initialize H2 schema Record behavior (mock) Run test scenario Validate database table Drop table and cleanup
22
Resources Blog Post on How to Implement http://vakhshoori.blogspot.com/2014/08/alfresc o-activiti-talking-to-external.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.