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

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

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

Loader.getResource介绍

[英]Search for a resource using the classloader passed as parameter.
[中]使用作为参数传递的classloader搜索资源。

代码示例

代码示例来源:origin: ch.qos.logback/logback-classic

private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  URL url = Loader.getResource(filename, myClassLoader);
  if (updateStatus) {
    statusOnResourceSearch(filename, myClassLoader, url);
  }
  return url;
}

代码示例来源:origin: ch.qos.logback/logback-classic

private URL urlByResourceName(StatusManager sm, String resourceName) {
  sm.add(new InfoStatus("Searching for [" + resourceName + "]", this));
  URL url = Loader.getResource(resourceName, Loader.getTCL());
  if (url != null) {
    return url;
  }
  return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private URL urlByResourceName(StatusManager sm, String resourceName) {
 sm.add(new InfoStatus("Searching for [" + resourceName + "]",
     this));
 URL url = Loader.getResource(resourceName, Loader.getTCL());
 if (url != null) {
  return url;
 }
 return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: ch.qos.logback/logback-classic

private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
  String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
  if (logbackConfigFile != null) {
    URL result = null;
    try {
      result = new URL(logbackConfigFile);
      return result;
    } catch (MalformedURLException e) {
      // so, resource is not a URL:
      // attempt to get the resource from the class path
      result = Loader.getResource(logbackConfigFile, classLoader);
      if (result != null) {
        return result;
      }
      File f = new File(logbackConfigFile);
      if (f.exists() && f.isFile()) {
        try {
          result = f.toURI().toURL();
          return result;
        } catch (MalformedURLException e1) {
        }
      }
    } finally {
      if (updateStatus) {
        statusOnResourceSearch(logbackConfigFile, classLoader, result);
      }
    }
  }
  return null;
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

private URL urlByResourceName(StatusManager sm, String resourceName) {
  sm.add(new InfoStatus("Searching for [" + resourceName + "]", this));
  URL url = Loader.getResource(resourceName, Loader.getTCL());
  if (url != null) {
    return url;
  }
  return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
 URL url = Loader.getResource(filename, myClassLoader);
 if (updateStatus) {
  statusOnResourceSearch(filename, myClassLoader, url);
 }
 return url;
}

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

private URL urlByResourceName(StatusManager sm, String resourceName) {
 sm.add(new InfoStatus("Searching for [" + resourceName + "]",
   this));
 URL url = Loader.getResource(resourceName, Loader.getTCL());
 if (url != null) {
  return url;
 }
 return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
 return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private URL urlByResourceName(StatusManager sm, String resourceName) {
  sm.add(new InfoStatus("Searching for [" + resourceName + "]", this));
  URL url = Loader.getResource(resourceName, Loader.getTCL());
  if (url != null) {
    return url;
  }
  return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
 String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
 if (logbackConfigFile != null) {
  URL result = null;
  try {
   result = new URL(logbackConfigFile);
   return result;
  } catch (MalformedURLException e) {
   // so, resource is not a URL:
   // attempt to get the resource from the class path
   result = Loader.getResource(logbackConfigFile, classLoader);
   if (result != null) {
    return result;
   }
   File f = new File(logbackConfigFile);
   if (f.exists() && f.isFile()) {
    try {
     result = f.toURI().toURL();
     return result;
    } catch (MalformedURLException e1) {
    }
   }
  } finally {
   if (updateStatus) {
    statusOnResourceSearch(logbackConfigFile, classLoader, result);
   }
  }
 }
 return null;
}

代码示例来源:origin: Nextdoor/bender

private URL urlByResourceName(StatusManager sm, String resourceName) {
  sm.add(new InfoStatus("Searching for [" + resourceName + "]", this));
  URL url = Loader.getResource(resourceName, Loader.getTCL());
  if (url != null) {
    return url;
  }
  return Loader.getResourceBySelfClassLoader(resourceName);
}

代码示例来源:origin: com.hynnet/logback-core

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
 return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: tony19/logback-android

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource the resource name to look for
 * @return resource URL
 */
public static URL getResourceBySelfClassLoader(String resource) {
 return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
  return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: Nextdoor/bender

private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  URL url = Loader.getResource(filename, myClassLoader);
  if (updateStatus) {
    statusOnResourceSearch(filename, myClassLoader, url);
  }
  return url;
}

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

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
 return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
  return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: ch.qos.logback/core

/**
 * Attempt to find a resource by using the classloader that loaded this class,
 * namely Loader.class.
 *
 * @param resource
 * @return
 */
public static URL getResourceBySelfClassLoader(String resource) {
 return getResource(resource, getClassLoaderOfClass(Loader.class));
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  URL url = Loader.getResource(filename, myClassLoader);
  if (updateStatus) {
    statusOnResourceSearch(filename, myClassLoader, url);
  }
  return url;
}

代码示例来源:origin: ch.qos.logback/logback-access

private URL searchAsResource(String filename) {
  URL result = Loader.getResource(filename, getClass().getClassLoader());
  if (result != null)
    addInfo("Found [" + filename + "] as a resource.");
  else
    addInfo("Could NOT find [" + filename + "] as a resource.");
  return result;
}

相关文章