use of org.apache.logging.log4j.core.config.arbiters.SelectArbiter 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