Examples of AnnotationConfigWebApplicationContext


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

        loadConfig(CustomSecurityConfig.class);
        assertThat(getSecurityContextRepository(request)).isSameAs(contextRepo);
    }

    private void loadConfig(Class<?> config) {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(config);
        context.refresh();
        this.context = context;
        request.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
    }
View Full Code Here

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

    @Override
    public void onStartup(final ServletContext sc) throws ServletException {

        //1、根上下文
        AnnotationConfigWebApplicationContext  rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(RootConfiguration.class);
        sc.addListener(new ContextLoaderListener(rootContext));

        //2、springmvc上下文
        AnnotationConfigWebApplicationContext springMvcContext = new AnnotationConfigWebApplicationContext();
        springMvcContext.register(SpringMvcConfiguration.class);

        //3、DispatcherServlet
        DispatcherServlet dispatcherServlet = new DispatcherServlet(springMvcContext);

        ServletRegistration.Dynamic dynamic = sc.addServlet("dispatcherServlet", dispatcherServlet);
View Full Code Here

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

   */
  @Override
  protected WebApplicationContext createRootApplicationContext() {
    Class<?>[] configClasses = getRootConfigClasses();
    if (!ObjectUtils.isEmpty(configClasses)) {
      AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
      rootAppContext.register(configClasses);
      return rootAppContext;
    }
    else {
      return null;
    }
View Full Code Here

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

   * <p>This implementation creates an {@link AnnotationConfigWebApplicationContext},
   * providing it the annotated classes returned by {@link #getServletConfigClasses()}.
   */
  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext servletAppContext = new AnnotationConfigWebApplicationContext();
    Class<?>[] configClasses = getServletConfigClasses();
    if (!ObjectUtils.isEmpty(configClasses)) {
      servletAppContext.register(configClasses);
    }
    return servletAppContext;
  }
View Full Code Here

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

    private static final String DISPATCHER_SERVLET_NAME = "dispatcher";
    private static final String DISPATCHER_SERVLET_MAPPING = "/";

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

        //XmlWebApplicationContext rootContext = new XmlWebApplicationContext();
        //rootContext.setConfigLocation("classpath:exampleApplicationContext.xml");

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

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

   */
  @Override
  protected WebApplicationContext createRootApplicationContext() {
    Class<?>[] rootConfigClasses = this.getRootConfigClasses();
    if (!ObjectUtils.isEmpty(rootConfigClasses)) {
      AnnotationConfigWebApplicationContext rootAppContext =
          new AnnotationConfigWebApplicationContext();
      rootAppContext.register(rootConfigClasses);
      return rootAppContext;
    }
    else {
      return null;
    }
View Full Code Here

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

   * @throws IllegalArgumentException if {@link #getServletConfigClasses()} returns
   * empty or {@code null}
   */
  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext servletAppContext =
        new AnnotationConfigWebApplicationContext();
    Class<?>[] servletConfigClasses = this.getServletConfigClasses();
    Assert.notEmpty(servletConfigClasses,
        "getServletConfigClasses() did not return any configuration classes");

    servletAppContext.register(servletConfigClasses);
    return servletAppContext;
  }
View Full Code Here

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

    public DispatcherServletChannelInitializer() throws ServletException {

      MockServletContext servletContext = new MockServletContext();
      MockServletConfig servletConfig = new MockServletConfig(servletContext);

      AnnotationConfigWebApplicationContext wac = new AnnotationConfigWebApplicationContext();
    wac.setServletContext(servletContext);
    wac.setServletConfig(servletConfig);
      wac.register(WebConfig.class);
      wac.refresh();

      this.dispatcherServlet = new DispatcherServlet(wac);
      this.dispatcherServlet.init(servletConfig);
  }
View Full Code Here

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

        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(MAPPING_URL);
    }

    private AnnotationConfigWebApplicationContext getContext() {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.setConfigLocation(CONFIG_LOCATION);
        return context;
    }
View Full Code Here

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

  @Override
  public void onStartup(final ServletContext servletContext)
      throws ServletException {

    AnnotationConfigWebApplicationContext root = null;

    // Bootstrap
    root = bootstrapSpring(servletContext);

    // Application Listeners (Spring, Logging, etc)
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.