提交 139c0835 编写于 作者: J Joram Barrez
上级 ecd6cee5
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright 2012-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<definitions id="processDefinitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="processDefinitions">
<process id="waiter2">
<startEvent id="start"/>
<sequenceFlow id="flow1" sourceRef="start" targetRef="service1"/>
<scriptTask id="service1" scriptFormat="groovy">
<script>
println 'customerId=' + customerId
</script>
</scriptTask>
<sequenceFlow id="flow2" sourceRef="service1" targetRef="end"/>
<endEvent id="end"/>
</process>
</definitions>
\ No newline at end of file
......@@ -30,6 +30,7 @@ public class ProcessEngineAutoConfigurationTest {
DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceProcessEngineConfiguration.class);
RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
Assert.assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey("waiter")
.list();
......
......@@ -73,7 +73,7 @@ public abstract class AbstractProcessEngineAutoConfiguration
List<Resource> procDefResources = this.discoverProcessDefinitionResources(
this.resourceLoader, this.activitiProperties.getProcessDefinitionLocationPrefix(),
this.activitiProperties.getProcessDefinitionLocationSuffix(),
this.activitiProperties.getProcessDefinitionLocationSuffixes(),
this.activitiProperties.isCheckProcessDefinitions());
SpringProcessEngineConfiguration conf = super.processEngineConfigurationBean(
......
......@@ -14,7 +14,6 @@ package org.activiti.spring.boot;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.sql.DataSource;
......@@ -35,7 +34,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
/**
* Provides sane definitions for the various beans required to be productive with Activiti in Spring.
......@@ -73,15 +71,25 @@ public abstract class AbstractProcessEngineConfiguration {
return engine;
}
public List<Resource> discoverProcessDefinitionResources(ResourcePatternResolver applicationContext, String prefix, String suffix, boolean checkPDs) throws IOException {
String path = prefix + suffix;
public List<Resource> discoverProcessDefinitionResources(ResourcePatternResolver applicationContext, String prefix, List<String> suffixes, boolean checkPDs) throws IOException {
if (checkPDs) {
if (!applicationContext.getResource(prefix).exists()) {
logger.warn(String.format("No process definitions were found using the specified path (%s).", path));
return new ArrayList<Resource>();
}
return Arrays.asList(applicationContext.getResources(path));
List<Resource> result = new ArrayList<Resource>();
for (String suffix : suffixes) {
String path = prefix + suffix;
Resource[] resources = applicationContext.getResources(path);
if (resources != null && resources.length > 0) {
for (Resource resource : resources) {
result.add(resource);
}
}
}
if (result.isEmpty()) {
logger.info(String.format("No process definitions were found for autodeployment"));
}
return result;
}
return new ArrayList<Resource>();
}
......
......@@ -12,6 +12,7 @@
*/
package org.activiti.spring.boot;
import java.util.Arrays;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
......@@ -39,7 +40,7 @@ public class ActivitiProperties {
private String databaseSchemaUpdate = "true";
private String databaseSchema;
private String processDefinitionLocationPrefix = "classpath:/processes/";
private String processDefinitionLocationSuffix = "**.bpmn20.xml";
private List<String> processDefinitionLocationSuffixes = Arrays.asList("**.bpmn20.xml", "**.bpmn");
private String restApiMapping = "/api/*";
private String restApiServletName = "activitiRestApi";
private boolean jpaEnabled = true; // true by default
......@@ -143,16 +144,16 @@ public class ActivitiProperties {
this.processDefinitionLocationPrefix = processDefinitionLocationPrefix;
}
public String getProcessDefinitionLocationSuffix() {
return processDefinitionLocationSuffix;
}
public List<String> getProcessDefinitionLocationSuffixes() {
return processDefinitionLocationSuffixes;
}
public void setProcessDefinitionLocationSuffix(
String processDefinitionLocationSuffix) {
this.processDefinitionLocationSuffix = processDefinitionLocationSuffix;
}
public void setProcessDefinitionLocationSuffixes(
List<String> processDefinitionLocationSuffixes) {
this.processDefinitionLocationSuffixes = processDefinitionLocationSuffixes;
}
public String getMailServerHost() {
public String getMailServerHost() {
return mailServerHost;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册