Simplify TaskExecutionAutoConfiguration

pull/36682/head
Moritz Halbritter 1 year ago
parent 4ba7463d75
commit 19859a9023

@ -38,8 +38,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Import({ TaskExecutorConfigurations.ThreadPoolTaskExecutorBuilderConfiguration.class, @Import({ TaskExecutorConfigurations.ThreadPoolTaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.TaskExecutorBuilderConfiguration.class, TaskExecutorConfigurations.TaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.SimpleAsyncTaskExecutorBuilderConfiguration.class, TaskExecutorConfigurations.SimpleAsyncTaskExecutorBuilderConfiguration.class,
TaskExecutorConfigurations.VirtualThreadTaskExecutorConfiguration.class, TaskExecutorConfigurations.TaskExecutorConfiguration.class })
TaskExecutorConfigurations.ThreadPoolTaskExecutorConfiguration.class })
public class TaskExecutionAutoConfiguration { public class TaskExecutionAutoConfiguration {
/** /**

@ -47,27 +47,22 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
*/ */
class TaskExecutorConfigurations { class TaskExecutorConfigurations {
@ConditionalOnThreading(Threading.VIRTUAL)
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class) @ConditionalOnMissingBean(Executor.class)
static class VirtualThreadTaskExecutorConfiguration { @SuppressWarnings("removal")
static class TaskExecutorConfiguration {
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, @Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME }) AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
SimpleAsyncTaskExecutor applicationTaskExecutor(SimpleAsyncTaskExecutorBuilder builder) { @ConditionalOnThreading(Threading.VIRTUAL)
SimpleAsyncTaskExecutor applicationTaskExecutorVirtualThreads(SimpleAsyncTaskExecutorBuilder builder) {
return builder.build(); return builder.build();
} }
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(Executor.class)
@SuppressWarnings("removal")
static class ThreadPoolTaskExecutorConfiguration {
@Lazy @Lazy
@Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME, @Bean(name = { TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME }) AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
@ConditionalOnThreading(Threading.PLATFORM)
ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder taskExecutorBuilder, ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder taskExecutorBuilder,
ObjectProvider<ThreadPoolTaskExecutorBuilder> threadPoolTaskExecutorBuilderProvider) { ObjectProvider<ThreadPoolTaskExecutorBuilder> threadPoolTaskExecutorBuilderProvider) {
ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder = threadPoolTaskExecutorBuilderProvider ThreadPoolTaskExecutorBuilder threadPoolTaskExecutorBuilder = threadPoolTaskExecutorBuilderProvider

Loading…
Cancel
Save