Life Developer
인생 개발자
application context(어플리케이션 콘텍스트)?


어플리케이션 콘텍스트- 빈팩토리를 바로사용하지 않고 이것을 사용함. 여러종류가있다.

 

 

 

Application Context

  • Web Application 최상단에 위치하고 있는 Context
  • Spring에서 ApplicationContext란 BeanFactory를 상속받고 있는 Context
  • Spring에서 root-context.xml, applicationContext.xml 파일은 ApplicationContext 생성 시 필요한 설정정보를 담은 파일 (Bean 선언 등..)
  • Spring에서 생성되는 Bean에 대한 IoC (제어의 역전)Container (또는 Bean Container)
  • 특정 Servlet설정과 관계 없는 설정을 한다 (@Service, @Repository, @Configuration, @Component)
  • 서로 다른 여러 Servlet에서 공통적으로 공유해서 사용할 수 있는 Bean을 선언한다.
  • Application Context에 정의된 Bean은 Servlet Context에 정의 된 Bean을 사용할 수 없다.

Servlet-Context (servlet-context.xml)

  • Servlet 단위로 생성되는 context
  • Spring에서 servlet-context.xml 파일은 DispatcherServlet 생성 시에 필요한 설정 정보를 담은 파일 (Interceptor, Bean생성, ViewResolver등..)
  • URL설정이 있는 Bean을 생성 (@Controller, Interceptor)
  • Application Context를 자신의 부모 Context로 사용한다.
  • Application Context와 Servlet Context에 같은 id로 된 Bean이 등록 되는 경우, Servlet Context에 선언된 Bean을 사용한다.
  • Bean 찾는 순서
    • Servlet Context에서 먼저 찾는다.
    • 만약 Servlet Context에서 bean을 못찾는 경우 Application Context에 정의된 bean을 찾는다.
  • Servlet Context에 정의된 Bean은 Application Context의 Bean을 사용할 수 있다.

'Developer' 카테고리의 다른 글

Bean 등록 어노테이션  (0) 2020.07.29
JUnit 이란?  (0) 2020.07.29
Bean 이란? 빈 팩토리란?  (0) 2020.07.29
Spring DI 방법  (0) 2020.07.29
DL/DI ?  (0) 2020.07.29
  Comments,     Trackbacks