Search in sources :

Example 1 with Component

use of org.apache.logging.log4j.core.config.builder.api.Component in project logging-log4j2 by apache.

the class BuiltConfiguration method convertToNode.

protected Node convertToNode(final Node parent, final Component component) {
    final String name = component.getPluginType();
    final PluginType<?> pluginType = pluginManager.getPluginType(name);
    final Node node = new Node(parent, name, pluginType);
    node.getAttributes().putAll(component.getAttributes());
    node.setValue(component.getValue());
    final List<Node> children = node.getChildren();
    for (final Component child : component.getComponents()) {
        children.add(convertToNode(node, child));
    }
    return node;
}
Also used : Node(org.apache.logging.log4j.core.config.Node) Component(org.apache.logging.log4j.core.config.builder.api.Component)

Example 2 with Component

use of org.apache.logging.log4j.core.config.builder.api.Component in project logging-log4j2 by apache.

the class DefaultConfigurationBuilder method writeXmlComponent.

private void writeXmlComponent(final XMLStreamWriter xmlWriter, final Component component, final int nesting) throws XMLStreamException {
    if (!component.getComponents().isEmpty() || component.getValue() != null) {
        writeXmlIndent(xmlWriter, nesting);
        xmlWriter.writeStartElement(component.getPluginType());
        writeXmlAttributes(xmlWriter, component);
        if (!component.getComponents().isEmpty()) {
            xmlWriter.writeCharacters(EOL);
        }
        for (final Component subComponent : component.getComponents()) {
            writeXmlComponent(xmlWriter, subComponent, nesting + 1);
        }
        if (component.getValue() != null) {
            xmlWriter.writeCharacters(component.getValue());
        }
        if (!component.getComponents().isEmpty()) {
            writeXmlIndent(xmlWriter, nesting);
        }
        xmlWriter.writeEndElement();
    } else {
        writeXmlIndent(xmlWriter, nesting);
        xmlWriter.writeEmptyElement(component.getPluginType());
        writeXmlAttributes(xmlWriter, component);
    }
    xmlWriter.writeCharacters(EOL);
}
Also used : Component(org.apache.logging.log4j.core.config.builder.api.Component)

Example 3 with Component

use of org.apache.logging.log4j.core.config.builder.api.Component in project logging-log4j2 by apache.

the class DefaultComponentBuilder method build.

@Override
public Component build() {
    final Component component = new Component(type, name, value);
    component.getAttributes().putAll(attributes);
    component.getComponents().addAll(components);
    return component;
}
Also used : Component(org.apache.logging.log4j.core.config.builder.api.Component)

Aggregations

Component (org.apache.logging.log4j.core.config.builder.api.Component)3 Node (org.apache.logging.log4j.core.config.Node)1