Spring Bean Aware Interfaces
Why do we need Spring Bean Aware Interfaces?
Sometimes spring bean might need access to different resource like ApplicationContext, BeanFactory. Spring Framework provides a set of interfaces that can help spring bean to get access of required resource.
Root Interface
Aware Interface
- Aware interface is the root marker interface.
- All the
@@@ Aware interfaces extendsAware interface and declares aset@@@ method.
Example :
Different types of Aware interfaces
1. BeanNameAware
setBeanName method makes bean aware of its name defined in container (Application Context).
2. BeanFactoryAware
setBeanFactory method makes bean aware of its Bean Factory that created the bean.
3. ApplicationContextAware
setApplicationContext method makes bean aware of its Application Context.
4. BeanClassLoaderAware
setBeanClassLoader method makes bean aware of its class loader.