加载自定义activiti.cfg.xml

时间:2018-03-12 14:21:10

标签: spring activiti

我正在学习活动 在那里我创建了一个java应用程序,我正在使用hibernate + Spring + activiti,我们有activiti.cfg.xml 我想以编程方式仅加载数据源和hibernate属性等数据库详细信息,例如asyncExecutorActivate等,我希望使用activiti.cfg.xml

e.g
以下需要使用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>

怎么办?

2 个答案:

答案 0 :(得分:1)

对于Spring Boot,您可以像以下代码一样配置流程引擎。 activitiproperties是我编写的用于获取邮件服务器参数的自定义类。

@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());

答案 1 :(得分:0)

您可以简单地从属性文件中注入值,并根据它们构建自己的引擎。比如数据源。请遵循此tutorial

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