ch.qos.logback.core.util.Loader.getResourceOccurenceCount()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(188)

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

Loader.getResourceOccurenceCount介绍

[英]Compute the number of occurrences a resource can be found by a class loader.
[中]计算类加载器可以找到的资源的出现次数。

代码示例

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

private void multiplicityWarning(String resourceName, ClassLoader classLoader ) {
 List<URL> urlList = null;
 StatusManager sm = loggerContext.getStatusManager();
 try {
  urlList = Loader.getResourceOccurenceCount(resourceName, classLoader);
 } catch (IOException e) {
  sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
    loggerContext, e));
 }
 if(urlList != null && urlList.size() > 1) {
  sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
    loggerContext));
  for(URL url: urlList) {
  sm.add(new WarnStatus("Resource ["+resourceName+"] occurs at ["+url.toString()+"]",
    loggerContext));
  }
 }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/ch.qos.logback.classic

private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
 Set<URL> urlSet = null;
 StatusManager sm = loggerContext.getStatusManager();
 try {
  urlSet = Loader.getResourceOccurenceCount(resourceName, classLoader);
 } catch (IOException e) {
  sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
      loggerContext, e));
 }
 if (urlSet != null && urlSet.size() > 1) {
  sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
      loggerContext));
  for (URL url : urlSet) {
   sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]",
       loggerContext));
  }
 }
}

相关文章