下面列出了怎么用org.apache.logging.log4j.core.config.plugins.Plugin的API类实例代码及写法,或者点击链接到github查看源代码。
default String getName() {
Plugin annotation = this.getClass().getAnnotation(Plugin.class);
if (annotation == null || annotation.name().length() == 0) {
throw new NameNotFoundException("No name could be found for plugin class " + this.getClass().getName());
}
return annotation.name();
}
/**
* Tests the presence of certain annotations and converter key in a given Converter class
*
* @param clazz PatterConverter class to test
* @param key Converter key to match
*/
private void testPatternAnnotation(Class<? extends AccessLogPatternConverter> clazz, String key) {
assertTrue(clazz.isAnnotationPresent(Plugin.class));
assertTrue(clazz.isAnnotationPresent(ConverterKeys.class));
assertEquals(key, clazz.getAnnotation(ConverterKeys.class).value()[0]);
}