package server.config;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.annotation.WebListener;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@WebListener
public class SpringConfigInitializer extends ContextLoaderListener {
public static final String SPRING_CONTEXT = "spring-ctx";
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
final AnnotationConfigWebApplicationContext springCtx = new AnnotationConfigWebApplicationContext();
springCtx.setServletContext(sc);
springCtx.scan("server");
springCtx.refresh();
sc.setAttribute(SPRING_CONTEXT, springCtx);
return springCtx;
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}