From 63ca14c33ee746734fe27b37712a53d78afcce74 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 19 Nov 2012 10:39:19 -0800 Subject: [PATCH] Clarify use of @Bean with @EnableAsync executors Update Javadoc to indicate that the getAsyncExecutor() method may be optionally annotated with @Bean and in such circumstance the executor.initialize() method need not be called. Issue: SPR-9934 --- .../scheduling/annotation/EnableAsync.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java index fdbd4baa7c..10b2f7dd4b 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/EnableAsync.java @@ -96,7 +96,13 @@ import org.springframework.core.Ordered; * the examples are equivalent save the setting of the thread name prefix of the * Executor; this is because the the {@code task:} namespace {@code executor} element does * not expose such an attribute. This demonstrates how the code-based approach allows for - * maximum configurability through direct access to actual componentry.

+ * maximum configurability through direct access to actual componentry. + * + *

Note: In the above example the {@code ThreadPoolTaskExecutor} is not a fully managed + * Spring Bean. Add the {@code @Bean} annotation to the {@code getAsyncExecutor()} method + * if you want a fully managed bean. In such circumstances it is no longer necessary to + * manually call the {@code executor.initialize()} method as this will be invoked + * automatically when the bean is initialized. * * @author Chris Beams * @since 3.1