Skip to content

Commit

Permalink
Document semantics for externally managed init/destroy methods
Browse files Browse the repository at this point in the history
This commit introduces Javadoc to explain the difference between
init/destroy method names when such methods are private, namely that a
private method is registered via its qualified method name; whereas, a
non-private method is registered via its simple name.

See gh-28083
  • Loading branch information
sbrannen committed Mar 1, 2022
1 parent dcdea98 commit d67034f
Showing 1 changed file with 39 additions and 13 deletions.
Expand Up @@ -437,7 +437,7 @@ public void registerExternallyManagedConfigMember(Member configMember) {
}

/**
* Check whether the given method or field is an externally managed configuration member.
* Determine if the given method or field is an externally managed configuration member.
*/
public boolean isExternallyManagedConfigMember(Member configMember) {
synchronized (this.postProcessingLock) {
Expand All @@ -447,7 +447,7 @@ public boolean isExternallyManagedConfigMember(Member configMember) {
}

/**
* Return all externally managed configuration methods and fields (as an immutable Set).
* Get all externally managed configuration methods and fields (as an immutable Set).
* @since 5.3.11
*/
public Set<Member> getExternallyManagedConfigMembers() {
Expand All @@ -459,7 +459,15 @@ public Set<Member> getExternallyManagedConfigMembers() {
}

/**
* Register an externally managed configuration initialization method.
* Register an externally managed configuration initialization method &mdash;
* for example, a method annotated with JSR-250's
* {@link javax.annotation.PostConstruct} annotation.
* <p>The supplied {@code initMethod} may be the
* {@linkplain Method#getName() simple method name} for non-private methods or the
* {@linkplain org.springframework.util.ClassUtils#getQualifiedMethodName(Method)
* qualified method name} for {@code private} methods. A qualified name is
* necessary for {@code private} methods in order to disambiguate between
* multiple private methods with the same name within a class hierarchy.
*/
public void registerExternallyManagedInitMethod(String initMethod) {
synchronized (this.postProcessingLock) {
Expand All @@ -471,7 +479,10 @@ public void registerExternallyManagedInitMethod(String initMethod) {
}

/**
* Check whether the given method name indicates an externally managed initialization method.
* Determine if the given method name indicates an externally managed
* initialization method.
* <p>See {@link #registerExternallyManagedInitMethod} for details
* regarding the format for the supplied {@code initMethod}.
*/
public boolean isExternallyManagedInitMethod(String initMethod) {
synchronized (this.postProcessingLock) {
Expand All @@ -484,10 +495,10 @@ public boolean isExternallyManagedInitMethod(String initMethod) {
* Determine if the given method name indicates an externally managed
* initialization method, regardless of method visibility.
* <p>In contrast to {@link #isExternallyManagedInitMethod(String)}, this
* method also returns {@code true} if there is a {@code private} external
* init method that has been
* method also returns {@code true} if there is a {@code private} externally
* managed initialization method that has been
* {@linkplain #registerExternallyManagedInitMethod(String) registered}
* using a fully qualified method name instead of a simple method name.
* using a qualified method name instead of a simple method name.
* @since 5.3.17
*/
boolean hasAnyExternallyManagedInitMethod(String initMethod) {
Expand All @@ -512,6 +523,8 @@ boolean hasAnyExternallyManagedInitMethod(String initMethod) {

/**
* Return all externally managed initialization methods (as an immutable Set).
* <p>See {@link #registerExternallyManagedInitMethod} for details
* regarding the format for the initialization methods in the returned set.
* @since 5.3.11
*/
public Set<String> getExternallyManagedInitMethods() {
Expand All @@ -523,7 +536,15 @@ public Set<String> getExternallyManagedInitMethods() {
}

/**
* Register an externally managed configuration destruction method.
* Register an externally managed configuration destruction method &mdash;
* for example, a method annotated with JSR-250's
* {@link javax.annotation.PreDestroy} annotation.
* <p>The supplied {@code destroyMethod} may be the
* {@linkplain Method#getName() simple method name} for non-private methods or the
* {@linkplain org.springframework.util.ClassUtils#getQualifiedMethodName(Method)
* qualified method name} for {@code private} methods. A qualified name is
* necessary for {@code private} methods in order to disambiguate between
* multiple private methods with the same name within a class hierarchy.
*/
public void registerExternallyManagedDestroyMethod(String destroyMethod) {
synchronized (this.postProcessingLock) {
Expand All @@ -535,7 +556,10 @@ public void registerExternallyManagedDestroyMethod(String destroyMethod) {
}

/**
* Check whether the given method name indicates an externally managed destruction method.
* Determine if the given method name indicates an externally managed
* destruction method.
* <p>See {@link #registerExternallyManagedDestroyMethod} for details
* regarding the format for the supplied {@code destroyMethod}.
*/
public boolean isExternallyManagedDestroyMethod(String destroyMethod) {
synchronized (this.postProcessingLock) {
Expand All @@ -548,10 +572,10 @@ public boolean isExternallyManagedDestroyMethod(String destroyMethod) {
* Determine if the given method name indicates an externally managed
* destruction method, regardless of method visibility.
* <p>In contrast to {@link #isExternallyManagedDestroyMethod(String)}, this
* method also returns {@code true} if there is a {@code private} external
* destroy method that has been
* method also returns {@code true} if there is a {@code private} externally
* managed destruction method that has been
* {@linkplain #registerExternallyManagedDestroyMethod(String) registered}
* using a fully qualified method name instead of a simple method name.
* using a qualified method name instead of a simple method name.
* @since 5.3.17
*/
boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) {
Expand All @@ -575,7 +599,9 @@ boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) {
}

/**
* Return all externally managed destruction methods (as an immutable Set).
* Get all externally managed destruction methods (as an immutable Set).
* <p>See {@link #registerExternallyManagedDestroyMethod} for details
* regarding the format for the destruction methods in the returned set.
* @since 5.3.11
*/
public Set<String> getExternallyManagedDestroyMethods() {
Expand Down

0 comments on commit d67034f

Please sign in to comment.