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

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

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

Logger.getAvailabilityCheckClassName介绍

暂无

代码示例

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

  1. private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  2. try {
  3. Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
  4. Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  5. } catch (Throwable e) {
  6. return false;
  7. }
  8. try {
  9. Class.forName(REAL_LOG4J_PRESENCE_CLASS);
  10. return false;
  11. } catch (ClassNotFoundException e) {
  12. try {
  13. Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
  14. .getMethod("test", new Class[] {}).invoke(null);
  15. return ((Boolean) r).booleanValue();
  16. } catch (Throwable e2) {
  17. return false;
  18. }
  19. }
  20. }

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

  1. /**
  2. * @throws ClassNotFoundException
  3. * If the required logger library is not available.
  4. */
  5. private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  6. final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  7. if (availabilityCheckClassName != null) { // Dynamically created factory
  8. Class.forName(availabilityCheckClassName);
  9. String libraryName = getLibraryName(libraryEnum);
  10. try {
  11. return (LoggerFactory) Class.forName(
  12. "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
  13. } catch (Exception e) {
  14. throw new RuntimeException(
  15. "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
  16. }
  17. } else { // Non-dynamically created factory
  18. if (libraryEnum == LIBRARY_JAVA) {
  19. return new _JULLoggerFactory();
  20. } else if (libraryEnum == LIBRARY_NONE) {
  21. return new _NullLoggerFactory();
  22. } else {
  23. throw new RuntimeException("Bug");
  24. }
  25. }
  26. }

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

  1. private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  2. try {
  3. Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
  4. Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  5. } catch (Throwable e) {
  6. return false;
  7. }
  8. try {
  9. Class.forName(REAL_LOG4J_PRESENCE_CLASS);
  10. return false;
  11. } catch (ClassNotFoundException e) {
  12. try {
  13. Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
  14. .getMethod("test", new Class[] {}).invoke(null);
  15. return ((Boolean) r).booleanValue();
  16. } catch (Throwable e2) {
  17. return false;
  18. }
  19. }
  20. }

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

  1. private static boolean hasLog4LibraryThatDelegatesToWorkingSLF4J() {
  2. try {
  3. Class.forName(getAvailabilityCheckClassName(LIBRARY_LOG4J));
  4. Class.forName(getAvailabilityCheckClassName(LIBRARY_SLF4J));
  5. } catch (Throwable e) {
  6. return false;
  7. }
  8. try {
  9. Class.forName(REAL_LOG4J_PRESENCE_CLASS);
  10. return false;
  11. } catch (ClassNotFoundException e) {
  12. try {
  13. Object r = Class.forName(LOG4J_OVER_SLF4J_TESTER_CLASS)
  14. .getMethod("test", new Class[] {}).invoke(null);
  15. return ((Boolean) r).booleanValue();
  16. } catch (Throwable e2) {
  17. return false;
  18. }
  19. }
  20. }

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

  1. /**
  2. * @throws ClassNotFoundException
  3. * If the required logger library is not available.
  4. */
  5. private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  6. final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  7. if (availabilityCheckClassName != null) { // Dynamically created factory
  8. Class.forName(availabilityCheckClassName);
  9. String libraryName = getLibraryName(libraryEnum);
  10. try {
  11. return (LoggerFactory) Class.forName(
  12. "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
  13. } catch (Exception e) {
  14. throw new RuntimeException(
  15. "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
  16. }
  17. } else { // Non-dynamically created factory
  18. if (libraryEnum == LIBRARY_JAVA) {
  19. return new _JULLoggerFactory();
  20. } else if (libraryEnum == LIBRARY_NONE) {
  21. return new _NullLoggerFactory();
  22. } else {
  23. throw new RuntimeException("Bug");
  24. }
  25. }
  26. }

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

  1. /**
  2. * @throws ClassNotFoundException
  3. * If the required logger library is not available.
  4. */
  5. private static LoggerFactory createLoggerFactoryForNonAuto(int libraryEnum) throws ClassNotFoundException {
  6. final String availabilityCheckClassName = getAvailabilityCheckClassName(libraryEnum);
  7. if (availabilityCheckClassName != null) { // Dynamically created factory
  8. Class.forName(availabilityCheckClassName);
  9. String libraryName = getLibraryName(libraryEnum);
  10. try {
  11. return (LoggerFactory) Class.forName(
  12. "freemarker.log._" + libraryName + "LoggerFactory").newInstance();
  13. } catch (Exception e) {
  14. throw new RuntimeException(
  15. "Unexpected error when creating logger factory for \"" + libraryName + "\".", e);
  16. }
  17. } else { // Non-dynamically created factory
  18. if (libraryEnum == LIBRARY_JAVA) {
  19. return new _JULLoggerFactory();
  20. } else if (libraryEnum == LIBRARY_NONE) {
  21. return new _NullLoggerFactory();
  22. } else {
  23. throw new RuntimeException("Bug");
  24. }
  25. }
  26. }

相关文章