gpt4 book ai didi

org.springframework.boot.web.context.WebServerApplicationContext.getServerNamespace()方法的使用及代码示例

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

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

WebServerApplicationContext.getServerNamespace介绍

[英]Returns the namespace of the web server application context or null if no namespace has been set. Used for disambiguation when multiple web servers are running in the same application (for example a management context running on a different port).
[中]返回web服务器应用程序上下文的名称空间,如果未设置名称空间,则返回null。用于在同一应用程序中运行多个web服务器时消除歧义(例如,在不同端口上运行的管理上下文)。

代码示例

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

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

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

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

代码示例来源: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();
    }
  }
}

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