本文整理了Java中org.apache.commons.logging.LogFactory.getClassLoader()
方法的一些代码示例,展示了LogFactory.getClassLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LogFactory.getClassLoader()
方法的具体详情如下:
包路径:org.apache.commons.logging.LogFactory
类名称:LogFactory
方法名:getClassLoader
[英]Safely get access to the classloader for the specified class.
Theoretically, calling getClassLoader can throw a security exception, and so should be done under an AccessController in order to provide maximum flexibility. However in practice people don't appear to use security policies that forbid getClassLoader calls. So for the moment all code is written to call this method rather than Class.getClassLoader, so that we could put AccessController stuff in this method without any disruption later if we need to.
Even when using an AccessController, however, this method can still throw SecurityException. Commons-logging basically relies on the ability to access classloaders, ie a policy that forbids all classloader access will also prevent commons-logging from working: currently this method will throw an exception preventing the entire app from starting up. Maybe it would be good to detect this situation and just disable all commons-logging? Not high priority though - as stated above, security policies that prevent classloader access aren't common.
[中]安全地访问指定类的类加载器。
从理论上讲,调用getClassLoader可能引发安全异常,因此应该在AccessController下执行,以提供最大的灵活性。然而,在实践中,人们似乎并不使用禁止getClassLoader调用的安全策略。所以目前所有的代码都是为了调用这个方法而不是类而编写的。getClassLoader,这样我们就可以将AccessController的东西放在这个方法中,如果需要的话,以后不会有任何中断。
但是,即使在使用AccessController时,此方法仍然可以引发SecurityException。Commons日志记录基本上依赖于访问类加载器的能力,即禁止所有类加载器访问的策略也将阻止Commons日志记录工作:当前此方法将引发异常,阻止整个应用程序启动。也许检测到这种情况并禁用所有公共日志记录会更好?但优先级不高——如上所述,阻止类加载器访问的安全策略并不常见。
代码示例来源:origin: commons-logging/commons-logging
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: robovm/robovm
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: robovm/robovm
classLoader = getClassLoader(LogFactory.class);
代码示例来源:origin: commons-logging/commons-logging
classLoader = getClassLoader(clazz);
} catch (SecurityException ex) {
代码示例来源:origin: robovm/robovm
classLoader = getClassLoader(clazz);
} catch(SecurityException ex) {
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: camunda/camunda-bpm-platform
classLoader = getClassLoader(LogFactory.class);
代码示例来源:origin: camunda/camunda-bpm-platform
classLoader = getClassLoader(clazz);
} catch(SecurityException ex) {
代码示例来源:origin: MobiVM/robovm
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: Nextdoor/bender
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: ibinti/bugvm
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: org.apache.openjpa/openjpa-all
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: apache-logging/commons-logging
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.commons.logging
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: FlexoVM/flexovm
/**
* Workaround for bug in Java1.2; in theory this method is not needed.
* See LogFactory.getClassLoader.
* @since 1.1
*/
protected static ClassLoader getClassLoader(Class clazz) {
return LogFactory.getClassLoader(clazz);
}
代码示例来源:origin: ibinti/bugvm
classLoader = getClassLoader(clazz);
} catch(SecurityException ex) {
内容来源于网络,如有侵权,请联系作者删除!