org.identityconnectors.common.logging.Log.getSpiClass()方法的使用及代码示例

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

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

Log.getSpiClass介绍

[英]Cache the search for the SPI class.
[中]缓存对SPI类的搜索。

代码示例

代码示例来源:origin: org.connid/framework

/**
 * Get the logger for the particular class. <code>
 * private static final Log LOG = Log.getLog(MyClass.class);
 * </code>
 * 
 * @param clazz
 *            class to log information about.
 * @return logger to use for logging.
 */
public static Log getLog(final Class<?> clazz) {
  try {
    // check that we're not logging ourselves
    if (LogSpi.class.isAssignableFrom(clazz)) {
      throw new IllegalArgumentException();
    }
    // attempt to get an instance..
    LogSpi logImpl = (LogSpi) getSpiClass().newInstance();
    return new Log(clazz, logImpl);
  } catch (RuntimeException e) {
    throw e;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: Tirasa/ConnId

/**
 * Get the logger for the particular class. <code>
 * private static final Log LOG = Log.getLog(MyClass.class);
 * </code>
 *
 * @param clazz
 *            class to log information about.
 * @return logger to use for logging.
 */
public static Log getLog(final Class<?> clazz) {
  try {
    // check that we're not logging ourselves
    if (LogSpi.class.isAssignableFrom(clazz)) {
      throw new IllegalArgumentException();
    }
    // attempt to get an instance..
    final LogSpi logImpl = (LogSpi) getSpiClass().newInstance();
    return new Log(clazz, logImpl);
  } catch (RuntimeException e) {
    throw e;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: net.tirasa.connid/connector-framework

/**
 * Get the logger for the particular class. <code>
 * private static final Log LOG = Log.getLog(MyClass.class);
 * </code>
 *
 * @param clazz
 *            class to log information about.
 * @return logger to use for logging.
 */
public static Log getLog(final Class<?> clazz) {
  try {
    // check that we're not logging ourselves
    if (LogSpi.class.isAssignableFrom(clazz)) {
      throw new IllegalArgumentException();
    }
    // attempt to get an instance..
    final LogSpi logImpl = (LogSpi) getSpiClass().newInstance();
    return new Log(clazz, logImpl);
  } catch (RuntimeException e) {
    throw e;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void checkSystemProperty() {
  // don't mess up other tests w/ changing out logging..
  synchronized (Log.class) {
    // save the original..
    Class<?> orig = Log.getSpiClass();
    try {
      // check the default..
      Log.getLog(String.class);
      assertEquals(Log.getSpiClass(), StdOutLogger.class);
      // attempt to get the mock logger
      Log.setSpiClass(null);
      System.setProperty(Log.LOGSPI_PROP, MockLogSpi.class.getName());
      Log.getLog(String.class);
      assertEquals(Log.getSpiClass(), MockLogSpi.class);
      // attempt to change it, so make sure its cached..
      System.setProperty(Log.LOGSPI_PROP, StdOutLogger.class.getName());
      assertEquals(Log.getSpiClass(), MockLogSpi.class);
    } finally {
      // restore logger to original state..
      Log.setSpiClass(orig);
      System.clearProperty(Log.LOGSPI_PROP);
    }
  }
}

相关文章