Customize destruction callback for AutoCloseable beans

Previously, a Bean implementing `AutoCloseable` (or `Closeable`) was
always destroyed regardless of its bean definition. In particular, the
documented way of disabling the destruction callback via an empty String
did not work.

AutoCloseable beans are now treated pretty much as any other bean: we
still use the presence of the interface to optimize the check of a
destroy method and we only auto-discover the method name to invoke if
the inferred mode is enabled.

Issue: SPR-13022
This commit is contained in:
Stephane Nicoll
2015-05-15 11:22:29 +02:00
parent 271804f105
commit 0ed9ca097b
8 changed files with 32 additions and 15 deletions

View File

@@ -11,6 +11,10 @@
class="org.springframework.context.annotation.DestroyMethodInferenceTests$WithLocalCloseMethod"
destroy-method="(inferred)"/>
<bean id="x8"
class="org.springframework.context.annotation.DestroyMethodInferenceTests.WithInheritedCloseMethod"
destroy-method=""/>
<beans default-destroy-method="(inferred)">
<bean id="x3"
class="org.springframework.context.annotation.DestroyMethodInferenceTests$WithLocalCloseMethod"/>