Package org.springframework.web.context

Examples of org.springframework.web.context.ContextLoaderListener


    public void onStartup(ServletContext sc) throws ServletException {

        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.getEnvironment().addActiveProfile("web");
        rootContext.register(WebSpringConfig.class);
        sc.addListener(new ContextLoaderListener(rootContext));

        // Create the dispatcher servlet's Spring application context
        AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
        dispatcherContext.setParent(rootContext);
        // Register and map the dispatcher servlet
View Full Code Here


      this.context.setInitParameter(PERSISTENCE_LOCATION, persistence.getAbsolutePath());
    }
    this.context.setInitParameter(SANDBOX_STATUS, sanboxStatus + "");

    // Add listener
    ContextLoaderListener listener = new ContextLoaderListener();
    this.context.addEventListener(listener);

    // Create servlet
    DispatcherServlet servlet = new DispatcherServlet();
    ServletHolder holder = new ServletHolder(servlet);
View Full Code Here

    final WebAppContext context = new WebAppContext();
    context.setContextPath("/");
    context.setResourceBase("build/classes");
    context.setDescriptor("web-push/WEB-INF/web.xml");
    context.setInitParameter("contextConfigLocation", springXml);
    context.addEventListener(new ContextLoaderListener());
    final Server server = new Server();
    server.setHandler(context);
    final SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(_port);
    server.addConnector(connector);
View Full Code Here

        final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
        root.scan("org.baeldung.config.parent");
        // root.getEnvironment().setDefaultProfiles("embedded");

        // Manages the lifecycle of the root application context
        sc.addListener(new ContextLoaderListener(root));

        // Handles requests into the application
        final AnnotationConfigWebApplicationContext childWebApplicationContext = new AnnotationConfigWebApplicationContext();
        childWebApplicationContext.scan("org.baeldung.config.child");
        final ServletRegistration.Dynamic appServlet = sc.addServlet("api", new DispatcherServlet(childWebApplicationContext));
View Full Code Here

  protected void registerContextLoaderListener( ServletContext servletContext ) {
    WebApplicationContext rootAppContext = createRootApplicationContext();
    if ( rootAppContext != null ) {
      servletContext.setAttribute( DYNAMIC_INITIALIZER, this );

      ContextLoaderListener listener = new ShutdownOnlyContextLoaderListener( rootAppContext );
      listener.initWebApplicationContext( servletContext );
      servletContext.removeAttribute( DYNAMIC_INITIALIZER );

      servletContext.addListener( listener );
    }
    else {
View Full Code Here

        appContext.setDisplayName(applicationProperties.getProperty("application.name"));
        appContext.getEnvironment().setActiveProfiles(applicationEnvironment);
        log.info("Starting up Application with the following active profiles: " + join(appContext.getEnvironment().getActiveProfiles(), ", "));

        // Enable Application Context with Context Loader Listner
        servletContext.addListener(new ContextLoaderListener(appContext));

        // Register Dispatcher Servlet
        ServletRegistration.Dynamic dispatcherServlet =
                servletContext.addServlet("dispatcherServlet", new DispatcherServlet(appContext));
        dispatcherServlet.setLoadOnStartup(1);
View Full Code Here

  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));
View Full Code Here

TOP

Related Classes of org.springframework.web.context.ContextLoaderListener

Copyright © 2018 www.massapicom. 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.