Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
d423c36f
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d423c36f
编写于
9月 18, 2014
作者:
J
Josh Long
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup
上级
727dd594
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
137 addition
and
226 deletion
+137
-226
modules/activiti-spring-boot/pom.xml
modules/activiti-spring-boot/pom.xml
+37
-0
modules/activiti-spring-boot/src/main/java/org/activiti/spring/boot/ActivitiProperties.java
...ain/java/org/activiti/spring/boot/ActivitiProperties.java
+38
-9
modules/activiti-spring-boot/src/main/java/org/activiti/spring/boot/ProcessEngineAutoConfiguration.java
.../activiti/spring/boot/ProcessEngineAutoConfiguration.java
+39
-207
modules/activiti-spring-boot/src/test/java/org/activiti/spring/boot/TestProcessEngineAutoConfiguration.java
...iviti/spring/boot/TestProcessEngineAutoConfiguration.java
+21
-9
modules/activiti-spring-boot/src/test/resources/application.properties
...iti-spring-boot/src/test/resources/application.properties
+2
-1
未找到文件。
modules/activiti-spring-boot/pom.xml
浏览文件 @
d423c36f
...
@@ -154,6 +154,36 @@
...
@@ -154,6 +154,36 @@
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>
org.activiti
</groupId>
<artifactId>
activiti-rest
</artifactId>
<!-- Excluding these in favour of the Spring Boot dependencies -->
<!--<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</exclusion>
</exclusions>-->
<optional>
true
</optional>
</dependency>
<dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<groupId>
com.h2database
</groupId>
...
@@ -179,6 +209,13 @@
...
@@ -179,6 +209,13 @@
<optional>
true
</optional>
<optional>
true
</optional>
<!-- Having it on the classpath will enable JPA + Activiti, but it is not mandatory -->
<!-- Having it on the classpath will enable JPA + Activiti, but it is not mandatory -->
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
<version>
${spring.boot.version}
</version>
<optional>
true
</optional>
<!-- Having it on the classpath will enable JPA + Activiti, but it is not mandatory -->
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<artifactId>
spring-boot-starter-web
</artifactId>
...
...
modules/activiti-spring-boot/src/main/java/org/activiti/spring/boot/ActivitiProperties.java
浏览文件 @
d423c36f
...
@@ -10,9 +10,25 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -10,9 +10,25 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
public
class
ActivitiProperties
{
public
class
ActivitiProperties
{
private
boolean
checkProcessDefinitions
;
private
boolean
checkProcessDefinitions
;
private
boolean
restApiEnabled
;
private
String
deploymentName
;
private
String
deploymentName
;
public
boolean
isRestApiEnabled
()
{
return
restApiEnabled
;
}
public
void
setRestApiEnabled
(
boolean
restApiEnabled
)
{
this
.
restApiEnabled
=
restApiEnabled
;
}
public
boolean
isJpaEnabled
()
{
return
jpaEnabled
;
}
public
void
setJpaEnabled
(
boolean
jpaEnabled
)
{
this
.
jpaEnabled
=
jpaEnabled
;
}
private
String
databaseSchemaUpdate
=
"true"
;
private
String
databaseSchemaUpdate
=
"true"
;
private
String
databaseSchema
;
private
String
databaseSchema
;
...
@@ -21,7 +37,27 @@ public class ActivitiProperties {
...
@@ -21,7 +37,27 @@ public class ActivitiProperties {
private
String
processDefinitionLocationSuffix
=
"**.bpmn20.xml"
;
private
String
processDefinitionLocationSuffix
=
"**.bpmn20.xml"
;
private
boolean
jpa
=
true
;
// true by default
private
String
restApiMapping
=
"/api/"
;
public
String
getRestApiMapping
()
{
return
restApiMapping
;
}
public
void
setRestApiMapping
(
String
restApiMapping
)
{
this
.
restApiMapping
=
restApiMapping
;
}
public
String
getRestApiServletName
()
{
return
restApiServletName
;
}
public
void
setRestApiServletName
(
String
restApiServletName
)
{
this
.
restApiServletName
=
restApiServletName
;
}
private
String
restApiServletName
=
"activitiRestApi"
;
private
boolean
jpaEnabled
=
true
;
// true by default
public
boolean
isCheckProcessDefinitions
()
{
public
boolean
isCheckProcessDefinitions
()
{
return
checkProcessDefinitions
;
return
checkProcessDefinitions
;
...
@@ -73,11 +109,4 @@ public class ActivitiProperties {
...
@@ -73,11 +109,4 @@ public class ActivitiProperties {
this
.
processDefinitionLocationSuffix
=
processDefinitionLocationSuffix
;
this
.
processDefinitionLocationSuffix
=
processDefinitionLocationSuffix
;
}
}
public
boolean
isJpa
()
{
return
jpa
;
}
public
void
setJpa
(
boolean
jpa
)
{
this
.
jpa
=
jpa
;
}
}
}
modules/activiti-spring-boot/src/main/java/org/activiti/spring/boot/ProcessEngineAutoConfiguration.java
浏览文件 @
d423c36f
...
@@ -16,18 +16,22 @@
...
@@ -16,18 +16,22 @@
package
org.activiti.spring.boot
;
package
org.activiti.spring.boot
;
import
org.activiti.engine.*
;
import
org.activiti.engine.*
;
import
org.activiti.rest.service.application.ActivitiRestServicesApplication
;
import
org.activiti.spring.ProcessEngineFactoryBean
;
import
org.activiti.spring.ProcessEngineFactoryBean
;
import
org.activiti.spring.SpringJobExecutor
;
import
org.activiti.spring.SpringJobExecutor
;
import
org.activiti.spring.SpringProcessEngineConfiguration
;
import
org.activiti.spring.SpringProcessEngineConfiguration
;
import
org.restlet.ext.servlet.ServerServlet
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.
ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.
*
;
import
org.springframework.boot.
autoconfigure.condition.ConditionalOnMissing
Bean
;
import
org.springframework.boot.
context.embedded.ServletRegistration
Bean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.core.task.SimpleAsyncTaskExecutor
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -159,13 +163,44 @@ public class ProcessEngineAutoConfiguration {
...
@@ -159,13 +163,44 @@ public class ProcessEngineAutoConfiguration {
return
super
.
identityServiceBean
(
processEngine
);
return
super
.
identityServiceBean
(
processEngine
);
}
}
@Bean
@ConditionalOnMissingBean
public
PlatformTransactionManager
transactionManager
(
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
@ConditionalOnMissingBean
public
TaskExecutor
taskExecutor
()
{
return
new
SimpleAsyncTaskExecutor
();
}
}
}
@ConditionalOnExpression
(
"${spring.activiti.restApiEnabled:true}"
)
@Configuration
@ConditionalOnClass
({
ActivitiRestServicesApplication
.
class
,
ServletRegistrationBean
.
class
,
ServerServlet
.
class
})
public
static
class
RestServiceAutoConfiguration
{
@Autowired
private
ActivitiProperties
activitiProperties
;
/*
@Bean
public
ServletRegistrationBean
activitiRestRegistration
()
{
ServerServlet
servlet
=
new
ServerServlet
();
ServletRegistrationBean
registration
=
new
ServletRegistrationBean
(
servlet
,
this
.
activitiProperties
.
getRestApiMapping
());
registration
.
addInitParameter
(
"org.restlet.application"
,
"org.activiti.rest.service.application.ActivitiRestServicesApplication"
);
registration
.
setName
(
this
.
activitiProperties
.
getRestApiServletName
());
return
null
;
}
}
/*
@Configuration
@Configuration
@ConditionalOnClass({EntityManagerFactory.class})
@ConditionalOnClass({EntityManagerFactory.class})
public static class JpaAutoConfiguration {
public static class JpaAutoConfiguration {
...
@@ -191,209 +226,6 @@ public class ProcessEngineAutoConfiguration {
...
@@ -191,209 +226,6 @@ public class ProcessEngineAutoConfiguration {
};
};
}
}
}
}*/
*/
/**
* This installs the Activiti REST endpoints. The REST endpoints can be used to
* query the running workflow engine.
*//*
@Configuration
@ConditionalOnClass({ServletRegistrationBean.class, ServerServlet.class})
public static class RestServiceAutoConfiguration {
@Bean
ServletRegistrationBean activitiRestRegistration(
@Value("${spring.activiti.rest.mapping:activiti-rest}") String name,
@Value("${spring.activiti.rest.mapping:'/activiti*/
/*'}") String mapping) {
ServerServlet servlet = new ServerServlet();
ServletRegistrationBean registration = new ServletRegistrationBean(servlet, mapping);
registration.addInitParameter("org.restlet.application", "org.activiti.rest.service.application.ActivitiRestServicesApplication");
registration.setName(name);
return registration;
}
}
*/
}
}
/*
@Configuration
class ActivitiConfiguration {
@Autowired(required = false)
private List<TaskExecutor> executors;
@Autowired(required = false)
private List<ActivitiConfigurer> activitiConfigurers;
@Autowired(required = false)
private Map<String, DataSource> dataSources;
@Autowired(required = false)
private List<PlatformTransactionManager> platformTransactionManagers;
@Autowired(required = false)
private List<SpringJobExecutor> springJobExecutors;
@Bean
public SpringProcessEngineConfiguration springProcessEngineConfiguration(
) {
ActivitiConfigurer configurer = activitiConfigurer(activitiConfigurers);
List<Resource> processDefinitionResources = new ArrayList<Resource>();
configurer.processDefinitionResources(processDefinitionResources);
SpringProcessEngineConfiguration engine = new SpringProcessEngineConfiguration();
if (!processDefinitionResources.isEmpty()) {
engine.setDeploymentResources(processDefinitionResources
.toArray(new Resource[processDefinitionResources.size()]));
}
DataSource dataSource = dataSource(configurer, dataSources);
engine.setDataSource(dataSource);
engine.setTransactionManager(platformTransactionManager(dataSource));
engine.setJobExecutor(springJobExecutor());
engine.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
configurer.postProcessSpringProcessEngineConfiguration(engine);
return engine;
}
@Bean
public ProcessEngineFactoryBean processEngine(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
ProcessEngineFactoryBean processEngineFactoryBean = new ProcessEngineFactoryBean();
processEngineFactoryBean.setProcessEngineConfiguration(springProcessEngineConfiguration);
return processEngineFactoryBean;
}
@Bean
public RuntimeService runtimeService(ProcessEngine processEngine) {
return processEngine.getRuntimeService();
}
@Bean
public RepositoryService repositoryService(ProcessEngine processEngine) {
return processEngine.getRepositoryService();
}
@Bean
public TaskService taskService(ProcessEngine processEngine) {
return processEngine.getTaskService();
}
@Bean
public HistoryService historyService(ProcessEngine processEngine) {
return processEngine.getHistoryService();
}
@Bean
public ManagementService managementService(ProcessEngine processEngine) {
return processEngine.getManagementService();
}
@Bean
public FormService formService(ProcessEngine processEngine) {
return processEngine.getFormService();
}
@Bean
public IdentityService identityService(ProcessEngine processEngine) {
return processEngine.getIdentityService();
}
*/
/*
* @Bean public static ProcessScopeBeanFactoryPostProcessor processScope() {
* return new ProcessScopeBeanFactoryPostProcessor(); }
*
* @Bean public SharedProcessInstanceFactoryBean
* processInstanceFactoryBean(SharedProcessInstanceHolder
* sharedProcessInstanceHolder) { return new
* SharedProcessInstanceFactoryBean(sharedProcessInstanceHolder); }
*
* @Bean public SharedProcessInstanceHolder processScopeContextHolder() {
* return new SharedProcessInstanceHolder(); }
*//*
*/
/* protected PlatformTransactionManager platformTransactionManager(final DataSource dataSource) {
return first(this.platformTransactionManagers,
new ObjectFactory<PlatformTransactionManager>() {
@Override
public PlatformTransactionManager getObject() throws BeansException {
return new DataSourceTransactionManager(dataSource);
}
});
}*//*
protected SpringJobExecutor springJobExecutor() {
return first(this.springJobExecutors,
new ObjectFactory<SpringJobExecutor>() {
@Override
public SpringJobExecutor getObject() throws BeansException {
TaskExecutor taskExecutor = first(executors,
new ObjectFactory<TaskExecutor>() {
@Override
public TaskExecutor getObject() throws BeansException {
return new SyncTaskExecutor();
}
});
return new SpringJobExecutor(taskExecutor);
}
});
}
protected ActivitiConfigurer activitiConfigurer(final List<ActivitiConfigurer> activitiConfigurers) {
return new ActivitiConfigurer() {
@Override
public void processDefinitionResources(List<Resource> resourceList) {
List<Resource> resources = new ArrayList<Resource>();
// lets first see if any exist in the default place:
Resource defaultClassPathResourceMatcher = new ClassPathResource("classpath:/processes*/
/**bpmn20.xml");
if (defaultClassPathResourceMatcher.exists()) {
resources.add(defaultClassPathResourceMatcher);
}
if (activitiConfigurers != null && !activitiConfigurers.isEmpty()) {
for (ActivitiConfigurer ac : activitiConfigurers) {
ac.processDefinitionResources(resources);
}
}
resourceList.addAll(resources);
}
@Override public void postProcessSpringProcessEngineConfiguration(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
if (activitiConfigurers != null) {
for (ActivitiConfigurer configurer : activitiConfigurers) {
configurer.postProcessSpringProcessEngineConfiguration(springProcessEngineConfiguration);
}
}
}
};
}
private static <T> T first(List<T> tList, ObjectFactory<T> tObjectFactory) {
T rt;
if (tList != null && !tList.isEmpty()) {
rt = tList.iterator().next();
} else {
rt = tObjectFactory.getObject();
}
return rt;
}
}
*/
modules/activiti-spring-boot/src/test/java/org/activiti/spring/boot/TestAutoConfiguration.java
→
modules/activiti-spring-boot/src/test/java/org/activiti/spring/boot/Test
ProcessEngine
AutoConfiguration.java
浏览文件 @
d423c36f
...
@@ -4,11 +4,12 @@ import org.activiti.engine.ProcessEngine;
...
@@ -4,11 +4,12 @@ import org.activiti.engine.ProcessEngine;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.RepositoryService
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -20,7 +21,9 @@ import org.springframework.transaction.PlatformTransactionManager;
...
@@ -20,7 +21,9 @@ import org.springframework.transaction.PlatformTransactionManager;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
java.util.List
;
import
java.util.List
;
public
class
TestAutoConfiguration
{
public
class
TestProcessEngineAutoConfiguration
{
private
ConfigurableApplicationContext
applicationContext
;
@Configuration
@Configuration
@EnableAutoConfiguration
@EnableAutoConfiguration
...
@@ -48,20 +51,31 @@ public class TestAutoConfiguration {
...
@@ -48,20 +51,31 @@ public class TestAutoConfiguration {
}
}
}
}
@Test
@Test
public
void
testProcessEngine
()
throws
Exception
{
public
void
testProcessEngine
()
throws
Exception
{
ProcessEngine
processEngine
=
applicationContext
.
getBean
(
ProcessEngine
.
class
);
ProcessEngine
processEngine
=
applicationContext
.
getBean
(
ProcessEngine
.
class
);
Assert
.
assertNotNull
(
"the processEngine should not be null!"
,
processEngine
);
Assert
.
assertNotNull
(
"the processEngine should not be null!"
,
processEngine
);
}
}
private
ConfigurableApplicationContext
applicationContext
;
@After
public
void
close
()
{
this
.
applicationContext
.
close
();
}
@Test
public
void
testRunsWithRestApis
()
{
System
.
setProperty
(
"spring.activiti.restApiEnabled"
,
"true"
);
this
.
applicationContext
=
SpringApplication
.
run
(
SimpleDataSourceConfiguration
.
class
);
// do RestTemplate or something
}
@Test
public
void
testRunsWithoutRestApis
()
{
System
.
setProperty
(
"spring.activiti.restApiEnabled"
,
"false"
);
this
.
applicationContext
=
SpringApplication
.
run
(
SimpleDataSourceConfiguration
.
class
);
}
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
this
.
applicationContext
=
new
SpringApplicationBuilder
(
SimpleDataSourceConfiguration
.
class
)
.
web
(
false
)
.
run
();
}
}
@Test
@Test
...
@@ -77,6 +91,4 @@ public class TestAutoConfiguration {
...
@@ -77,6 +91,4 @@ public class TestAutoConfiguration {
ProcessDefinition
processDefinition
=
processDefinitionList
.
iterator
().
next
();
ProcessDefinition
processDefinition
=
processDefinitionList
.
iterator
().
next
();
Assert
.
assertEquals
(
processDefinition
.
getKey
(),
"waiter"
);
Assert
.
assertEquals
(
processDefinition
.
getKey
(),
"waiter"
);
}
}
}
}
modules/activiti-spring-boot/src/test/resources/application.properties
浏览文件 @
d423c36f
debug
:
false
debug
true
spring.activiti.restApiEnabled
false
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录