package kr.co.jinwoosi.clfd.framework.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import kr.co.jinwoosi.clfd.conts.bod.service.BodService;
import kr.co.jinwoosi.clfd.conts.menu.service.MenuService;
import kr.co.jinwoosi.clfd.conts.site.service.SiteService;
import org.springframework.web.context.support.WebApplicationContextUtils;

import kr.co.jinwoosi.clfd.framework.cd.service.CdDtlService;

public class InitJsonListener implements ServletContextListener {
	private CdDtlService cdDtlService;
	private SiteService siteService;
	private BodService bodService;
	private MenuService cmsMenuService;
	
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {}

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		// cdDtlService = WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext()).getBean(CdDtlService.class);
		// cdDtlService.initJson();
		
		siteService = WebApplicationContextUtils.getRequiredWebApplicationContext(
				sce.getServletContext()).getBean(SiteService.class);
		siteService.initJson();
		
		bodService =  WebApplicationContextUtils.getRequiredWebApplicationContext(
				sce.getServletContext()).getBean(BodService.class);
		bodService.initJson();
		
		cmsMenuService = WebApplicationContextUtils.getRequiredWebApplicationContext(
				sce.getServletContext()).getBean(MenuService.class);
		cmsMenuService.initJson();
	}
}
