gpt4 book ai didi

org.springframework.boot.web.context.WebServerApplicationContext类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 04:49:05 31 4
gpt4 key购买 nike

本文整理了Java中org.springframework.boot.web.context.WebServerApplicationContext类的一些代码示例,展示了WebServerApplicationContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebServerApplicationContext类的具体详情如下:
包路径:org.springframework.boot.web.context.WebServerApplicationContext
类名称:WebServerApplicationContext

WebServerApplicationContext介绍

[英]Interface to be implemented by ApplicationContext that create and manage the lifecycle of an embedded WebServer.
[中]由ApplicationContext实现的接口,用于创建和管理嵌入式Web服务器的生命周期。

代码示例

代码示例来源:origin: org.springframework.boot/spring-boot

private String getServerNamespace(ApplicationContext applicationContext) {
  if (applicationContext instanceof WebServerApplicationContext) {
    return ((WebServerApplicationContext) applicationContext)
        .getServerNamespace();
  }
  return null;
}

代码示例来源:origin: line/armeria

@Test
public void verifySingleConnector() {
  // Relevant to Tomcat 9.0
  assertThat(applicationContext).isInstanceOf(WebServerApplicationContext.class);
  WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer();
  assertThat(webServer).isInstanceOf(TomcatWebServer.class);
  assertThat(((TomcatWebServer) webServer).getTomcat()
                      .getEngine()
                      .getService()
                      .findConnectors()).hasSize(1);
}

代码示例来源:origin: chillzhuang/blade-tool

@Async
  @Order
  @EventListener(WebServerInitializedEvent.class)
  public void afterStart(WebServerInitializedEvent event) {
    Environment environment = event.getApplicationContext().getEnvironment();
    String appName = environment.getProperty("spring.application.name").toUpperCase();
    int localPort = event.getWebServer().getPort();
    String profile = StringUtils.arrayToCommaDelimitedString(environment.getActiveProfiles());
    log.info("---[{}]---启动完成,当前使用的端口:[{}],环境变量:[{}]---", appName, localPort, profile);
  }
}

代码示例来源:origin: xiaour/spring.boot.sapi.starter

@Override
public void onApplicationEvent(WebServerInitializedEvent webServerInitializedEvent) {
  this.serverPort=webServerInitializedEvent.getWebServer().getPort();
  this.contextPath=webServerInitializedEvent.getApplicationContext().getApplicationName();
  apiRouter.add(contextPath+"/sapidata/apiList");
  apiRouter.add(contextPath+"/sapidata/group");
  LOG.info("Sapi v1.4.1:http://127.0.0.1:"+getPort()+getContextPath()+"/sapi");
}

代码示例来源:origin: org.springframework.boot/spring-boot-actuator

private ThreadPool findThreadPool(ApplicationContext applicationContext) {
  if (applicationContext instanceof WebServerApplicationContext) {
    WebServer webServer = ((WebServerApplicationContext) applicationContext)
        .getWebServer();
    if (webServer instanceof JettyWebServer) {
      return ((JettyWebServer) webServer).getServer().getThreadPool();
    }
  }
  return null;
}

代码示例来源:origin: org.springframework.boot/spring-boot-actuator

private Manager findManager(ApplicationContext applicationContext) {
  if (applicationContext instanceof WebServerApplicationContext) {
    WebServer webServer = ((WebServerApplicationContext) applicationContext)
        .getWebServer();
    if (webServer instanceof TomcatWebServer) {
      Context context = findContext((TomcatWebServer) webServer);
      return context.getManager();
    }
  }
  return null;
}

代码示例来源:origin: org.springframework.boot/spring-boot

private String getName(WebServerApplicationContext context) {
  String name = context.getServerNamespace();
  return StringUtils.hasText(name) ? name : "server";
}

代码示例来源:origin: org.springframework.boot/spring-boot-actuator-autoconfigure

@Override
public void afterSingletonsInstantiated() {
  if (this.applicationContext instanceof WebServerApplicationContext
      && ((WebServerApplicationContext) this.applicationContext)
          .getWebServer() != null) {
    ConfigurableWebServerApplicationContext managementContext = this.managementContextFactory
        .createManagementContext(this.applicationContext,
            EnableChildManagementContextConfiguration.class,
            PropertyPlaceholderAutoConfiguration.class);
    managementContext.setServerNamespace("management");
    managementContext.setId(this.applicationContext.getId() + ":management");
    setClassLoaderIfPossible(managementContext);
    CloseManagementContextListener.addIfPossible(this.applicationContext,
        managementContext);
    managementContext.refresh();
  }
  else {
    logger.warn("Could not start embedded management container on "
        + "different port (management endpoints are still available "
        + "through JMX)");
  }
}

代码示例来源:origin: codecentric/spring-boot-admin

@EventListener
  public void onWebServerInitialized(WebServerInitializedEvent event) {
    String name = event.getApplicationContext().getServerNamespace();
    if ("server".equals(name) || !StringUtils.hasText(name)) {
      localServerPort = event.getWebServer().getPort();
    } else if ("management".equals(name)) {
      localManagementPort = event.getWebServer().getPort();
    }
  }
}

代码示例来源:origin: de.codecentric/spring-boot-admin-client

@EventListener
  public void onWebServerInitialized(WebServerInitializedEvent event) {
    String name = event.getApplicationContext().getServerNamespace();
    if ("server".equals(name) || !StringUtils.hasText(name)) {
      localServerPort = event.getWebServer().getPort();
    } else if ("management".equals(name)) {
      localManagementPort = event.getWebServer().getPort();
    }
  }
}

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com