Subversion Repositories SmartDukaan

Rev

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

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