Clarify destroy method suppression for DisposableBean vs (Auto)Closeable
Issue: SPR-16078
(cherry picked from commit dff2c84)
This commit is contained in:
@@ -228,6 +228,8 @@ public @interface Bean {
|
||||
* Not commonly used, given that the method may be called programmatically directly
|
||||
* within the body of a Bean-annotated method.
|
||||
* <p>The default value is {@code ""}, indicating no init method to be called.
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.springframework.context.ConfigurableApplicationContext#refresh()
|
||||
*/
|
||||
String initMethod() default "";
|
||||
|
||||
@@ -248,12 +250,14 @@ public @interface Bean {
|
||||
* creation time).
|
||||
* <p>To disable destroy method inference for a particular {@code @Bean}, specify an
|
||||
* empty string as the value, e.g. {@code @Bean(destroyMethod="")}. Note that the
|
||||
* {@link org.springframework.beans.factory.DisposableBean} and the
|
||||
* {@link java.io.Closeable}/{@link java.lang.AutoCloseable} interfaces will
|
||||
* nevertheless get detected and the corresponding destroy/close method invoked.
|
||||
* {@link org.springframework.beans.factory.DisposableBean} callback interface will
|
||||
* nevertheless get detected and the corresponding destroy method invoked: In other
|
||||
* words, {@code destroyMethod=""} only affects custom close/shutdown methods and
|
||||
* {@link java.io.Closeable}/{@link java.lang.AutoCloseable} declared close methods.
|
||||
* <p>Note: Only invoked on beans whose lifecycle is under the full control of the
|
||||
* factory, which is always the case for singletons but not guaranteed for any
|
||||
* other scope.
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.context.ConfigurableApplicationContext#close()
|
||||
*/
|
||||
String destroyMethod() default AbstractBeanDefinition.INFER_METHOD;
|
||||
|
||||
Reference in New Issue
Block a user