本文整理汇总了Java中org.apache.logging.log4j.core.helpers.Loader类的典型用法代码示例。如果您正苦于以下问题:Java Loader类的具体用法?Java Loader怎么用?Java Loader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Loader类属于org.apache.logging.log4j.core.helpers包,在下文中一共展示了Loader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputFromResource
import org.apache.logging.log4j.core.helpers.Loader; //导入依赖的package包/类
/**
* Retrieve the configuration via the ClassLoader.
* @param resource The resource to load.
* @param loader The default ClassLoader to use.
* @return The ConfigurationSource for the configuration.
*/
protected ConfigurationSource getInputFromResource(final String resource, final ClassLoader loader) {
final URL url = Loader.getResource(resource, loader);
if (url == null) {
return null;
}
InputStream is = null;
try {
is = url.openStream();
} catch (final IOException ioe) {
return null;
}
if (is == null) {
return null;
}
if (FileUtils.isFile(url)) {
try {
return new ConfigurationSource(is, FileUtils.fileFromURI((url.toURI())));
} catch (final URISyntaxException ex) {
// Just ignore the exception.
}
}
return new ConfigurationSource(is, resource);
}
示例2: getClassLoader
import org.apache.logging.log4j.core.helpers.Loader; //导入依赖的package包/类
/**
* Returns the classloader that will be used for scanning for classes. If no explicit
* ClassLoader has been set by the calling, the context class loader will be used.
*
* @return the ClassLoader that will be used to scan for classes
*/
public ClassLoader getClassLoader() {
return classloader != null ? classloader : (classloader = Loader.getClassLoader(ResolverUtil.class, null));
}