Package server.config

Source Code of server.config.SpringConfigInitializer

package server.config;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.annotation.WebListener;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;

@WebListener
public class SpringConfigInitializer extends ContextLoaderListener {

    public static final String SPRING_CONTEXT = "spring-ctx";

    @Override
    protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
  final AnnotationConfigWebApplicationContext springCtx = new AnnotationConfigWebApplicationContext();
  springCtx.setServletContext(sc);
  springCtx.scan("server");
  springCtx.refresh();

  sc.setAttribute(SPRING_CONTEXT, springCtx);

  return springCtx;
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
    }
}
TOP

Related Classes of server.config.SpringConfigInitializer

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.