use of org.apache.logging.log4j.plugins.processor.PluginEntry in project logging-log4j2 by apache.
the class PluginProcessor method collectPlugins.
private String collectPlugins(String packageName, final Iterable<? extends Element> elements, List<PluginEntry> list) {
boolean calculatePackage = packageName == null;
final Elements elementUtils = processingEnv.getElementUtils();
final ElementVisitor<PluginEntry, Plugin> pluginVisitor = new PluginElementVisitor(elementUtils);
final ElementVisitor<Collection<PluginEntry>, Plugin> pluginAliasesVisitor = new PluginAliasesElementVisitor(elementUtils);
for (final Element element : elements) {
final Plugin plugin = element.getAnnotation(Plugin.class);
if (plugin == null) {
continue;
}
final PluginEntry entry = element.accept(pluginVisitor, plugin);
list.add(entry);
if (calculatePackage) {
packageName = calculatePackage(elementUtils, element, packageName);
}
final Collection<PluginEntry> entries = element.accept(pluginAliasesVisitor, plugin);
for (final PluginEntry pluginEntry : entries) {
list.add(pluginEntry);
}
}
return packageName;
}
use of org.apache.logging.log4j.plugins.processor.PluginEntry in project logging-log4j2 by apache.
the class PluginProcessorTest method testNestedPlugin.
@Test
public void testNestedPlugin() throws Exception {
final Plugin p = FakePlugin.Nested.class.getAnnotation(Plugin.class);
final List<PluginType<?>> list = pluginService.getCategory(p.category());
assertNotNull(list);
final PluginEntry nested = getEntry(list, p.name());
assertNotNull(nested);
assertEquals(p.name().toLowerCase(), nested.getKey());
assertEquals(FakePlugin.Nested.class.getName(), nested.getClassName());
assertEquals(p.name(), nested.getName());
assertEquals(Plugin.EMPTY, p.elementType());
assertEquals(p.printObject(), nested.isPrintable());
assertEquals(p.deferChildren(), nested.isDefer());
}
use of org.apache.logging.log4j.plugins.processor.PluginEntry in project logging-log4j2 by apache.
the class PluginProcessorTest method testFakePluginAliasesContainSameInformation.
@Test
public void testFakePluginAliasesContainSameInformation() throws Exception {
final PluginAliases aliases = FakePlugin.class.getAnnotation(PluginAliases.class);
for (final String alias : aliases.value()) {
final List<PluginType<?>> list = pluginService.getCategory(p.category());
assertNotNull(list);
final PluginEntry fake = getEntry(list, alias);
assertNotNull(fake);
verifyFakePluginEntry(alias, fake);
}
}
use of org.apache.logging.log4j.plugins.processor.PluginEntry in project logging-log4j2 by apache.
the class PluginProcessorTest method testFakePluginFoundWithCorrectInformation.
@Test
public void testFakePluginFoundWithCorrectInformation() throws Exception {
final List<PluginType<?>> list = pluginService.getCategory(p.category());
assertNotNull(list);
final PluginEntry fake = getEntry(list, p.name());
assertNotNull(fake);
verifyFakePluginEntry(p.name(), fake);
}
Aggregations