When you use setter-based dependency injection, the init-method
makes it possible to perform initialization: the specified method will be called after all the setters have been called.
As per destroy-method
, it seems that implementing finalize
in Java classes is not a good practice, instead, and many libraries define a close
method which may or may not be called from finalize
. See this discussion:
https://stackoverflow.com/questions/158174/why-would-you-ever-implement-finalize
EDIT (to clarify things even further)
In setter-based injection methods will be called in the following order:
- default constructor
- the setters corresponding to each
<property>
of the bean
- the
init-method
, if specified
In constructor-based injection methods will be called in the following order:
- the matching constructor
- the
init-method
, if specified