Skip to content

Commit

Permalink
Clarify enforceInitMethod/enforceDestroyMethod default values
Browse files Browse the repository at this point in the history
Closes gh-25402

(cherry picked from commit 5846d9c)
  • Loading branch information
jhoeller committed Jul 17, 2020
1 parent bca6391 commit a6f7386
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Expand Up @@ -898,16 +898,20 @@ public String getInitMethodName() {
}

/**
* 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() {
Expand All @@ -934,16 +938,20 @@ public String getDestroyMethodName() {

/**
* 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;
}

/**
* Indicate whether the configured destroy method is the default.
* @see #getDestroyMethodName
* @see #getDestroyMethodName()
*/
public boolean isEnforceDestroyMethod() {
return this.enforceDestroyMethod;
Expand Down
@@ -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.
Expand All @@ -25,6 +25,7 @@
* @author Mark Fisher
* @author Juergen Hoeller
* @since 2.5
* @see AbstractBeanDefinition#applyDefaults
*/
public class BeanDefinitionDefaults {

Expand All @@ -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;
Expand All @@ -66,6 +68,7 @@ public boolean isLazyInit() {
* (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;
Expand All @@ -82,6 +85,7 @@ public int getAutowireMode() {
* 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;
Expand All @@ -96,6 +100,10 @@ public int getDependencyCheck() {

/**
* 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);
Expand All @@ -111,6 +119,10 @@ public String getInitMethodName() {

/**
* 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);
Expand Down

0 comments on commit a6f7386

Please sign in to comment.