Programing/JVM(Java, Kotlin)
후벼파는 스프링 - ApplicationContext의 디폴트
나모찾기
2015. 2. 2. 20:00
스프링 튜토리얼에 보면 1ApplicationContext 인터페이스는 BeanFactory 인터페이스의 서브-인터페이스이며, 스프링의 AOP 기능 등과 통합을 더 쉽게 한다라고 적혀있다. 또한 웹 어플리케이션을 위하여 WebApplicationContext를 소개하고 있다.
그런데 HttpServletBean를 상속하고 있는 FrameworkServlet의 경우 WebApplicationContext 인터페이스의 구현체를 XmlWebApplicationContext를 사용하고 있었다.
public abstract class FrameworkServlet extends HttpServletBean {
/* ... */
public static final Class<?> DEFAULT_CONTEXT_CLASS
= XmlWebApplicationContext.class;
/* ... */
private Class<?> contextClass = DEFAULT_CONTEXT_CLASS;
}
FrameworkServlet에서는 createWebApplicationContext 메소드를 통해 ContextClass를 획득을 하고 org.springframework.beans.BeanUtils.instantiateClass에 의해 생성이 된다.
- 5.1 Introduction to the Spring IoC container and beans http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html [본문으로]