Package org.springframework.boot.context.embedded

Examples of org.springframework.boot.context.embedded.ServletRegistrationBean


@Configuration
public class H2Initializer {

  @Bean
  public ServletRegistrationBean h2Servlet() {
    ServletRegistrationBean servletBean = new ServletRegistrationBean();
    servletBean.addUrlMappings("/h2/*");
    servletBean.setServlet(new WebServlet());
    return servletBean;
  }
View Full Code Here


  @Bean
  public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    return new ServletRegistrationBean(servlet, "/services/*");
  }
 
View Full Code Here

      return new DispatcherServlet();
    }

    @Bean
    public ServletRegistrationBean dispatcherRegistration() {
      return new ServletRegistrationBean(dispatcherServlet(), "/app/*");
    }
 
View Full Code Here

    this.context.register(ServerPropertiesAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    assertNotNull(this.context.getBean(DispatcherServlet.class));
    ServletRegistrationBean registration = this.context
        .getBean(ServletRegistrationBean.class);
    assertEquals("[/]", registration.getUrlMappings().toString());
  }
View Full Code Here

    this.context.register(CustomDispatcherRegistration.class,
        ServerPropertiesAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    ServletRegistrationBean registration = this.context
        .getBean(ServletRegistrationBean.class);
    assertEquals("[/foo]", registration.getUrlMappings().toString());
    assertEquals("customDispatcher", registration.getServletName());
    assertEquals(0, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }
View Full Code Here

    this.context.register(CustomAutowiredRegistration.class,
        ServerPropertiesAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);
    this.context.setServletContext(new MockServletContext());
    this.context.refresh();
    ServletRegistrationBean registration = this.context
        .getBean(ServletRegistrationBean.class);
    assertEquals("[/foo]", registration.getUrlMappings().toString());
    assertEquals("customDispatcher", registration.getServletName());
    assertEquals(1, this.context.getBeanNamesForType(DispatcherServlet.class).length);
  }
View Full Code Here

    this.context.register(ServerPropertiesAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "server.servlet_path:/spring");
    this.context.refresh();
    assertNotNull(this.context.getBean(DispatcherServlet.class));
    ServletRegistrationBean registration = this.context
        .getBean(ServletRegistrationBean.class);
    assertEquals("[/spring/*]", registration.getUrlMappings().toString());
    assertNull(registration.getMultipartConfig());
  }
View Full Code Here

    this.context.setServletContext(new MockServletContext());
    this.context.register(MultipartConfiguration.class,
        ServerPropertiesAutoConfiguration.class,
        DispatcherServletAutoConfiguration.class);
    this.context.refresh();
    ServletRegistrationBean registration = this.context
        .getBean(ServletRegistrationBean.class);
    assertNotNull(registration.getMultipartConfig());
  }
View Full Code Here

  @Configuration
  protected static class CustomDispatcherRegistration {
    @Bean
    public ServletRegistrationBean dispatcherServletRegistration() {
      ServletRegistrationBean registration = new ServletRegistrationBean(
          new DispatcherServlet(), "/foo");
      registration.setName("customDispatcher");
      return registration;
    }
View Full Code Here

  @Configuration
  protected static class CustomAutowiredRegistration {
    @Bean
    public ServletRegistrationBean dispatcherServletRegistration(
        DispatcherServlet dispatcherServlet) {
      ServletRegistrationBean registration = new ServletRegistrationBean(
          dispatcherServlet, "/foo");
      registration.setName("customDispatcher");
      return registration;
    }
View Full Code Here

TOP

Related Classes of org.springframework.boot.context.embedded.ServletRegistrationBean

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.