Clarify @EnableScheduling javadoc

It is now advised that destroyMethod="shutdown" should be used
on @Bean methods returning an ExecutorService.

Backport-Issue: SPR-9280
Backport-Commit: 6da03a61b22696283c2c5c79f8f88b5c36480560
This commit is contained in:
Chris Beams
2012-05-14 12:15:42 +03:00
parent 6b76afd1ce
commit 1380d053c4

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,12 +105,16 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
* taskRegistrar.setScheduler(taskExecutor());
* }
*
* @Bean
* @Bean(destroyMethod="shutdown")
* public Executor taskExecutor() {
* return Executors.newScheduledThreadPool(100);
* }
* }</pre>
*
* Note in the example above the use of {@code @Bean(destroyMethod="shutdown")}. This
* ensures that the task executor is properly shut down when the Spring application
* context itself is closed.
*
* Implementing {@code SchedulingConfigurer} also allows for fine-grained
* control over task registration via the {@code ScheduledTaskRegistrar}.
* For example, the following configures the execution of a particular bean
@@ -133,7 +137,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
* );
* }
*
* &#064;Bean
* &#064;Bean(destroyMethod="shutdown")
* public Executor taskScheduler() {
* return Executors.newScheduledThreadPool(42);
* }