From b56555923af4006935d956fceaacfde927460c8b Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 7 Jan 2025 14:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Spring=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jpa/SpringFlowableAutoConfiguration.java | 15 ++++++++------- .../flowable/jpa/SpringFlowableManager.java | 11 ++++++++--- .../jpa/SpringFlowableManagerInitializer.java | 4 +--- 3 files changed, 17 insertions(+), 13 deletions(-) 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 index 699d5dc..d43c812 100644 --- 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 @@ -1,6 +1,5 @@ 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; @@ -12,6 +11,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -22,13 +22,14 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories; * @version 20250103 */ @Configuration +@ComponentScan @EnableJpaRepositories("com.lanyuanxiaoyao.flowable.jpa.repository") @EnableConfigurationProperties(SpringFlowableConfiguration.class) public class SpringFlowableAutoConfiguration { - @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") + @Bean @ConditionalOnMissingBean(FlowableRepository.class) - public FlowableRepository flowableRepository( + public SpringFlowableRepository flowableRepository( FlowableNodeRepository flowableNodeRepository, FlowableInstanceRepository flowableInstanceRepository, FlowableHistoryRepository flowableHistoryRepository @@ -39,12 +40,12 @@ public class SpringFlowableAutoConfiguration { @Bean @ConditionalOnBean(FlowableRepository.class) @ConditionalOnMissingBean(FlowableManager.class) - public FlowableManager flowableManager( - FlowableConfiguration configuration, - FlowableRepository repository, + public SpringFlowableManager flowableManager( + SpringFlowableConfiguration configuration, + SpringFlowableRepository repository, ApplicationContext applicationContext ) { - FlowableManager manager = new SpringFlowableManager(configuration, repository, applicationContext); + SpringFlowableManager manager = new SpringFlowableManager(configuration, repository, applicationContext); Map initializerMap = applicationContext.getBeansOfType(SpringFlowableManagerInitializer.class); for (SpringFlowableManagerInitializer initializer : initializerMap.values()) { 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 f9ccb78..09e7ac8 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 @@ -1,12 +1,15 @@ 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.entity.FlowableHistory; +import com.lanyuanxiaoyao.flowable.jpa.entity.FlowableInstance; +import com.lanyuanxiaoyao.flowable.jpa.entity.FlowableNode; +import java.util.List; import java.util.UUID; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationContext; +import org.springframework.data.jpa.domain.Specification; /** * @author lanyuanxiaoyao @@ -14,11 +17,13 @@ import org.springframework.context.ApplicationContext; */ @Slf4j public class SpringFlowableManager extends FlowableManager { + private final SpringFlowableRepository repository; private final ApplicationContext applicationContext; - public SpringFlowableManager(FlowableConfiguration configuration, FlowableRepository repository, ApplicationContext applicationContext) { + public SpringFlowableManager(SpringFlowableConfiguration configuration, SpringFlowableRepository repository, ApplicationContext applicationContext) { super(configuration, repository); log.info("Configuration: {}", configuration); + this.repository = repository; this.applicationContext = applicationContext; } diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManagerInitializer.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManagerInitializer.java index 6fe4220..8010b18 100644 --- a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManagerInitializer.java +++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManagerInitializer.java @@ -1,11 +1,9 @@ package com.lanyuanxiaoyao.flowable.jpa; -import com.lanyuanxiaoyao.flowable.core.manager.FlowableManager; - /** * @author lanyuanxiaoyao * @version 20250106 */ public interface SpringFlowableManagerInitializer { - FlowableManager initial(FlowableManager manager); + SpringFlowableManager initial(SpringFlowableManager manager); }