网路冷眼@BlogJava

熙熙攘攘一闲人 以冷静的眼光观察技术
posts - 88, comments - 193, trackbacks - 0, articles - 28
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Extend the migration logic

扩展迁移逻辑

The migration logic is written in such a way, that it is easy to extend to suit your needs. The source code is available as a Maven 2 project in the srcsubfolder of the downloaded zip file. To build a new zip file, after having changed or extended the logic, simply execute a

迁移逻辑可以编写,以便轻松地满足你的需求。源代码在所下载zip文件里src子文件夹里作一个Maven 2项目来使用。为了构建一个新的zip文件,在已经改变或者扩展逻辑之后,简单执行下面指令

 mvn clean install

 

to produce a new zip file in the target folder.

在target文件下产生一个新的zip文件。

Following picture gives a high-level overview of the classes in the migration logic.

下图提供了在迁移逻辑里类的高层次概貌。

migration.code.overview

  • Both the ProcessConversion and ProcessDataMigration classes have a main method that directly is called from the ant build script in the root of the migration zip.
  • ProcessConversion and ProcessDataMigration 这两个类都有在迁移zip的根目录下的ant构建脚本里调用的main方法。
  • These classes construct a ServiceFactory based on the two properties files, using a static factory method
  • 通过使用静态的工厂方法,基于两个properties文件这些类构建一个ServiceFactory
ServiceFactory.configureFromProperties(jbpmDbProperties, activitiDbProperties);
  • The services are constructed by the ServiceFactory (eg. getProcessConversionService()) and are used to execute the migration logic:
  • 通过ServiceFactory (eg. getProcessConversionService())构建这些服务,这些服务被用来执行迁移逻辑:
 1 public void execute() throws IOException {
 2     
 3   // convert processes
 4   ServiceFactory serviceFactory = createServiceFactory();
 5   ProcessConversionService processConversionService = serviceFactory.getProcessConversionService();
 6   Map<String, Document> migratedProcesses = processConversionService.convertAllProcessDefinitions();
 7   
 8   // write results to bpmn20.xml files
 9   writeConvertedProcesses(migratedProcesses, workingDir);
10     
11   // Deploy processes to Activiti
12   ActivitiService activitiService = serviceFactory.getActivitiService();
13   activitiService.deployConvertedProcesses(migratedProcesses);
14     
15   // data migration
16   
17 }
  • The ProcessConversionService is an interface that contains process conversion and process definition data retrievel operations. It uses an implementation of Jbpm3Dao. The default implementation of this class uses a Hibernate SessionFactory to retrieve all the data from jBPM 3 tables.

The ActivitiService offers operation needed to get the migrated data in the Activiti tables. For example, deploying the converted process definitions is such an operation

ProcessConversionService 是一个包含流程转换和数据检索的流程定义借口。它使用了 Jbpm3Dao.的实现。这个类的缺省实现使用了Hibernate的SessionFactory从jBPM 3的数据库表里检索所有的数据。

ActivitiService 提供需要从Activiti数据库表迁移数据的操作。例如,部署转换之后的流程定义就是如此的操作。

  • All these dependencies, ProcessConversionService, Jbpm3Dao, Sessionfactory, ActivitiService and ProcessEngine, are interfaces and can be implemented by your own implementation. You can inject them into the ServiceFactory using regular JavaBean setters. When no such custom implementation is set, the ServiceFactory will fall back to creating the default implementation:
  • 所有这些依赖, ProcessConversionService, Jbpm3Dao, Sessionfactory, ActivitiService 和 ProcessEngine都是接口,并能由你自己实现。采用正常的JavaBean设置器,能将它们注入到ServiceFactory。当没有设置这些实现,ServiceFactory将后退一步,建立缺省的实现:
    1 public ProcessConversionService getProcessConversionService() {
 2   if (processConversionService == null) {
 3     this.processConversionService = createDefaultProcessConversionService();
 4   } 
 5   return processConversionService;
 6 }
 7 
 8 protected ProcessConversionService createDefaultProcessConversionService() {
 9   ProcessConversionServiceImpl service = new ProcessConversionServiceImpl(getJbpm3Dao());
10   return service;
11 }
           

评论

# re: Activiti User Guide(Activiti用户指南)-Chapter 18. JBPM Migration(JBPM 迁移)(2)[未登录]  回复  更多评论   

2012-05-09 12:29 by hh
事务能一起控制吗?

# re: Activiti User Guide(Activiti用户指南)-Chapter 18. JBPM Migration(JBPM 迁移)(2)  回复  更多评论   

2014-07-11 14:01 by cheap nikes
同一楼

只有注册用户登录后才能发表评论。


网站导航: