Examples of AnnotationConfigWebApplicationContext


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

  // Initializes a Configurable Bean Context
  private AnnotationConfigWebApplicationContext bootstrapSpring(
      ServletContext servletContext) {

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(servletContext); // registers the servlet context
    root.register(ApplicationConfiguration.class,
        RepositoryConfiguration.class);
    root.refresh(); // refreshes all beans
    return root;
  }
View Full Code Here

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

   * Build a {@link MockMvc} from Java-based Spring configuration.
   * @param configClasses one or more @{@link Configuration} classes
   */
  public static ContextMockMvcBuilder annotationConfigSetup(Class<?>... configClasses) {
    Assert.notEmpty(configClasses, "At least one @Configuration class is required");
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(configClasses);
    return new ContextMockMvcBuilder(context);
  }
View Full Code Here

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

    public void autowire(ServletContext sc) {
  autowire(sc, this);
    }

    public static void autowire(ServletContext sc, Object target) {
  AnnotationConfigWebApplicationContext context = (AnnotationConfigWebApplicationContext) sc
          .getAttribute(SpringConfigInitializer.SPRING_CONTEXT);
  context.getBeanFactory().autowireBean(target);
    }
View Full Code Here

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

  @Override
  public void contextInitialized(ServletContextEvent sce) {
    final ServletContext ctx = sce.getServletContext();

    final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
    root.setServletContext(ctx);
    root.scan("app");
    root.refresh();

    final Dynamic servlet = ctx.addServlet("spring", new DispatcherServlet(root));
    servlet.setLoadOnStartup(1);
    servlet.addMapping("/");
  }
View Full Code Here

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

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

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

    private static final String DISPATCHER_SERVLET_MAPPING_PRODUCTS = "/products/*";
    private static final String DISPATCHER_SERVLET_MAPPING_SERVICES = "/services/*";
   
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING_HOME);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING_PRODUCTS);
View Full Code Here

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

    private static final String URL_REWRITE_FILTER_PARAM_LOGLEVEL = "logLevel";
    private static final String URL_REWRITE_FILTER_LOGLEVEL_SLF4J = "slf4j";
   
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

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

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

*/
public class ServletInitializer extends AbstractDispatcherServletInitializer {

  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.scan(ClassUtils.getPackageName(getClass()));
    return context;
  }
View Full Code Here

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

  }

  @Test
  public void testDefaults() throws Exception {
    tokenStore.storeAccessToken(token, authentication);
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(ResourceServerContext.class);
    context.refresh();
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(context)
        .addFilters(new DelegatingFilterProxy(context.getBean("springSecurityFilterChain", Filter.class)))
        .build();
    mvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.status().isUnauthorized());
    context.close();
  }
View Full Code Here

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

  }

  @Test
  public void testCustomTokenServices() throws Exception {
    tokenStore.storeAccessToken(token, authentication);
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(TokenServicesContext.class);
    context.refresh();
    MockMvc mvc = MockMvcBuilders.webAppContextSetup(context)
        .addFilters(new DelegatingFilterProxy(context.getBean("springSecurityFilterChain", Filter.class)))
        .build();
    mvc.perform(MockMvcRequestBuilders.get("/")).andExpect(MockMvcResultMatchers.status().isUnauthorized());
    context.close();
  }
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.