本文整理了Java中ch.qos.logback.core.util.Loader.getResource()
方法的一些代码示例,展示了Loader.getResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.getResource()
方法的具体详情如下:
包路径:ch.qos.logback.core.util.Loader
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!