Subversion Repositories SmartDukaan

Rev

Rev 21220 | Rev 21734 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.config;

import javax.servlet.ServletContext;

import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

public class SpringWebAppInitializer implements WebApplicationInitializer{
        
        private static final Logger LOGGER=LoggerFactory.getLogger(SpringWebAppInitializer.class);
        
        private static final String DISPATCHER_SERVLET_NAME="DispatcherServlet";
        private static final String SPRING_CONFIG_PACKAGE_LOCATION="com.spice.profitmandi.web.config";
        
        public void onStartup(ServletContext servletContext) throws ServletException {
                WebApplicationContext context = getContext();
        servletContext.addListener(new ContextLoaderListener(context));
        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(context));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
        LOGGER.info("Context is loaded");
        }
        
        private AnnotationConfigWebApplicationContext getContext() {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation(SPRING_CONFIG_PACKAGE_LOCATION);
        return context;
    }
        
        
}