Browse Source

Clarify enforceInitMethod/enforceDestroyMethod default values

Closes gh-25402

(cherry picked from commit 5846d9c2ea)
5.0.x
Juergen Hoeller 6 years ago
parent
commit
b904d5268a
  1. 18
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java
  2. 14
      spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java

18
spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java

@ -896,16 +896,20 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess @@ -896,16 +896,20 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
}
/**
* Specify whether or not the configured init method is the default.
* <p>The default value is {@code false}.
* Specify whether or not the configured initializer method is the default.
* <p>The default value is {@code true} for a locally specified init method
* but switched to {@code false} for a shared setting in a defaults section
* (e.g. {@code bean init-method} versus {@code beans default-init-method}
* level in XML) which might not apply to all contained bean definitions.
* @see #setInitMethodName
* @see #applyDefaults
*/
public void setEnforceInitMethod(boolean enforceInitMethod) {
this.enforceInitMethod = enforceInitMethod;
}
/**
* Indicate whether the configured init method is the default.
* Indicate whether the configured initializer method is the default.
* @see #getInitMethodName()
*/
public boolean isEnforceInitMethod() {
@ -930,8 +934,12 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess @@ -930,8 +934,12 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Specify whether or not the configured destroy method is the default.
* <p>The default value is {@code false}.
* <p>The default value is {@code true} for a locally specified destroy method
* but switched to {@code false} for a shared setting in a defaults section
* (e.g. {@code bean destroy-method} versus {@code beans default-destroy-method}
* level in XML) which might not apply to all contained bean definitions.
* @see #setDestroyMethodName
* @see #applyDefaults
*/
public void setEnforceDestroyMethod(boolean enforceDestroyMethod) {
this.enforceDestroyMethod = enforceDestroyMethod;
@ -939,7 +947,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess @@ -939,7 +947,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
/**
* Indicate whether the configured destroy method is the default.
* @see #getDestroyMethodName
* @see #getDestroyMethodName()
*/
public boolean isEnforceDestroyMethod() {
return this.enforceDestroyMethod;

14
spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionDefaults.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -25,6 +25,7 @@ import org.springframework.util.StringUtils; @@ -25,6 +25,7 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @author Juergen Hoeller
* @since 2.5
* @see AbstractBeanDefinition#applyDefaults
*/
public class BeanDefinitionDefaults {
@ -45,6 +46,7 @@ public class BeanDefinitionDefaults { @@ -45,6 +46,7 @@ public class BeanDefinitionDefaults {
* Set whether beans should be lazily initialized by default.
* <p>If {@code false}, the bean will get instantiated on startup by bean
* factories that perform eager initialization of singletons.
* @see AbstractBeanDefinition#setLazyInit
*/
public void setLazyInit(boolean lazyInit) {
this.lazyInit = lazyInit;
@ -66,6 +68,7 @@ public class BeanDefinitionDefaults { @@ -66,6 +68,7 @@ public class BeanDefinitionDefaults {
* (however, there may still be explicit annotation-driven autowiring).
* @param autowireMode the autowire mode to set.
* Must be one of the constants defined in {@link AbstractBeanDefinition}.
* @see AbstractBeanDefinition#setAutowireMode
*/
public void setAutowireMode(int autowireMode) {
this.autowireMode = autowireMode;
@ -82,6 +85,7 @@ public class BeanDefinitionDefaults { @@ -82,6 +85,7 @@ public class BeanDefinitionDefaults {
* Set the dependency check code.
* @param dependencyCheck the code to set.
* Must be one of the constants defined in {@link AbstractBeanDefinition}.
* @see AbstractBeanDefinition#setDependencyCheck
*/
public void setDependencyCheck(int dependencyCheck) {
this.dependencyCheck = dependencyCheck;
@ -96,6 +100,10 @@ public class BeanDefinitionDefaults { @@ -96,6 +100,10 @@ public class BeanDefinitionDefaults {
/**
* Set the name of the default initializer method.
* <p>Note that this method is not enforced on all affected bean definitions
* but rather taken as an optional callback, to be invoked if actually present.
* @see AbstractBeanDefinition#setInitMethodName
* @see AbstractBeanDefinition#setEnforceInitMethod
*/
public void setInitMethodName(@Nullable String initMethodName) {
this.initMethodName = (StringUtils.hasText(initMethodName) ? initMethodName : null);
@ -111,6 +119,10 @@ public class BeanDefinitionDefaults { @@ -111,6 +119,10 @@ public class BeanDefinitionDefaults {
/**
* Set the name of the default destroy method.
* <p>Note that this method is not enforced on all affected bean definitions
* but rather taken as an optional callback, to be invoked if actually present.
* @see AbstractBeanDefinition#setDestroyMethodName
* @see AbstractBeanDefinition#setEnforceDestroyMethod
*/
public void setDestroyMethodName(@Nullable String destroyMethodName) {
this.destroyMethodName = (StringUtils.hasText(destroyMethodName) ? destroyMethodName : null);

Loading…
Cancel
Save