Skip to content

Commit d67034f

Browse files
committed
Document semantics for externally managed init/destroy methods
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
1 parent dcdea98 commit d67034f

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

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

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public void registerExternallyManagedConfigMember(Member configMember) {
437437
}
438438

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

449449
/**
450-
* Return all externally managed configuration methods and fields (as an immutable Set).
450+
* Get all externally managed configuration methods and fields (as an immutable Set).
451451
* @since 5.3.11
452452
*/
453453
public Set<Member> getExternallyManagedConfigMembers() {
@@ -459,7 +459,15 @@ public Set<Member> getExternallyManagedConfigMembers() {
459459
}
460460

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

473481
/**
474-
* Check whether the given method name indicates an externally managed initialization method.
482+
* Determine if the given method name indicates an externally managed
483+
* initialization method.
484+
* <p>See {@link #registerExternallyManagedInitMethod} for details
485+
* regarding the format for the supplied {@code initMethod}.
475486
*/
476487
public boolean isExternallyManagedInitMethod(String initMethod) {
477488
synchronized (this.postProcessingLock) {
@@ -484,10 +495,10 @@ public boolean isExternallyManagedInitMethod(String initMethod) {
484495
* Determine if the given method name indicates an externally managed
485496
* initialization method, regardless of method visibility.
486497
* <p>In contrast to {@link #isExternallyManagedInitMethod(String)}, this
487-
* method also returns {@code true} if there is a {@code private} external
488-
* init method that has been
498+
* method also returns {@code true} if there is a {@code private} externally
499+
* managed initialization method that has been
489500
* {@linkplain #registerExternallyManagedInitMethod(String) registered}
490-
* using a fully qualified method name instead of a simple method name.
501+
* using a qualified method name instead of a simple method name.
491502
* @since 5.3.17
492503
*/
493504
boolean hasAnyExternallyManagedInitMethod(String initMethod) {
@@ -512,6 +523,8 @@ boolean hasAnyExternallyManagedInitMethod(String initMethod) {
512523

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

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

537558
/**
538-
* Check whether the given method name indicates an externally managed destruction method.
559+
* Determine if the given method name indicates an externally managed
560+
* destruction method.
561+
* <p>See {@link #registerExternallyManagedDestroyMethod} for details
562+
* regarding the format for the supplied {@code destroyMethod}.
539563
*/
540564
public boolean isExternallyManagedDestroyMethod(String destroyMethod) {
541565
synchronized (this.postProcessingLock) {
@@ -548,10 +572,10 @@ public boolean isExternallyManagedDestroyMethod(String destroyMethod) {
548572
* Determine if the given method name indicates an externally managed
549573
* destruction method, regardless of method visibility.
550574
* <p>In contrast to {@link #isExternallyManagedDestroyMethod(String)}, this
551-
* method also returns {@code true} if there is a {@code private} external
552-
* destroy method that has been
575+
* method also returns {@code true} if there is a {@code private} externally
576+
* managed destruction method that has been
553577
* {@linkplain #registerExternallyManagedDestroyMethod(String) registered}
554-
* using a fully qualified method name instead of a simple method name.
578+
* using a qualified method name instead of a simple method name.
555579
* @since 5.3.17
556580
*/
557581
boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) {
@@ -575,7 +599,9 @@ boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) {
575599
}
576600

577601
/**
578-
* Return all externally managed destruction methods (as an immutable Set).
602+
* Get all externally managed destruction methods (as an immutable Set).
603+
* <p>See {@link #registerExternallyManagedDestroyMethod} for details
604+
* regarding the format for the destruction methods in the returned set.
579605
* @since 5.3.11
580606
*/
581607
public Set<String> getExternallyManagedDestroyMethods() {

0 commit comments

Comments
 (0)