加载自定义 activiti.cfg.xml

Loading Custom activiti.cfg.xml

我正在学习活动。
我创建了一个 java 应用程序,因为我正在使用 hibernate + Spring + activiti 我们有 activiti.cfg.xml.
我只想以编程方式加载数据库详细信息,如数据源和休眠属性,其他我想使用 activiti.cfg.xml.

执行的操作,例如 asyncExecutorActivate 等

例如
以下需要使用Programatically

设置
<bean id="dataSource"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="<set_Using_Program>" />
    <property name="url" value="<set_Using_Program>" />
    <property name="username" value="<set_Using_Program>" />
    <property name="password" value="<set_Using_Program>" />
</bean>

此信息集使用 activiti.cgf.xml

    <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
        <property name="processEngineConfiguration" ref="processEngineConfiguration" />
    </bean>

    <bean id="runtimeService" factory-bean="processEngine"
          factory-method="getRuntimeService" />
    <bean id="taskService" factory-bean="processEngine"
          factory-method="getTaskService" />
    <bean id="repositoryService" factory-bean="processEngine"
          factory-method="getRepositoryService" />
</beans>

怎么办?

您可以简单地从属性文件中注入您的值,并基于它们构建您自己的引擎。比如数据源。按照这个 tutorial

您还可以在其上构建扩展,请参阅 userguide

for Spring Boot 你可以像这段代码一样配置流程引擎。 activitiproperties 是我编写的自定义 class 来获取邮件服务器参数。

@Autowired
private SpringProcessEngineConfiguration springprocessengineconfiguration;
springprocessengineconfiguration.setMailServerHost(activitiproperties.getMailServerHost());
springprocessengineconfiguration.setMailServerPort(activitiproperties.getMailServerPort());
springprocessengineconfiguration.setMailServerUsername(activitiproperties.getMailServerUserName());
springprocessengineconfiguration.setMailServerPassword(activitiproperties.getMailServerPassword());
springprocessengineconfiguration.setMailServerDefaultFrom(activitiproperties.getMailServerDefaultFrom());
springprocessengineconfiguration.setMailServerUseSSL(activitiproperties.isMailServerUseSsl());
springprocessengineconfiguration.setMailServerUseTLS(activitiproperties.isMailServerUseTls());