| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
8年前发布

编程方式整合Spring和Activiti

1、配置并注入org.activiti.spring.SpringProcessEngineConfiguration,通过它设置一系列参数:

@Bean   public SpringProcessEngineConfiguration processEngineConfiguration(){    SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();    processEngineConfiguration.setDataSource(this.dataSource);    processEngineConfiguration.setTransactionManager(this.jpaTransactionManager());    processEngineConfiguration.setDatabaseSchemaUpdate("true");    Resource resource = new ClassPathResource("com/sfauto/config/leave.zip");    processEngineConfiguration.setDeploymentResources(new Resource[]{resource});    return processEngineConfiguration;   }



注意 setDeployResources方法,通过它可以自动部署流程(如果已部署过就不部署)。

2、注入ProcessEngineFactoryBean

@Bean   public ProcessEngineFactoryBean processEngineFactory(){    ProcessEngineFactoryBean processEngineFactory = new ProcessEngineFactoryBean();    processEngineFactory.setProcessEngineConfiguration(this.processEngineConfiguration());    return processEngineFactory;   }



3、通过processEngineFactory注入activiti的各类service

@Bean   public RepositoryService repositoryService() throws Exception{    return this.processEngineFactory.getObject().getRepositoryService();   }      @Bean   public RuntimeService runtimeService() throws Exception{    return this.processEngineFactory.getObject().getRuntimeService();   }      @Bean   public FormService formService() throws Exception{    return this.processEngineFactory.getObject().getFormService();   }      @Bean   public IdentityService identityService() throws Exception{    return this.processEngineFactory.getObject().getIdentityService();   }      @Bean   public TaskService taskService() throws Exception{    return this.processEngineFactory.getObject().getTaskService();   }      @Bean   public HistoryService historyService() throws Exception{    return this.processEngineFactory.getObject().getHistoryService();   }      @Bean   public ManagementService managementService() throws Exception{    return this.processEngineFactory.getObject().getManagementService();   }



来自: http://my.oschina.net/u/2453016/blog/601915

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1452738832480.html
Spring JEE框架