Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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