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

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

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

Loader.loadClass介绍

[英]If running under JDK 1.2 load the specified class using the Thread``contextClassLoader if that fails try Class.forname. Under JDK 1.1 only Class.forName is used.
[中]

代码示例

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(LoggerContext defaultLoggerContext, String contextSelectorStr) throws ClassNotFoundException,
  17. SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException,
  18. InvocationTargetException {
  19. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  20. Constructor cons = contextSelectorClass.getConstructor(new Class[] { LoggerContext.class });
  21. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  22. }

代码示例来源:origin: googleapis/google-cloud-java

  1. private <T> T getEnhancer(String enhancerClassName) {
  2. try {
  3. Class<T> clz = (Class<T>) Loader.loadClass(enhancerClassName.trim());
  4. return clz.newInstance();
  5. } catch (Exception ex) {
  6. // If we cannot create the enhancer we fallback to null
  7. }
  8. return null;
  9. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(
  17. LoggerContext defaultLoggerContext, String contextSelectorStr)
  18. throws ClassNotFoundException, SecurityException, NoSuchMethodException,
  19. IllegalArgumentException, InstantiationException, IllegalAccessException,
  20. InvocationTargetException {
  21. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  22. Constructor cons = contextSelectorClass
  23. .getConstructor(new Class[] { LoggerContext.class });
  24. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  25. }

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

代码示例来源:origin: com.google.cloud/google-cloud-logging-logback

  1. private <T> T getEnhancer(String enhancerClassName) {
  2. try {
  3. Class<T> clz = (Class<T>) Loader.loadClass(enhancerClassName.trim());
  4. return clz.newInstance();
  5. } catch (Exception ex) {
  6. // If we cannot create the enhancer we fallback to null
  7. }
  8. return null;
  9. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(LoggerContext defaultLoggerContext, String contextSelectorStr) throws ClassNotFoundException,
  17. SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException,
  18. InvocationTargetException {
  19. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  20. Constructor cons = contextSelectorClass.getConstructor(new Class[] { LoggerContext.class });
  21. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  22. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(
  17. LoggerContext defaultLoggerContext, String contextSelectorStr)
  18. throws ClassNotFoundException, SecurityException, NoSuchMethodException,
  19. IllegalArgumentException, InstantiationException, IllegalAccessException,
  20. InvocationTargetException {
  21. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  22. Constructor cons = contextSelectorClass
  23. .getConstructor(new Class[] { LoggerContext.class });
  24. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  25. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(LoggerContext defaultLoggerContext, String contextSelectorStr) throws ClassNotFoundException,
  17. SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException,
  18. InvocationTargetException {
  19. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  20. Constructor cons = contextSelectorClass.getConstructor(new Class[] { LoggerContext.class });
  21. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  22. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(LoggerContext defaultLoggerContext, String contextSelectorStr) throws ClassNotFoundException,
  17. SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException,
  18. InvocationTargetException {
  19. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  20. Constructor cons = contextSelectorClass.getConstructor(new Class[] { LoggerContext.class });
  21. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  22. }

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

  1. /**
  2. * Instantiate the context selector class designated by the user. The selector
  3. * must have a constructor taking a LoggerContext instance as an argument.
  4. *
  5. * @param defaultLoggerContext
  6. * @param contextSelectorStr
  7. * @return an instance of the designated context selector class
  8. * @throws ClassNotFoundException
  9. * @throws SecurityException
  10. * @throws NoSuchMethodException
  11. * @throws IllegalArgumentException
  12. * @throws InstantiationException
  13. * @throws IllegalAccessException
  14. * @throws InvocationTargetException
  15. */
  16. static ContextSelector dynamicalContextSelector(
  17. LoggerContext defaultLoggerContext, String contextSelectorStr)
  18. throws ClassNotFoundException, SecurityException, NoSuchMethodException,
  19. IllegalArgumentException, InstantiationException, IllegalAccessException,
  20. InvocationTargetException {
  21. Class<?> contextSelectorClass = Loader.loadClass(contextSelectorStr);
  22. Constructor cons = contextSelectorClass
  23. .getConstructor(new Class[] { LoggerContext.class });
  24. return (ContextSelector) cons.newInstance(defaultLoggerContext);
  25. }

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

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

  1. componentClass = Loader.loadClass(className, context);
  2. } else {

相关文章