Bean Scope

- prototype으로 하면 매 생성마다 새로운 객체를 생성함
- 빈이 생성되고, 존재하고, 적용되는 범위가 빈 스코프임
- 싱글톤은 컨테이너 내에 한 개의 오브젝트만
- 리퀘스트 : 웹을 통해 새로운 HTTP 요청이 생길 때마다 생성
Bean Lifecycle Callback

Bean life cycle event 제어하는 방법
InitializingBean
andDisposableBean
callback interfaces
- Aware interfaces for specific behavior
- Custom
init()
anddestroy()
methods in bean configuration file
@PostConstruct
and@PreDestroy
annotations
Bean 생성 생명주기 콜백
@PostConsturct
어노테이션이 적용된 메소드 호출
- Bean 이 InitializingBean 인터페이스 구현시 afterPropertiesSet호출
- @Bean 어노테이션의
initMethod
에 설정한 메소드 호출
Bean 소멸 생성주기 콜백
@PreDestroy
어노테이션이 적용된 메서드 호출
- Bean이 DisposableBean 인터페이스 구현시 destroy 호출
- @Bean 어노테이션의
destroyMethod
에 설정한 메소드 호출