Subversion Repositories SmartDukaan

Rev

Rev 21734 | Rev 35385 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21165 ashik.ali 1
package com.spice.profitmandi.web.config;
2
 
3
import javax.servlet.ServletContext;
4
 
5
import javax.servlet.ServletException;
6
import javax.servlet.ServletRegistration;
7
 
23568 govind 8
import org.apache.logging.log4j.Logger;
9
import org.apache.logging.log4j.LogManager;
21165 ashik.ali 10
import org.springframework.web.WebApplicationInitializer;
11
import org.springframework.web.context.ContextLoaderListener;
12
import org.springframework.web.context.WebApplicationContext;
13
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
14
import org.springframework.web.servlet.DispatcherServlet;
15
 
16
public class SpringWebAppInitializer implements WebApplicationInitializer{
17
 
23568 govind 18
	private static final Logger LOGGER=LogManager.getLogger(SpringWebAppInitializer.class);
21165 ashik.ali 19
 
20
	private static final String DISPATCHER_SERVLET_NAME="DispatcherServlet";
21220 ashik.ali 21
	private static final String SPRING_CONFIG_PACKAGE_LOCATION="com.spice.profitmandi.web.config";
21165 ashik.ali 22
 
23
	public void onStartup(ServletContext servletContext) throws ServletException {
24
		WebApplicationContext context = getContext();
25
        servletContext.addListener(new ContextLoaderListener(context));
26
        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(context));
27
        dispatcher.setLoadOnStartup(1);
28
        dispatcher.addMapping("/");
29
        LOGGER.info("Context is loaded");
30
	}
31
 
32
	private AnnotationConfigWebApplicationContext getContext() {
33
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
34
        context.setConfigLocation(SPRING_CONFIG_PACKAGE_LOCATION);
35
        return context;
36
    }
37
 
38
 
39
}