Aware Interfaces, FactoryBean, Method Injection and Programmatic Bean Access
Learn Aware Interfaces, FactoryBean, Method Injection and Programmatic Bean Access (Phase 6 · Spring Container (Essential), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Aware interfaces • Aware callbacks give a bean access to container infrastructure: BeanNameAware , BeanFactoryAware , BeanClassLoaderAware , ApplicationContextAware , EnvironmentAware , ResourceLoaderAware , ApplicationEventPublisherAware , MessageSourceAware , EmbeddedValueResolverAware . They run after dependency injection and before @PostConstruct ( ApplicationContextAwareProcessor handles most). • They couple code to Spring, so use them in infrastructure/framework code ; in application beans inject the needed type directly ( Environment , ApplicationEventPublisher and ApplicationContext...