Consistent documentation for both 'close' and 'shutdown' as inferred destroy methods
Issue: SPR-11680
This commit is contained in:
@@ -38,8 +38,8 @@ import org.springframework.util.StringUtils;
|
|||||||
/**
|
/**
|
||||||
* Base class for concrete, full-fledged
|
* Base class for concrete, full-fledged
|
||||||
* {@link org.springframework.beans.factory.config.BeanDefinition} classes,
|
* {@link org.springframework.beans.factory.config.BeanDefinition} classes,
|
||||||
* factoring out common properties of {@link RootBeanDefinition} and
|
* factoring out common properties of {@link GenericBeanDefinition},
|
||||||
* {@link ChildBeanDefinition}.
|
* {@link RootBeanDefinition} and {@link ChildBeanDefinition}.
|
||||||
*
|
*
|
||||||
* <p>The autowire constants match the ones defined in the
|
* <p>The autowire constants match the ones defined in the
|
||||||
* {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory}
|
* {@link org.springframework.beans.factory.config.AutowireCapableBeanFactory}
|
||||||
@@ -123,11 +123,14 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
|||||||
public static final int DEPENDENCY_CHECK_ALL = 3;
|
public static final int DEPENDENCY_CHECK_ALL = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant that indicates the container should attempt to infer the {@link
|
* Constant that indicates the container should attempt to infer the
|
||||||
* #setDestroyMethodName destroy method name} for a bean as opposed to explicit
|
* {@link #setDestroyMethodName destroy method name} for a bean as opposed to
|
||||||
* specification of a method name. The value {@value} is specifically designed to
|
* explicit specification of a method name. The value {@value} is specifically
|
||||||
* include characters otherwise illegal in a method name, ensuring no possibility of
|
* designed to include characters otherwise illegal in a method name, ensuring
|
||||||
* collisions with legitimately named methods having the same name.
|
* no possibility of collisions with legitimately named methods having the same
|
||||||
|
* name.
|
||||||
|
* <p>Currently, the method names detected during destroy method inference
|
||||||
|
* are "close" and "shutdown", if present on the specific bean class.
|
||||||
*/
|
*/
|
||||||
public static final String INFER_METHOD = "(inferred)";
|
public static final String INFER_METHOD = "(inferred)";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 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.
|
||||||
@@ -197,25 +197,26 @@ public @interface Bean {
|
|||||||
/**
|
/**
|
||||||
* The optional name of a method to call on the bean instance during initialization.
|
* The optional name of a method to call on the bean instance during initialization.
|
||||||
* Not commonly used, given that the method may be called programmatically directly
|
* Not commonly used, given that the method may be called programmatically directly
|
||||||
* within the body of a Bean-annotated method. Default value is {@code ""}, indicating
|
* within the body of a Bean-annotated method.
|
||||||
* that no init method should be called.
|
* <p>The default value is {@code ""}, indicating no init method to be called.
|
||||||
*/
|
*/
|
||||||
String initMethod() default "";
|
String initMethod() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The optional name of a method to call on the bean instance upon closing the
|
* The optional name of a method to call on the bean instance upon closing the
|
||||||
* application context, for example a {@code close()} method on a JDBC {@code
|
* application context, for example a {@code close()} method on a JDBC
|
||||||
* DataSource} implementation, or a Hibernate {@code SessionFactory} object.
|
* {@code DataSource} implementation, or a Hibernate {@code SessionFactory} object.
|
||||||
* The method must have no arguments but may throw any exception.
|
* The method must have no arguments but may throw any exception.
|
||||||
* <p>As a convenience to the user, the container will attempt to infer a destroy
|
* <p>As a convenience to the user, the container will attempt to infer a destroy
|
||||||
* method against an object returned from the {@code @Bean} method. For example, given a
|
* method against an object returned from the {@code @Bean} method. For example, given
|
||||||
* {@code @Bean} method returning an Apache Commons DBCP {@code BasicDataSource}, the
|
* an {@code @Bean} method returning an Apache Commons DBCP {@code BasicDataSource},
|
||||||
* container will notice the {@code close()} method available on that object and
|
* the container will notice the {@code close()} method available on that object and
|
||||||
* automatically register it as the {@code destroyMethod}. This 'destroy method
|
* automatically register it as the {@code destroyMethod}. This 'destroy method
|
||||||
* inference' is currently limited to detecting only public, no-arg methods named
|
* inference' is currently limited to detecting only public, no-arg methods named
|
||||||
* 'close'. The method may be declared at any level of the inheritance hierarchy and
|
* 'close' or 'shutdown'. The method may be declared at any level of the inheritance
|
||||||
* will be detected regardless of the return type of the {@code @Bean} method (i.e.,
|
* hierarchy and will be detected regardless of the return type of the {@code @Bean}
|
||||||
* detection occurs reflectively against the bean instance itself at creation time).
|
* method (i.e., detection occurs reflectively against the bean instance itself at
|
||||||
|
* creation time).
|
||||||
* <p>To disable destroy method inference for a particular {@code @Bean}, specify an
|
* <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
|
* empty string as the value, e.g. {@code @Bean(destroyMethod="")}. Note that the
|
||||||
* {@link org.springframework.beans.factory.DisposableBean} and the
|
* {@link org.springframework.beans.factory.DisposableBean} and the
|
||||||
|
|||||||
Reference in New Issue
Block a user