Stereotype annotations
Component Repository Service Controller RestController Configuration
Meta-annotation
Annotation can be used to create new annotations e.g. @Service, @MockBean. Example:
@Service
public @interface MyService {}
Bean initialization process
Bean deconstruction process
What are the use cases of spring.factories file?
2. Locate auto-configuration candidates
What is the name of objects created by the Spring IoC container?
Beans
Which of the following are valid ways of defining Spring bean metadata?
Why can I say “lifecycle management in Spring is consistent”?
regardless of the type of application - the way Spring behaves in a unit test is identical to how it will behave in production
Why can I say “lifecycle management in Spring is lightweight”?
It does not require deploying applications to a servlet container or other special environment
How to modify bean definitions?
What does PropertySourcesPlaceholderConfigurer do?
A BFPP that evaluates @Value(“expression”) and
List out 3 BFPP
What bean enables @PostConstruct, how is it implemented?
CommonAnnotationBeanPostProcessor extends BeanPostProcessor
Override postProcessBeforeInitialization
When does BeanPostProcessor.postProcessBeforeInitialization get called?
bean creation –> DI –> postProcessBeforeInitialization –> initializers called (e.g. InitializingBean’s afterPropertiesSet or a custom init-method)
When does BeanPostProcessor.postProcessAfterInitialization get called?
bean creation –> DI –> postProcessBeforeInitialization –> initializers called (e.g. InitializingBean’s afterPropertiesSet or a custom init-method) –> postProcessAfterInitialization
Input, output of BeanPostProcessor.postProcessBeforeInitialization
Object postProcessBeforeInitialization(Object originalBean, String beanName); return post processed bean
About JDK proxy
About CGLib proxy
How to force dependency order?
Using @DependsOn(value[]) Apply to component class and bean method
What are type and beanName created in this case?
@Bean
TransferService tfService() {
return new BankTransferServiceImpl();
}type: TransferService (not BankTransferServiceImpl)
name: tfService
Can CGLib prox private methods?
No, because it creates subclass of the target class so there’s no way to intercept private