freemarker.log.Logger.getAvailabilityCheckClassName()方法的使用及代码示例

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

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

Logger.getAvailabilityCheckClassName介绍

暂无

代码示例

代码示例来源:origin: org.freemarker/freemarker

private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  try {
    Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
    Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  } catch (Throwable e) {
    return false;
  }
  try {
    Class.forName(REAL_LOG4J_PRESENCE_CLASS);
    return false;
  } catch (ClassNotFoundException e) {
    try {
      Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
          .getMethod("test", new Class[] {}).invoke(null);
      return ((Boolean) r).booleanValue();
    } catch (Throwable e2) {
      return false;
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker

/**
 * @throws ClassNotFoundException
 *             If the required logger library is not available.
 */
private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  if (availabilityCheckClassName != null) { // Dynamically created factory
    Class.forName(availabilityCheckClassName);
    String libraryName = getLibraryName(libraryEnum);
    try {
      return (LoggerFactory) Class.forName(
          "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
    } catch (Exception e) {
      throw new RuntimeException(
          "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
    }
  } else { // Non-dynamically created factory
    if (libraryEnum == LIBRARY_JAVA) {
      return new _JULLoggerFactory();
    } else if (libraryEnum == LIBRARY_NONE) {
      return new _NullLoggerFactory();
    } else {
      throw new RuntimeException("Bug");
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker-gae

private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  try {
    Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
    Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  } catch (Throwable e) {
    return false;
  }
  try {
    Class.forName(REAL_LOG4J_PRESENCE_CLASS);
    return false;
  } catch (ClassNotFoundException e) {
    try {
      Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
          .getMethod("test", new Class[] {}).invoke(null);
      return ((Boolean) r).booleanValue();
    } catch (Throwable e2) {
      return false;
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  try {
    Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
    Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  } catch (Throwable e) {
    return false;
  }
  try {
    Class.forName(REAL_LOG4J_PRESENCE_CLASS);
    return false;
  } catch (ClassNotFoundException e) {
    try {
      Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
          .getMethod("test", new Class[] {}).invoke(null);
      return ((Boolean) r).booleanValue();
    } catch (Throwable e2) {
      return false;
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

/**
 * @throws ClassNotFoundException
 *             If the required logger library is not available.
 */
private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  if (availabilityCheckClassName != null) { // Dynamically created factory
    Class.forName(availabilityCheckClassName);
    String libraryName = getLibraryName(libraryEnum);
    try {
      return (LoggerFactory) Class.forName(
          "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
    } catch (Exception e) {
      throw new RuntimeException(
          "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
    }
  } else { // Non-dynamically created factory
    if (libraryEnum == LIBRARY_JAVA) {
      return new _JULLoggerFactory();
    } else if (libraryEnum == LIBRARY_NONE) {
      return new _NullLoggerFactory();
    } else {
      throw new RuntimeException("Bug");
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker-gae

/**
 * @throws ClassNotFoundException
 *             If the required logger library is not available.
 */
private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  if (availabilityCheckClassName != null) { // Dynamically created factory
    Class.forName(availabilityCheckClassName);
    String libraryName = getLibraryName(libraryEnum);
    try {
      return (LoggerFactory) Class.forName(
          "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
    } catch (Exception e) {
      throw new RuntimeException(
          "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
    }
  } else { // Non-dynamically created factory
    if (libraryEnum == LIBRARY_JAVA) {
      return new _JULLoggerFactory();
    } else if (libraryEnum == LIBRARY_NONE) {
      return new _NullLoggerFactory();
    } else {
      throw new RuntimeException("Bug");
    }
  }
}

相关文章