use of org.apache.logging.log4j.plugins.Node in project logging-log4j2 by apache.
the class RequiredValidatorTest method setUp.
@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType<ValidatingPlugin>) manager.getPluginType("Validator");
assertNotNull(plugin, "Rebuild this module to make sure annotation processing kicks in.");
node = new Node(null, "Validator", plugin);
}
use of org.apache.logging.log4j.plugins.Node in project logging-log4j2 by apache.
the class ValidatingPluginWithGenericBuilderTest method setUp.
@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType<ValidatingPluginWithGenericBuilder>) manager.getPluginType("ValidatingPluginWithGenericBuilder");
assertNotNull(plugin, "Rebuild this module to make sure annotation processing kicks in.");
node = new Node(null, "Validator", plugin);
}
use of org.apache.logging.log4j.plugins.Node in project logging-log4j2 by apache.
the class ValidatingPluginWithTypedBuilderTest method setUp.
@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
final PluginManager manager = new PluginManager("Test");
manager.collectPlugins();
plugin = (PluginType<ValidatingPluginWithTypedBuilder>) manager.getPluginType("ValidatingPluginWithTypedBuilder");
assertNotNull(plugin, "Rebuild this module to make sure annotation processing kicks in.");
node = new Node(null, "Validator", plugin);
}
use of org.apache.logging.log4j.plugins.Node in project logging-log4j2 by apache.
the class AppenderSet method createAppender.
public Appender createAppender(final String actualAppenderName, final String sourceAppenderName) {
final Node node = nodeMap.get(actualAppenderName);
if (node == null) {
LOGGER.error("No node named {} in {}", actualAppenderName, this);
return null;
}
node.getAttributes().put("name", sourceAppenderName);
if (node.getType().getElementName().equals(Appender.ELEMENT_TYPE)) {
final Node appNode = new Node(node);
configuration.createConfiguration(appNode, null);
if (appNode.getObject() instanceof Appender) {
final Appender app = appNode.getObject();
app.start();
return app;
}
LOGGER.error("Unable to create Appender of type " + node.getName());
return null;
}
LOGGER.error("No Appender was configured for name {} " + actualAppenderName);
return null;
}
use of org.apache.logging.log4j.plugins.Node in project logging-log4j2 by apache.
the class AbstractConfiguration method processSelect.
/**
* Handle Select nodes. This finds the first child condition that returns true and attaches its children
* to the parent of the Select Node. Other Nodes are discarded.
* @param selectNode The Select Node.
* @param type The PluginType of the Select Node.
* @return The list of Nodes to be added to the parent.
*/
protected List<Node> processSelect(final Node selectNode, final PluginType<?> type) {
final List<Node> addList = new ArrayList<>();
final SelectArbiter select = (SelectArbiter) createPluginObject(type, selectNode, null);
final List<Arbiter> conditions = new ArrayList<>();
for (final Node child : selectNode.getChildren()) {
final PluginType<?> nodeType = child.getType();
if (nodeType != null) {
if (Arbiter.class.isAssignableFrom(nodeType.getPluginClass())) {
final Arbiter condition = (Arbiter) createPluginObject(nodeType, child, null);
conditions.add(condition);
child.setObject(condition);
} else {
LOGGER.error("Invalid Node {} for Select. Must be a Condition", child.getName());
}
} else {
LOGGER.error("No PluginType for node {}", child.getName());
}
}
final Arbiter condition = select.evaluateConditions(conditions);
if (condition != null) {
for (final Node child : selectNode.getChildren()) {
if (condition == child.getObject()) {
addList.addAll(child.getChildren());
processConditionals(child);
}
}
}
return addList;
}
Aggregations