BeanPostProcessor

What is it for? Execute a block of code for each and every bean that is initialised. Bean Post Processor is a separate class Spring executes the code in the Post Processor after initializing each and every bean Example Print the Name of Every Bean that is Initialized DisplayNameBeanPostProcessor Register the BeanPostProcessor with Spring Spring.xml

Lifecycle Callbacks

Execute Code after Bean Initialized make Bean implement InitializingBean override method public void afterPropertiesSet() code is executed just after the properties have been set Problem tightly coupled to Spring Framework Execute Code before Bean is Destroyed make Bean implement DisposableBean override method public void destroy() code is executed just before the bean is destroyed Problem... Continue Reading →

ApplicationContextAware

Why do we need it? Allows our beans to reference the context Allows our beans to perform a getBean() from within rather Used if dependents are prototypes that we want to be created each time Otherwise, Spring injects singleton dependents during initialisation In the Bean Make Spring Bean implement ApplicationContextAware create private member variable for... Continue Reading →

Spring 3 – Injecting Values with XML Config

Overview This post demonstrates setting Spring Bean property values using an xml config file. The example demonstrates the following principles: setter injection constructor injection (by index) multiple argument injection (by name) bean injection by reference list injection (by value and by reference) aliases Example The following example is presented as a Maven Project.  The Spring... Continue Reading →

Up ↑

%d bloggers like this: