List of usage examples for org.springframework.web.context ContextLoaderListener ContextLoaderListener
public ContextLoaderListener(WebApplicationContext context)
From source file:org.jumpmind.metl.ui.init.AppInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { Properties properties = loadProperties(); AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); applicationContext.scan("org.jumpmind.metl"); MutablePropertySources sources = applicationContext.getEnvironment().getPropertySources(); sources.addLast(new PropertiesPropertySource("passed in properties", properties)); servletContext.addListener(new ContextLoaderListener(applicationContext)); servletContext.addListener(this); servletContext.addListener(new RequestContextListener()); AnnotationConfigWebApplicationContext dispatchContext = new AnnotationConfigWebApplicationContext(); dispatchContext.setParent(applicationContext); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatchContext)); dispatcher.setLoadOnStartup(1);/*from ww w.j a v a 2s . c o m*/ dispatcher.addMapping("/api/*"); applicationContextRef.set(dispatchContext); ServletRegistration.Dynamic apidocs = servletContext.addServlet("apidocs", DefaultServlet.class); apidocs.addMapping("/api.html", "/doc/*"); ServletRegistration.Dynamic vaadin = servletContext.addServlet("vaadin", AppServlet.class); vaadin.setAsyncSupported(true); vaadin.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName()); vaadin.setInitParameter("beanName", "appUI"); vaadin.addMapping("/*"); }
From source file:org.springframework.boot.context.web.SpringBootServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Logger initialization is deferred in case a ordered // LogServletContextInitializer is being used this.logger = LogFactory.getLog(getClass()); WebApplicationContext rootAppContext = createRootApplicationContext(servletContext); if (rootAppContext != null) { servletContext.addListener(new ContextLoaderListener(rootAppContext) { @Override//www.j ava 2 s.c om public void contextInitialized(ServletContextEvent event) { // no-op because the application context is already initialized } }); } else { this.logger.debug("No ContextLoaderListener registered, as " + "createRootApplicationContext() did not " + "return an application context"); } }
From source file:org.springframework.boot.web.servlet.support.SpringBootServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Logger initialization is deferred in case an ordered // LogServletContextInitializer is being used this.logger = LogFactory.getLog(getClass()); WebApplicationContext rootAppContext = createRootApplicationContext(servletContext); if (rootAppContext != null) { servletContext.addListener(new ContextLoaderListener(rootAppContext) { @Override/*from w w w . j ava2s . c o m*/ public void contextInitialized(ServletContextEvent event) { // no-op because the application context is already initialized } }); } else { this.logger.debug("No ContextLoaderListener registered, as " + "createRootApplicationContext() did not " + "return an application context"); } }
From source file:org.springframework.boot.web.SpringBootServletInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { WebApplicationContext rootAppContext = this.createRootApplicationContext(servletContext); if (rootAppContext != null) { servletContext.addListener(new ContextLoaderListener(rootAppContext) { @Override/*from w w w. j a v a 2s . c o m*/ public void contextInitialized(ServletContextEvent event) { // no-op because the application context is already initialized } }); } else { this.logger.debug("No ContextLoaderListener registered, as " + "createRootApplicationContext() did not " + "return an application context"); } }
From source file:org.springframework.web.context.AbstractContextLoaderInitializer.java
/** * Register a {@link ContextLoaderListener} against the given servlet context. The * {@code ContextLoaderListener} is initialized with the application context returned * from the {@link #createRootApplicationContext()} template method. * @param servletContext the servlet context to register the listener against *//*from w w w. j a va2 s .c om*/ protected void registerContextLoaderListener(ServletContext servletContext) { WebApplicationContext rootAppContext = createRootApplicationContext(); if (rootAppContext != null) { ContextLoaderListener listener = new ContextLoaderListener(rootAppContext); listener.setContextInitializers(getRootApplicationContextInitializers()); servletContext.addListener(listener); } else { logger.debug("No ContextLoaderListener registered, as " + "createRootApplicationContext() did not return an application context"); } }