org.springframework.web.context.WebApplicationContext.getId()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(117)

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

WebApplicationContext.getId介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Nullable
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
  String wacId = wac.getId();
  Map<Class<?>, String> beanNamesByType = cache.get(wacId);
  if (beanNamesByType == null) {
    beanNamesByType = new ConcurrentHashMap<>();
    cache.put(wacId, beanNamesByType);
  }
  if (!beanNamesByType.containsKey(endpointClass)) {
    String[] names = wac.getBeanNamesForType(endpointClass);
    if (names.length == 1) {
      beanNamesByType.put(endpointClass, names[0]);
    }
    else {
      beanNamesByType.put(endpointClass, NO_VALUE);
      if (names.length > 1) {
        throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
            endpointClass.getName() + "]: bean names " + Arrays.asList(names));
      }
    }
  }
  String beanName = beanNamesByType.get(endpointClass);
  return (NO_VALUE.equals(beanName) ? null : beanName);
}

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

@Nullable
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
  String wacId = wac.getId();
  Map<Class<?>, String> beanNamesByType = cache.get(wacId);
  if (beanNamesByType == null) {
    beanNamesByType = new ConcurrentHashMap<>();
    cache.put(wacId, beanNamesByType);
  }
  if (!beanNamesByType.containsKey(endpointClass)) {
    String[] names = wac.getBeanNamesForType(endpointClass);
    if (names.length == 1) {
      beanNamesByType.put(endpointClass, names[0]);
    }
    else {
      beanNamesByType.put(endpointClass, NO_VALUE);
      if (names.length > 1) {
        throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
            endpointClass.getName() + "]: bean names " + Arrays.asList(names));
      }
    }
  }
  String beanName = beanNamesByType.get(endpointClass);
  return (NO_VALUE.equals(beanName) ? null : beanName);
}

代码示例来源:origin: apache/servicemix-bundles

@Nullable
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
  String wacId = wac.getId();
  Map<Class<?>, String> beanNamesByType = cache.get(wacId);
  if (beanNamesByType == null) {
    beanNamesByType = new ConcurrentHashMap<>();
    cache.put(wacId, beanNamesByType);
  }
  if (!beanNamesByType.containsKey(endpointClass)) {
    String[] names = wac.getBeanNamesForType(endpointClass);
    if (names.length == 1) {
      beanNamesByType.put(endpointClass, names[0]);
    }
    else {
      beanNamesByType.put(endpointClass, NO_VALUE);
      if (names.length > 1) {
        throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
            endpointClass.getName() + "]: bean names " + Arrays.asList(names));
      }
    }
  }
  String beanName = beanNamesByType.get(endpointClass);
  return (NO_VALUE.equals(beanName) ? null : beanName);
}

代码示例来源:origin: org.eagle-i/eagle-i-search-gwt

private void debug(final WebApplicationContext ctx) {
  // DEBUG
  if ( DEBUG ) {
    logger.debug("SearchServlet: Context Display name = "
        + ctx.getDisplayName());
    logger.debug("SearchServlet: Context ID = " + ctx.getId());
    if (ctx.getParent() == null) {
      logger.debug("SearchServlet: Context Parent is null.");
    } else {
      logger.debug("SearchServlet: Context Parent Display name = "
          + ctx.getParent().getDisplayName());
    }
    if (ctx.getServletContext() == null) {
      logger.debug("SearchServlet: ServletContext is null.");
    } else {
      logger.debug("SearchServlet: ServletContext path = "
          + ctx.getServletContext().getContextPath());
      logger.debug("SearchServlet: ServletContext context name = "
          + ctx.getServletContext().getServletContextName());
    }
  }
  // DEBUG
}

代码示例来源:origin: pl.matisoft/spring-soy-view

@Override
public void resolveData(final HttpServletRequest request, final HttpServletResponse response, final Map<String, ? extends Object> model, final SoyMapData root) {
  final WebApplicationContext context = getWebApplicationContext();
  if (context.getApplicationName() != null) {
    root.put(prefix + "applicationName", context.getApplicationName());
  }
  if (context.getDisplayName() != null) {
    root.put(prefix + "displayName", context.getDisplayName());
  }
  root.put(prefix + "startUp", DateFormat.getDateTimeInstance().format(new Date(context.getStartupDate())));
  if (context.getId() != null) {
    root.put(prefix + "id", context.getId());
  }
}

代码示例来源:origin: org.eagle-i/eagle-i-search-gwt

logger.debug( "InstanceServlet: Context ID = " + ctx.getId() );
if ( ctx.getParent() == null ) {
  logger.debug( "InstanceServlet: Context Parent is null." );

相关文章