diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableAutoConfiguration.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableAutoConfiguration.java new file mode 100644 index 0000000..6df7363 --- /dev/null +++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableAutoConfiguration.java @@ -0,0 +1,41 @@ +package com.lanyuanxiaoyao.flowable.jpa; + +import com.lanyuanxiaoyao.flowable.core.manager.FlowableConfiguration; +import com.lanyuanxiaoyao.flowable.core.manager.FlowableManager; +import com.lanyuanxiaoyao.flowable.core.repository.FlowableRepository; +import com.lanyuanxiaoyao.flowable.jpa.repository.FlowableHistoryRepository; +import com.lanyuanxiaoyao.flowable.jpa.repository.FlowableInstanceRepository; +import com.lanyuanxiaoyao.flowable.jpa.repository.FlowableNodeRepository; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 自动配置 + * + * @author lanyuanxiaoyao + * @version 20250103 + */ +@Configuration +@EnableConfigurationProperties(SpringFlowableConfiguration.class) +public class SpringFlowableAutoConfiguration { + @Bean + public FlowableRepository flowableRepository( + FlowableNodeRepository flowableNodeRepository, + FlowableInstanceRepository flowableInstanceRepository, + FlowableHistoryRepository flowableHistoryRepository + ) { + return new SpringFlowableRepository(flowableNodeRepository, flowableInstanceRepository, flowableHistoryRepository); + } + + @Bean + public FlowableManager flowableManager( + @Qualifier("springFlowableConfiguration") FlowableConfiguration configuration, + FlowableRepository repository, + ApplicationContext applicationContext + ) { + return new SpringFlowableManager(configuration, repository, applicationContext); + } +} diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java index 008dc33..7a46a06 100644 --- a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java +++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java @@ -7,14 +7,12 @@ import java.util.UUID; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Service; /** * @author lanyuanxiaoyao * @version 20241231 */ @Slf4j -@Service public class SpringFlowableManager extends FlowableManager { private final ApplicationContext applicationContext; diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableRepository.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableRepository.java index 4406704..9086108 100644 --- a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableRepository.java +++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableRepository.java @@ -10,13 +10,11 @@ import com.lanyuanxiaoyao.flowable.jpa.repository.FlowableNodeRepository; import java.util.List; import java.util.stream.Collectors; import javax.transaction.Transactional; -import org.springframework.stereotype.Service; /** * @author lanyuanxiaoyao * @version 20241231 */ -@Service public class SpringFlowableRepository implements FlowableRepository { private final FlowableNodeRepository flowableNodeRepository; private final FlowableInstanceRepository flowableInstanceRepository; diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/resources/META-INF/spring.factories b/adapter/flowable-spring-boot-jpa-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..293b87d --- /dev/null +++ b/adapter/flowable-spring-boot-jpa-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.lanyuanxiaoyao.flowable.jpa.SpringFlowableAutoConfiguration \ No newline at end of file