What is the difference between implementing the BeanPostProcessor
interface and either using the init
/destroy
method attributes in the XML
Just a short supplement to all the answers above: If you have any generic logic, common logic that needs to be universally applied to all your Spring beans, such as the injection of a logger to your beans, setting of a properties file, setting default values to fields of your beans through reflection; you could put that logic into ONE single place: the @Override
n callbacks (eg: postProcessBeforeInitialization(Object arg0, String arg1)
if you are implementing the BeanPostProcessor
interface); instead of duplicating the same logic across all your beans.