org.apache.logging.log4j.core.config.plugins.util.PluginType Java Examples
The following examples show how to use
org.apache.logging.log4j.core.config.plugins.util.PluginType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConstraintPlugins.java From logging-log4j-audit with Apache License 2.0 | 7 votes |
private ConstraintPlugins() { final PluginManager manager = new PluginManager(ConstraintType.CATEGORY); if (LOGGER instanceof org.apache.logging.log4j.core.Logger) { List<String> pluginPackages = ((org.apache.logging.log4j.core.Logger) LOGGER).getContext().getConfiguration().getPluginPackages(); manager.collectPlugins(pluginPackages); } else { manager.collectPlugins(); } final Map<String, PluginType<?>> plugins = manager.getPlugins(); for (Map.Entry<String, PluginType<?>> entry : plugins.entrySet()) { try { final Class<? extends ConstraintType> clazz = entry.getValue().getPluginClass().asSubclass(ConstraintType.class); ConstraintType constraintType = ReflectionUtil.instantiate(clazz); constraintMap.put(entry.getKey(), constraintType); } catch (final Throwable t) { throw new ConstraintCreationException("Unable to create constraint for " + entry.getKey(), t); } } }
Example #2
Source File: BuilderManager.java From logging-log4j2 with Apache License 2.0 | 5 votes |
public Appender parseAppender(String className, Element appenderElement, XmlConfigurationFactory factory) { PluginType<?> plugin = plugins.get(className.toLowerCase()); if (plugin != null) { try { @SuppressWarnings("unchecked") AppenderBuilder builder = (AppenderBuilder) LoaderUtil.newInstanceOf(plugin.getPluginClass()); return builder.parseAppender(appenderElement, factory); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) { LOGGER.warn("Unable to load plugin: {} due to: {}", plugin.getKey(), ex.getMessage()); } } return null; }
Example #3
Source File: BuilderManager.java From logging-log4j2 with Apache License 2.0 | 5 votes |
public Filter parseFilter(String className, Element filterElement, XmlConfigurationFactory factory) { PluginType<?> plugin = plugins.get(className.toLowerCase()); if (plugin != null) { try { @SuppressWarnings("unchecked") FilterBuilder builder = (FilterBuilder) LoaderUtil.newInstanceOf(plugin.getPluginClass()); return builder.parseFilter(filterElement, factory); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) { LOGGER.warn("Unable to load plugin: {} due to: {}", plugin.getKey(), ex.getMessage()); } } return null; }
Example #4
Source File: BuilderManager.java From logging-log4j2 with Apache License 2.0 | 5 votes |
public Layout parseLayout(String className, Element layoutElement, XmlConfigurationFactory factory) { PluginType<?> plugin = plugins.get(className.toLowerCase()); if (plugin != null) { try { @SuppressWarnings("unchecked") LayoutBuilder builder = (LayoutBuilder) LoaderUtil.newInstanceOf(plugin.getPluginClass()); return builder.parseLayout(layoutElement, factory); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) { LOGGER.warn("Unable to load plugin: {} due to: {}", plugin.getKey(), ex.getMessage()); } } return null; }
Example #5
Source File: LogTest.java From x-pipe with Apache License 2.0 | 3 votes |
@Test public void testPlugin(){ PluginManager pm = new PluginManager(PatternConverter.CATEGORY); pm.collectPlugins(); for(Entry<String, PluginType<?>> entry : pm.getPlugins().entrySet()){ logger.info("{} : {}", entry.getKey(), entry.getValue()); } logger.error("[testPlugin]", new IOException("io exception message...")); }