Skip to content

Commit

Permalink
feat: support ActivitiIdGeneratorAutoConfiguration (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Nov 1, 2023
1 parent 018409d commit 86296fd
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cosid-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ java {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "data-jdbc-support", version.toString())
}
registerFeature("activitiSupport") {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "activiti-support", version.toString())
}
registerFeature("flowableSupport") {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "flowable-support", version.toString())
Expand Down Expand Up @@ -67,6 +71,8 @@ dependencies {

"proxySupportImplementation"(project(":cosid-proxy"))
"mongoSupportImplementation"(project(":cosid-mongo"))
"activitiSupportImplementation"(project(":cosid-activiti"))
"activitiSupportImplementation"(libs.activitiSpringBootStarter)
"flowableSupportImplementation"(project(":cosid-flowable"))
"flowableSupportImplementation"(libs.flowableSpring)
"flowableSupportImplementation"(libs.flowableSpringBootAutoconfigure)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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.
*/

package me.ahoo.cosid.spring.boot.starter.activiti;

import me.ahoo.cosid.activiti.ActivitiIdGenerator;
import me.ahoo.cosid.flowable.FlowableIdGenerator;
import me.ahoo.cosid.spring.boot.starter.ConditionalOnCosIdEnabled;

import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

/**
* Activiti IdGenerator Auto Configuration.
*
* @author ahoo wang
*/
@AutoConfiguration
@ConditionalOnCosIdEnabled
@ConditionalOnClass(FlowableIdGenerator.class)
public class ActivitiIdGeneratorAutoConfiguration {

@Bean
public ProcessEngineConfigurationConfigurer engineConfigurationConfigurer() {
return new ActivitiIdGeneratorAutoConfiguration.CosIdProcessEngineConfigurationConfigurer();
}

static class CosIdProcessEngineConfigurationConfigurer implements ProcessEngineConfigurationConfigurer {

@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
engineConfiguration.setIdGenerator(new ActivitiIdGenerator());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ me.ahoo.cosid.spring.boot.starter.mybatis.CosIdMybatisAutoConfiguration
me.ahoo.cosid.spring.boot.starter.actuate.CosIdEndpointAutoConfiguration
me.ahoo.cosid.spring.boot.starter.jdbc.CosIdJdbcAutoConfiguration
me.ahoo.cosid.spring.boot.starter.flowable.FlowableIdGeneratorAutoConfiguration
me.ahoo.cosid.spring.boot.starter.activiti.ActivitiIdGeneratorAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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.
*/

package me.ahoo.cosid.spring.boot.starter.activiti;

import me.ahoo.cosid.spring.boot.starter.machine.ConditionalOnCosIdMachineEnabled;

import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.assertj.core.api.AssertionsForInterfaceTypes;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

class ActivitiIdGeneratorAutoConfigurationTest {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();

@Test
void contextLoads() {
this.contextRunner
.withPropertyValues(ConditionalOnCosIdMachineEnabled.ENABLED_KEY + "=true")
.withUserConfiguration(ActivitiIdGeneratorAutoConfiguration.class)
.run(context -> {
AssertionsForInterfaceTypes.assertThat(context)
.hasSingleBean(ActivitiIdGeneratorAutoConfiguration.class)
.hasSingleBean(ProcessEngineConfigurationConfigurer.class)
;
});
}
}
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mybatisSpringBoot = "3.0.2"
junitPioneer = "2.1.0"
axon = "4.9.0"
flowable = "6.8.0"
activiti = "6.0.0"
activiti = "7.0.0.SR1"
springDoc = "2.2.0"
hamcrest = "2.2"
jmh = "1.37"
Expand All @@ -29,10 +29,11 @@ guava = { module = "com.google.guava:guava", version.ref = "guava" }
mybatis = { module = "org.mybatis:mybatis", version.ref = "mybatis" }
mybatisSpringBoot = { module = "org.mybatis.spring.boot:mybatis-spring-boot-starter", version.ref = "mybatisSpringBoot" }
springDocStarterWebfluxUi = { module = "org.springdoc:springdoc-openapi-starter-webflux-ui", version.ref = "springDoc" }
activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" }
activitiSpringBootStarter = { module = "org.activiti:activiti-spring-boot-starter", version.ref = "activiti" }
flowableEngineCommon = { module = "org.flowable:flowable-engine-common", version.ref = "flowable" }
flowableSpring = { module = "org.flowable:flowable-spring", version.ref = "flowable" }
flowableSpringBootAutoconfigure = { module = "org.flowable:flowable-spring-boot-autoconfigure", version.ref = "flowable" }
activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" }
junitPioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junitPioneer" }
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
jmhCore = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
Expand Down

0 comments on commit 86296fd

Please sign in to comment.