Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamWriter#writeStartElement()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamWriter#writeStartElement() . 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: StandaloneXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public boolean writeNativeManagementProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {

    writer.writeStartElement(Element.NATIVE_INTERFACE.getLocalName());
    NativeManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.SECURITY_REALM.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);

    if (NativeManagementResourceDefinition.SOCKET_BINDING.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.SOCKET_BINDING.getLocalName());
        NativeManagementResourceDefinition.SOCKET_BINDING.marshallAsAttribute(protocol, writer);
    }

    writer.writeEndElement();

    return true;
}
 
Example 2
Source File: RemotingSubsystemXMLPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeWorkerThreadPoolIfAttributesSet(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (node.hasDefined(CommonAttributes.WORKER_READ_THREADS) || node.hasDefined(CommonAttributes.WORKER_TASK_CORE_THREADS) || node.hasDefined(CommonAttributes.WORKER_TASK_KEEPALIVE) ||
            node.hasDefined(CommonAttributes.WORKER_TASK_LIMIT) || node.hasDefined(CommonAttributes.WORKER_TASK_MAX_THREADS) || node.hasDefined(CommonAttributes.WORKER_WRITE_THREADS)) {

        writer.writeStartElement(Element.WORKER_THREAD_POOL.getLocalName());

        RemotingSubsystemRootResource.WORKER_READ_THREADS.marshallAsAttribute(node, false, writer);
        RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS.marshallAsAttribute(node, false, writer);
        RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE.marshallAsAttribute(node, false, writer);
        RemotingSubsystemRootResource.WORKER_TASK_LIMIT.marshallAsAttribute(node, false, writer);
        RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS.marshallAsAttribute(node, false, writer);
        RemotingSubsystemRootResource.WORKER_WRITE_THREADS.marshallAsAttribute(node, false, writer);

        writer.writeEndElement();
    }

}
 
Example 3
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void writeRoleIdentifiers(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    ModelNode value = model.get(Constants.Model.ROLE_ATTRIBUTES);
    if (!value.isDefined()) {
        return;
    }

    List<ModelNode> items = value.asList();
    if (items.size() == 0) {
        return;
    }

    writer.writeStartElement(Constants.XML.ROLE_IDENTIFIERS);
    for (ModelNode item : items) {
        writer.writeStartElement(Constants.XML.ATTRIBUTE);
        writer.writeAttribute("name", item.asString());
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
Example 4
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void writeBoundedQueueThreadPool(final XMLExtendedStreamWriter writer, final Property property, final String elementName,
                                        final boolean includeName, final boolean blocking)
        throws XMLStreamException {
    writer.writeStartElement(elementName);
    ModelNode node = property.getValue();
    if (includeName) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    }
    PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT.marshallAsAttribute(node, writer);
    writeCountElement(PoolAttributeDefinitions.CORE_THREADS, node, writer);
    writeCountElement(PoolAttributeDefinitions.QUEUE_LENGTH, node, writer);
    writeCountElement(PoolAttributeDefinitions.MAX_THREADS, node, writer);

    writeTime(writer, node, Element.KEEPALIVE_TIME);
    writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY);
    if (!blocking) {
        writeRef(writer, node, Element.HANDOFF_EXECUTOR, HANDOFF_EXECUTOR);
    }
    writer.writeEndElement();
}
 
Example 5
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
  ModelNode node = context.getModelNode();
  ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName());
  
  if (jobExecutorNode.isDefined()) { 
    writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName());
    
    for (Property property : jobExecutorNode.asPropertyList()) {
      ModelNode propertyValue = property.getValue();

      for (AttributeDefinition jobExecutorAttribute : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) {
        if (jobExecutorAttribute.equals(SubsystemAttributeDefinitons.NAME)) {
          ((SimpleAttributeDefinition) jobExecutorAttribute).marshallAsAttribute(propertyValue, writer);
        } else {
          jobExecutorAttribute.marshallAsElement(propertyValue, writer);
        }
      }

      writeJobAcquisitionsContent(writer, context, propertyValue);
    }

    // end job-executor
    writer.writeEndElement();
  }
}
 
Example 6
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private void writeSecureResource(String tagName, List<SimpleAttributeDefinition> attributes, XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    if (!context.getModelNode().get(tagName).isDefined()) {
        return;
    }
    for (Property deployment : context.getModelNode().get(tagName).asPropertyList()) {
        writer.writeStartElement(tagName);
        writer.writeAttribute("name", deployment.getName());
        ModelNode deploymentElements = deployment.getValue();
        for (AttributeDefinition element : attributes) {
            element.marshallAsElement(deploymentElements, writer);
        }

        ModelNode credentials = deploymentElements.get(CredentialDefinition.TAG_NAME);
        if (credentials.isDefined()) {
            writeCredentials(writer, credentials);
        }

        ModelNode redirectRewriteRule = deploymentElements.get(RedirecRewritetRuleDefinition.TAG_NAME);
        if (redirectRewriteRule.isDefined()) {
            writeRedirectRules(writer, redirectRewriteRule);
        }

        writer.writeEndElement();
    }
}
 
Example 7
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeUnboundedQueueThreadPoolInternal(final XMLExtendedStreamWriter writer, final Property property,
                                                   final String elementName, final boolean includeName,
                                                   final boolean supportsCoreThreads) throws XMLStreamException {
    writer.writeStartElement(elementName);
    ModelNode node = property.getValue();
    if (includeName) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    }
    writeCountElement(PoolAttributeDefinitions.MAX_THREADS, node, writer);

    if(supportsCoreThreads) {
        writeCountElement(PoolAttributeDefinitions.CORE_THREADS, node, writer);
    }

    writeTime(writer, node, Element.KEEPALIVE_TIME);
    writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY);

    writer.writeEndElement();
}
 
Example 8
Source File: RollbackPatchXml_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void writeInstallation(final XMLExtendedStreamWriter writer, final InstalledIdentity identity) throws XMLStreamException {

        writer.writeStartElement(Element.INSTALLATION.name);

        // identity
        writeTargetInfo(writer, Element.IDENTITY, identity.getIdentity());
        // layers
        for (final Layer layer : identity.getLayers()) {
            writeTargetInfo(writer, Element.LAYER, layer);
        }
        // addons
        for (final AddOn addOn : identity.getAddOns()) {
            writeTargetInfo(writer, Element.ADD_ON, addOn);
        }

        writer.writeEndElement();
    }
 
Example 9
Source File: AuditLogXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeAuditLogSyslogProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {
    String type = protocol.keys().iterator().next();
    ModelNode protocolContents = protocol.get(type);
    if (type.equals(ModelDescriptionConstants.UDP)) {
        writer.writeStartElement(type);
        SyslogAuditLogProtocolResourceDefinition.Udp.HOST.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Udp.PORT.marshallAsAttribute(protocolContents, writer);
        writer.writeEndElement();
    } else if (type.equals(ModelDescriptionConstants.TCP)) {
        writer.writeStartElement(type);
        SyslogAuditLogProtocolResourceDefinition.Tcp.HOST.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tcp.PORT.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tcp.MESSAGE_TRANSFER.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tcp.RECONNECT_TIMEOUT.marshallAsAttribute(protocolContents, writer);
        writer.writeEndElement();
    } else if (type.equals(ModelDescriptionConstants.TLS)) {
        writer.writeStartElement(type);
        SyslogAuditLogProtocolResourceDefinition.Tls.HOST.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tls.PORT.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tls.MESSAGE_TRANSFER.marshallAsAttribute(protocolContents, writer);
        SyslogAuditLogProtocolResourceDefinition.Tcp.RECONNECT_TIMEOUT.marshallAsAttribute(protocolContents, writer);

        if (protocolContents.hasDefined(AUTHENTICATION)) {
            writeAuditLogSyslogTlsProtocolKeyStore(writer, protocolContents.get(AUTHENTICATION), TRUSTSTORE);
            writeAuditLogSyslogTlsProtocolKeyStore(writer, protocolContents.get(AUTHENTICATION), CLIENT_CERT_STORE);
        }

        writer.writeEndElement();
    }
}
 
Example 10
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeHttpClient(XMLExtendedStreamWriter writer, ModelNode httpClientModel) throws XMLStreamException {
    if (!httpClientModel.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.HTTP_CLIENT);
    for (SimpleAttributeDefinition attr : HttpClientDefinition.ATTRIBUTES) {
        attr.marshallAsAttribute(httpClientModel, false, writer);
    }
    writer.writeEndElement();
}
 
Example 11
Source File: LoggingSubsystemWriter.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeFormatters(final XMLExtendedStreamWriter writer, final String resourceName,
                             final AttributeDefinition attribute, final ModelNode model) throws XMLStreamException {
    if (model.hasDefined(resourceName)) {
        for (String name : model.get(resourceName).keys()) {
            writer.writeStartElement(Element.FORMATTER.getLocalName());
            writer.writeAttribute(NAME.getXmlName(), name);
            final ModelNode value = model.get(resourceName, name);
            attribute.marshallAsElement(value, writer);
            writer.writeEndElement();
        }
    }
}
 
Example 12
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeSingleSignOn(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.SINGLE_SIGN_ON);
    for (SimpleAttributeDefinition attr : SingleSignOnDefinition.ATTRIBUTES) {
        attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    }
    writer.writeEndElement();
}
 
Example 13
Source File: LoggingSubsystemWriter.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeConsoleHandler(final XMLExtendedStreamWriter writer, final ModelNode model, final String name)
        throws XMLStreamException {
    writer.writeStartElement(Element.CONSOLE_HANDLER.getLocalName());
    writer.writeAttribute(HANDLER_NAME.getXmlName(), name);
    AUTOFLUSH.marshallAsAttribute(model, writer);
    ENABLED.marshallAsAttribute(model, false, writer);
    writeCommonHandler(writer, model);
    TARGET.marshallAsElement(model, writer);
    writer.writeEndElement();
}
 
Example 14
Source File: ModuleDependency.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, Dependency value) throws XMLStreamException {

    if(value != null && this != value) {
        throw new IllegalStateException("Wrong target dependency.");
    }

    writer.writeStartElement(ModuleConfigImpl.MODULE);
    writer.writeAttribute(ModuleConfigImpl.NAME, name);
    if (export) {
        writer.writeAttribute(ModuleConfigImpl.EXPORT, "true");
    }
    writer.writeEndElement();
}
 
Example 15
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeAllowedClockSkew(XMLExtendedStreamWriter writer, ModelNode allowedClockSkew) throws XMLStreamException {
    if (!allowedClockSkew.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.ALLOWED_CLOCK_SKEW);
    AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT.getAttributeMarshaller().marshallAsAttribute(AllowedClockSkew.ALLOWED_CLOCK_SKEW_UNIT, allowedClockSkew, false, writer);
    ModelNode allowedClockSkewValue = allowedClockSkew.get(Constants.Model.ALLOWED_CLOCK_SKEW_VALUE);
    char[] chars = allowedClockSkewValue.asString().toCharArray();
    writer.writeCharacters(chars, 0, chars.length);
    writer.writeEndElement();
}
 
Example 16
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeSingleLogout(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.SINGLE_LOGOUT);
    for (SimpleAttributeDefinition attr : SingleLogoutDefinition.ATTRIBUTES) {
        attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    }
    writer.writeEndElement();
}
 
Example 17
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeSingleSignOn(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.SINGLE_SIGN_ON);
    for (SimpleAttributeDefinition attr : SingleSignOnDefinition.ATTRIBUTES) {
        attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    }
    writer.writeEndElement();
}
 
Example 18
Source File: RemotingSubsystemXMLPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeProperties(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    writer.writeStartElement(Element.PROPERTIES.getLocalName());
    for (Property prop : node.asPropertyList()) {
        writer.writeStartElement(Element.PROPERTY.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
        PropertyResource.VALUE.marshallAsAttribute(prop.getValue(), writer);
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
Example 19
Source File: OrderedChildResourceExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
    context.startSubsystemElement(OrderedChildResourceExtension.NAMESPACE, false);
    final ModelNode node = context.getModelNode();
    if (node.hasDefined("child")) {
        for (Property prop : node.get("child").asPropertyList()) {
            writer.writeStartElement("child");
            writer.writeAttribute("name", prop.getName());
            writer.writeEndElement();
        }
    }
    writer.writeEndElement();
}
 
Example 20
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void writeServers(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {

        for (String serverName : modelNode.keys()) {
            final ModelNode server = modelNode.get(serverName);

            writer.writeStartElement(Element.SERVER.getLocalName());

            WriteUtils.writeAttribute(writer, Attribute.NAME, serverName);
            ServerConfigResourceDefinition.GROUP.marshallAsAttribute(server, writer);
            ServerConfigResourceDefinition.AUTO_START.marshallAsAttribute(server, writer);
            ServerConfigResourceDefinition.UPDATE_AUTO_START_WITH_SERVER_STATUS.marshallAsAttribute(server, writer);
            if (server.hasDefined(PATH)) {
                writePaths(writer, server.get(PATH), false);
            }
            if (server.hasDefined(SYSTEM_PROPERTY)) {
                writeProperties(writer, server.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
            }
            if (server.hasDefined(INTERFACE)) {
                writeInterfaces(writer, server.get(INTERFACE));
            }
            if (server.hasDefined(JVM)) {
                for (final Property jvm : server.get(JVM).asPropertyList()) {
                    JvmXml.writeJVMElement(writer, jvm.getName(), jvm.getValue());
                    break; // TODO just write the first !?
                }
            }
            if (server.hasDefined(SOCKET_BINDING_GROUP) || server.hasDefined(SOCKET_BINDING_PORT_OFFSET) || server.hasDefined(SOCKET_BINDING_DEFAULT_INTERFACE)) {
                writer.writeStartElement(Element.SOCKET_BINDINGS.getLocalName());
                ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.marshallAsAttribute(server, writer);
                ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.marshallAsAttribute(server, writer);
                ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.marshallAsAttribute(server, writer);
                writer.writeEndElement();
            }
            if (server.hasDefined(SSL, LOOPBACK)) {
                ModelNode ssl = server.get(SSL, LOOPBACK);
                writer.writeStartElement(Element.SSL.getLocalName());
                SslLoopbackResourceDefinition.SSL_PROTOCOCOL.marshallAsAttribute(ssl, writer);
                SslLoopbackResourceDefinition.TRUST_MANAGER_ALGORITHM.marshallAsAttribute(ssl, writer);
                SslLoopbackResourceDefinition.TRUSTSTORE_TYPE.marshallAsAttribute(ssl, writer);
                SslLoopbackResourceDefinition.TRUSTSTORE_PATH.marshallAsAttribute(ssl, writer);
                SslLoopbackResourceDefinition.TRUSTSTORE_PASSWORD.marshallAsAttribute(ssl, writer);
                writer.writeEndElement();
            }

            writer.writeEndElement();
        }
    }