Skip to content

Commit 4031b5d

Browse files
committed
feat: support ActivitiIdGeneratorAutoConfiguration
1 parent 018409d commit 4031b5d

File tree

5 files changed

+96
-2
lines changed

5 files changed

+96
-2
lines changed

cosid-spring-boot-starter/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ java {
4040
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
4141
capability(group.toString(), "data-jdbc-support", version.toString())
4242
}
43+
registerFeature("activitiSupport") {
44+
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
45+
capability(group.toString(), "activiti-support", version.toString())
46+
}
4347
registerFeature("flowableSupport") {
4448
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
4549
capability(group.toString(), "flowable-support", version.toString())
@@ -67,6 +71,8 @@ dependencies {
6771

6872
"proxySupportImplementation"(project(":cosid-proxy"))
6973
"mongoSupportImplementation"(project(":cosid-mongo"))
74+
"activitiSupportImplementation"(project(":cosid-activiti"))
75+
"activitiSupportImplementation"(libs.activitiSpringBootStarter)
7076
"flowableSupportImplementation"(project(":cosid-flowable"))
7177
"flowableSupportImplementation"(libs.flowableSpring)
7278
"flowableSupportImplementation"(libs.flowableSpringBootAutoconfigure)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
package me.ahoo.cosid.spring.boot.starter.activiti;
15+
16+
import me.ahoo.cosid.activiti.ActivitiIdGenerator;
17+
import me.ahoo.cosid.flowable.FlowableIdGenerator;
18+
import me.ahoo.cosid.spring.boot.starter.ConditionalOnCosIdEnabled;
19+
20+
import org.activiti.spring.SpringProcessEngineConfiguration;
21+
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
22+
import org.springframework.boot.autoconfigure.AutoConfiguration;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24+
import org.springframework.context.annotation.Bean;
25+
26+
/**
27+
* Activiti IdGenerator Auto Configuration.
28+
*
29+
* @author ahoo wang
30+
*/
31+
@AutoConfiguration
32+
@ConditionalOnCosIdEnabled
33+
@ConditionalOnClass(FlowableIdGenerator.class)
34+
public class ActivitiIdGeneratorAutoConfiguration {
35+
36+
@Bean
37+
public ProcessEngineConfigurationConfigurer engineConfigurationConfigurer() {
38+
return new ActivitiIdGeneratorAutoConfiguration.CosIdProcessEngineConfigurationConfigurer();
39+
}
40+
41+
static class CosIdProcessEngineConfigurationConfigurer implements ProcessEngineConfigurationConfigurer {
42+
43+
@Override
44+
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
45+
engineConfiguration.setIdGenerator(new ActivitiIdGenerator());
46+
}
47+
}
48+
}

cosid-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ me.ahoo.cosid.spring.boot.starter.mybatis.CosIdMybatisAutoConfiguration
1919
me.ahoo.cosid.spring.boot.starter.actuate.CosIdEndpointAutoConfiguration
2020
me.ahoo.cosid.spring.boot.starter.jdbc.CosIdJdbcAutoConfiguration
2121
me.ahoo.cosid.spring.boot.starter.flowable.FlowableIdGeneratorAutoConfiguration
22+
me.ahoo.cosid.spring.boot.starter.activiti.ActivitiIdGeneratorAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
package me.ahoo.cosid.spring.boot.starter.activiti;
15+
16+
import me.ahoo.cosid.spring.boot.starter.machine.ConditionalOnCosIdMachineEnabled;
17+
18+
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
19+
import org.assertj.core.api.AssertionsForInterfaceTypes;
20+
import org.junit.jupiter.api.Test;
21+
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
22+
23+
class ActivitiIdGeneratorAutoConfigurationTest {
24+
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
25+
26+
@Test
27+
void contextLoads() {
28+
this.contextRunner
29+
.withPropertyValues(ConditionalOnCosIdMachineEnabled.ENABLED_KEY + "=true")
30+
.withUserConfiguration(ActivitiIdGeneratorAutoConfiguration.class)
31+
.run(context -> {
32+
AssertionsForInterfaceTypes.assertThat(context)
33+
.hasSingleBean(ActivitiIdGeneratorAutoConfiguration.class)
34+
.hasSingleBean(ProcessEngineConfigurationConfigurer.class)
35+
;
36+
});
37+
}
38+
}

gradle/libs.versions.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mybatisSpringBoot = "3.0.2"
1010
junitPioneer = "2.1.0"
1111
axon = "4.9.0"
1212
flowable = "6.8.0"
13-
activiti = "6.0.0"
13+
activiti = "7.0.0.SR1"
1414
springDoc = "2.2.0"
1515
hamcrest = "2.2"
1616
jmh = "1.37"
@@ -29,10 +29,11 @@ guava = { module = "com.google.guava:guava", version.ref = "guava" }
2929
mybatis = { module = "org.mybatis:mybatis", version.ref = "mybatis" }
3030
mybatisSpringBoot = { module = "org.mybatis.spring.boot:mybatis-spring-boot-starter", version.ref = "mybatisSpringBoot" }
3131
springDocStarterWebfluxUi = { module = "org.springdoc:springdoc-openapi-starter-webflux-ui", version.ref = "springDoc" }
32+
activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" }
33+
activitiSpringBootStarter = { module = "org.activiti:activiti-spring-boot-starter", version.ref = "activiti" }
3234
flowableEngineCommon = { module = "org.flowable:flowable-engine-common", version.ref = "flowable" }
3335
flowableSpring = { module = "org.flowable:flowable-spring", version.ref = "flowable" }
3436
flowableSpringBootAutoconfigure = { module = "org.flowable:flowable-spring-boot-autoconfigure", version.ref = "flowable" }
35-
activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" }
3637
junitPioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junitPioneer" }
3738
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
3839
jmhCore = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }

0 commit comments

Comments
 (0)