Commit 6f86a843 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Alias auto-configured `TaskExecutor` to make async tasks use it"

Closes gh-15748
parent d0859f15
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration; ...@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.core.task.TaskDecorator; import org.springframework.core.task.TaskDecorator;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/** /**
...@@ -49,8 +50,6 @@ public class TaskExecutionAutoConfiguration { ...@@ -49,8 +50,6 @@ public class TaskExecutionAutoConfiguration {
*/ */
public static final String APPLICATION_TASK_EXECUTOR_BEAN_NAME = "applicationTaskExecutor"; public static final String APPLICATION_TASK_EXECUTOR_BEAN_NAME = "applicationTaskExecutor";
public static final String ASYNC_TASK_EXECUTOR_BEAN_NAME = "taskExecutor";
private final TaskExecutionProperties properties; private final TaskExecutionProperties properties;
private final ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers; private final ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers;
...@@ -82,7 +81,8 @@ public class TaskExecutionAutoConfiguration { ...@@ -82,7 +81,8 @@ public class TaskExecutionAutoConfiguration {
} }
@Lazy @Lazy
@Bean(name = { APPLICATION_TASK_EXECUTOR_BEAN_NAME, ASYNC_TASK_EXECUTOR_BEAN_NAME }) @Bean(name = { APPLICATION_TASK_EXECUTOR_BEAN_NAME,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME })
@ConditionalOnMissingBean(Executor.class) @ConditionalOnMissingBean(Executor.class)
public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) { public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {
return builder.build(); return builder.build();
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment