Java 类org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void overrideServerProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "server.displayName:foo");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    ServerProperties serverProperties = this.applicationContext
            .getBean(ServerProperties.class);
    assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
    assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertThat(actual).isEqualTo(String.valueOf(expected));
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void overrideServerProperties() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "server.displayName:foo");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    ServerProperties serverProperties = this.applicationContext
            .getBean(ServerProperties.class);
    assertThat(serverProperties.getDisplayName()).isEqualTo("foo");
}
项目:spring-boot-concourse    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
    assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertThat(actual).isEqualTo(String.valueOf(expected));
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void contextPath() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "management.contextPath:/test");
    this.applicationContext.register(RootConfig.class, EndpointConfig.class,
            ServerPortConfig.class, PropertyPlaceholderAutoConfiguration.class,
            ManagementServerPropertiesAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class, JacksonAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            HttpMessageConvertersAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
            EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    assertContent("/controller", ports.get().server, "controlleroutput");
    assertContent("/test/endpoint", ports.get().server, "endpointoutput");
    this.applicationContext.close();
    assertAllClosed();
}
项目:contestparser    文件:SpringApplicationAdminJmxAutoConfigurationTests.java   
@Test
public void registerWithSimpleWebApp() throws Exception {
    this.context = new SpringApplicationBuilder()
            .sources(EmbeddedServletContainerAutoConfiguration.class,
                    ServerPropertiesAutoConfiguration.class,
                    DispatcherServletAutoConfiguration.class,
                    JmxAutoConfiguration.class,
                    SpringApplicationAdminJmxAutoConfiguration.class)
            .run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
    assertTrue(this.context instanceof EmbeddedWebApplicationContext);
    assertEquals(true, this.mBeanServer.getAttribute(createDefaultObjectName(),
            "EmbeddedWebApplication"));
    int expected = ((EmbeddedWebApplicationContext) this.context)
            .getEmbeddedServletContainer().getPort();
    String actual = getProperty(createDefaultObjectName(), "local.server.port");
    assertEquals(String.valueOf(expected), actual);
}
项目:joal    文件:EndpointObfuscatorConfiguration.java   
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {
    final ServletRegistrationBean registration = new ServletRegistrationBean(
            dispatcherServlet(),
            "/" + this.pathPrefix + "/*"
    );
    registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    return registration;
}
项目:service-integration-sdk    文件:AsyncServletConfiguration.java   
/**
 * Register dispatcherServlet programmatically
 *
 * @return ServletRegistrationBean
 */
@Bean
public ServletRegistrationBean dispatcherServletRegistration() {

    ServletRegistrationBean registration = new ServletRegistrationBean(
        dispatcherServlet(), "/");

    registration
        .setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    registration.setAsyncSupported(true);
    registration.setEnabled(true);
    registration.setLoadOnStartup(1);

    return registration;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfiguration.java   
private void createChildManagementContext() {
    AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
    childContext.setParent(this.applicationContext);
    childContext.setNamespace("management");
    childContext.setId(this.applicationContext.getId() + ":management");
    childContext.register(EndpointWebMvcChildContextConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    registerEmbeddedServletContainerFactory(childContext);
    CloseManagementContextListener.addIfPossible(this.applicationContext,
            childContext);
    childContext.refresh();
    managementContextResolver().setApplicationContext(childContext);
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfiguration.java   
private void createChildManagementContext() {
    AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
    childContext.setParent(this.applicationContext);
    childContext.setNamespace("management");
    childContext.setId(this.applicationContext.getId() + ":management");
    childContext.register(EndpointWebMvcChildContextConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    registerEmbeddedServletContainerFactory(childContext);
    CloseManagementContextListener.addIfPossible(this.applicationContext,
            childContext);
    childContext.refresh();
    managementContextResolver().setApplicationContext(childContext);
}
项目:awesome-agile    文件:FakeHackpadServer.java   
private void start() {
  try {
    webApplicationContext = SpringApplication.run(
        new Object[]{
            FakeHackpadServerConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class},
        new String[]{"--server.port=" + port});
    webApplicationContext.getAutowireCapableBeanFactory().autowireBean(this);
  } catch (Exception ex) {
    throw new RuntimeException("Unable to start fake Google OAuth server", ex);
  }
}
项目:awesome-agile    文件:FakeGoogleServer.java   
private void start() {
  try {
    webApplicationContext = SpringApplication.run(
        new Object[] {
            FakeGoogleOAuthServerConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class},
        new String[] { "--server.port=" + port });
    webApplicationContext.getAutowireCapableBeanFactory().autowireBean(this);
  } catch (Exception ex) {
    throw new RuntimeException("Unable to start fake Google OAuth server", ex);
  }
}
项目:contestparser    文件:EndpointWebMvcAutoConfiguration.java   
private void createChildManagementContext() {
    final AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
    childContext.setParent(this.applicationContext);
    childContext.setNamespace("management");
    childContext.setId(this.applicationContext.getId() + ":management");
    childContext.register(EndpointWebMvcChildContextConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class,
            EmbeddedServletContainerAutoConfiguration.class,
            DispatcherServletAutoConfiguration.class);
    CloseEventPropagationListener.addIfPossible(this.applicationContext,
            childContext);
    childContext.refresh();
    managementContextResolver().setApplicationContext(childContext);
}
项目:infotranspub-backend    文件:Main.java   
@Bean
public ServletRegistrationBean dispatchServletRegistration() {
    ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet(), "/api/*");
    registration.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
    return registration;
}
项目:gradlejug    文件:Application.java   
@Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public DispatcherServlet dispatcherServlet() {
    return new DispatcherServlet();
}