Package ua.ck.geekhub

Source Code of ua.ck.geekhub.Initializer

package ua.ck.geekhub;

import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

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

/**
* @author vladimirb
* @since 3/12/14
*/
public class Initializer implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();

    rootContext.register(WebMvcConfig.class, HibernateConfig.class);

    servletContext.addListener(new ContextLoaderListener(rootContext));
    rootContext.setServletContext(servletContext);

    ServletRegistration.Dynamic dispatcher =
        servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext));

    dispatcher.addMapping("/");
    dispatcher.setLoadOnStartup(1);

  }
}
TOP

Related Classes of ua.ck.geekhub.Initializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.