Examples of AnnotationConfigWebApplicationContext


Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    private static final Logger LOG = LoggerFactory.getLogger(MyWebAppInitializer.class);

    @Override
    public void onStartup(ServletContext container) {
        // Create the 'root' Spring application context
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        // Register application config
        rootContext.register(AppConfig.class);

        // Manage the lifecycle of the root application context
        container.addListener(new ContextLoaderListener(rootContext));

        // Register Encoding Filter
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    // SLF4JBridgeHandler.install();
   
    log.debug("${artifactId} starting up...");

    // Create the 'root' Spring application context
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.register(SpringConfiguration.class);
    ctx.refresh();
   
    // Register the Spring Context in the ServletContext
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);

    // Manages the lifecycle
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    context.getBean(Validator.class); // Fails as there are two Validator beans in the context
  }

  @Test
  public void noExplicitValidator() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(MyConfiguration.class);
    context.setServletContext(new MockServletContext());
    context.refresh(); // Fails as there's no Validator bean in the context
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    private static final Logger logger = org.slf4j.LoggerFactory.getLogger(AppInitializer.class);

    @Override
    public void onStartup(ServletContext container) {

        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(AppRootConfig.class);

        // Manage the lifecycle of the root application context
        container.addListener(new ContextLoaderListener(rootContext));

        container.addFilter("resourceUrlEncodingFilter", ResourceUrlEncodingFilter.class).addMappingForUrlPatterns(
                EnumSet.allOf(DispatcherType.class), false, "/*");

        // Create the dispatcher servlet's Spring application context
        AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
        dispatcherContext.register(WebConfig.class);

        // Register and map the dispatcher servlet
        ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(
                dispatcherContext));
        dispatcher.setLoadOnStartup(1);
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

public class WebInitializer implements WebApplicationInitializer {

  @Override
  public void onStartup(ServletContext servletContext) throws ServletException {
    // Create the dispatcher servlet's Spring application context
    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(WebConfiguration.class);

    servletContext.addListener(new ContextLoaderListener(dispatcherContext));


    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    registerOpenEntityManagerInViewFilter(servletContext);
    registerSpringSecurityFilterChain(servletContext);
  }

  private void registerDispatcherServlet(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext dispatcherContext = createContext(WebMvcContextConfiguration.class);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
        new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

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

  private void registerListener(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = createContext(configurationClasses);
    servletContext.addListener(new ContextLoaderListener(rootContext));
    servletContext.addListener(new RequestContextListener());
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

   * Factory method to create {@link AnnotationConfigWebApplicationContext} instances.
   * @param annotatedClasses
   * @return
   */
  private AnnotationConfigWebApplicationContext createContext(final Class<?>... annotatedClasses) {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(annotatedClasses);
    return context;
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

    registerOpenEntityManagerInViewFilter(servletContext);

  }

  private void registerDispatcherServlet(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext dispatcherContext = createContext(WebMvcContextConfiguration.class);
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
        new DispatcherServlet(dispatcherContext));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
  }
View Full Code Here

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

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

  private void registerListener(ServletContext servletContext) {
    AnnotationConfigWebApplicationContext rootContext = createContext(InfrastructureContextConfiguration.class,
        TestDataContextConfiguration.class);
    servletContext.addListener(new ContextLoaderListener(rootContext));
  }
View Full Code Here
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.