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

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

本文整理了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

  1. private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  2. URL url = Loader.getResource(filename, myClassLoader);
  3. if (updateStatus) {
  4. statusOnResourceSearch(filename, myClassLoader, url);
  5. }
  6. return url;
  7. }

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

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

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

  1. private URL urlByResourceName(StatusManager sm, String resourceName) {
  2. sm.add(new InfoStatus("Searching for [" + resourceName + "]",
  3. this));
  4. URL url = Loader.getResource(resourceName, Loader.getTCL());
  5. if (url != null) {
  6. return url;
  7. }
  8. return Loader.getResourceBySelfClassLoader(resourceName);
  9. }

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

  1. private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
  2. String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
  3. if (logbackConfigFile != null) {
  4. URL result = null;
  5. try {
  6. result = new URL(logbackConfigFile);
  7. return result;
  8. } catch (MalformedURLException e) {
  9. // so, resource is not a URL:
  10. // attempt to get the resource from the class path
  11. result = Loader.getResource(logbackConfigFile, classLoader);
  12. if (result != null) {
  13. return result;
  14. }
  15. File f = new File(logbackConfigFile);
  16. if (f.exists() && f.isFile()) {
  17. try {
  18. result = f.toURI().toURL();
  19. return result;
  20. } catch (MalformedURLException e1) {
  21. }
  22. }
  23. } finally {
  24. if (updateStatus) {
  25. statusOnResourceSearch(logbackConfigFile, classLoader, result);
  26. }
  27. }
  28. }
  29. return null;
  30. }

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

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

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

  1. private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  2. URL url = Loader.getResource(filename, myClassLoader);
  3. if (updateStatus) {
  4. statusOnResourceSearch(filename, myClassLoader, url);
  5. }
  6. return url;
  7. }

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

  1. private URL urlByResourceName(StatusManager sm, String resourceName) {
  2. sm.add(new InfoStatus("Searching for [" + resourceName + "]",
  3. this));
  4. URL url = Loader.getResource(resourceName, Loader.getTCL());
  5. if (url != null) {
  6. return url;
  7. }
  8. return Loader.getResourceBySelfClassLoader(resourceName);
  9. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

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

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

  1. private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
  2. String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
  3. if (logbackConfigFile != null) {
  4. URL result = null;
  5. try {
  6. result = new URL(logbackConfigFile);
  7. return result;
  8. } catch (MalformedURLException e) {
  9. // so, resource is not a URL:
  10. // attempt to get the resource from the class path
  11. result = Loader.getResource(logbackConfigFile, classLoader);
  12. if (result != null) {
  13. return result;
  14. }
  15. File f = new File(logbackConfigFile);
  16. if (f.exists() && f.isFile()) {
  17. try {
  18. result = f.toURI().toURL();
  19. return result;
  20. } catch (MalformedURLException e1) {
  21. }
  22. }
  23. } finally {
  24. if (updateStatus) {
  25. statusOnResourceSearch(logbackConfigFile, classLoader, result);
  26. }
  27. }
  28. }
  29. return null;
  30. }

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

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

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource the resource name to look for
  6. * @return resource URL
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  2. URL url = Loader.getResource(filename, myClassLoader);
  3. if (updateStatus) {
  4. statusOnResourceSearch(filename, myClassLoader, url);
  5. }
  6. return url;
  7. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. /**
  2. * Attempt to find a resource by using the classloader that loaded this class,
  3. * namely Loader.class.
  4. *
  5. * @param resource
  6. * @return
  7. */
  8. public static URL getResourceBySelfClassLoader(String resource) {
  9. return getResource(resource, getClassLoaderOfClass(Loader.class));
  10. }

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

  1. private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
  2. URL url = Loader.getResource(filename, myClassLoader);
  3. if (updateStatus) {
  4. statusOnResourceSearch(filename, myClassLoader, url);
  5. }
  6. return url;
  7. }

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

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

相关文章