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

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamWriter#writeEmptyElement() . 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_8.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: HostXml_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);

    writer.writeEmptyElement(Element.SOCKET.getLocalName());
    NativeManagementResourceDefinition.INTERFACE.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.NATIVE_PORT.marshallAsAttribute(protocol, writer);

    writer.writeEndElement();

    return true;
}
 
Example 3
Source File: ManagementXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeAuthorization(XMLExtendedStreamWriter writer, ModelNode realm) throws XMLStreamException {
    // A String comparison in-case it is an expression.
    String defaultMapGroupsToRoles = Boolean.toString(SecurityRealmResourceDefinition.MAP_GROUPS_TO_ROLES.getDefaultValue().asBoolean());
    String mapGroupsToRoles = realm.hasDefined(MAP_GROUPS_TO_ROLES) ? realm.require(MAP_GROUPS_TO_ROLES).asString() : defaultMapGroupsToRoles;

    if (realm.hasDefined(AUTHORIZATION) || defaultMapGroupsToRoles.equals(mapGroupsToRoles) == false) {
        writer.writeStartElement(Element.AUTHORIZATION.getLocalName());
        SecurityRealmResourceDefinition.MAP_GROUPS_TO_ROLES.marshallAsAttribute(realm, writer);
        if (realm.hasDefined(AUTHORIZATION)) {
            ModelNode authorization = realm.require(AUTHORIZATION);
            if (authorization.hasDefined(PROPERTIES)) {
                ModelNode properties = authorization.require(PROPERTIES);
                writer.writeEmptyElement(Element.PROPERTIES.getLocalName());
                PropertiesAuthorizationResourceDefinition.PATH.marshallAsAttribute(properties, writer);
                PropertiesAuthorizationResourceDefinition.RELATIVE_TO.marshallAsAttribute(properties, writer);
            } else if (authorization.hasDefined(PLUG_IN)) {
                writePlugIn_Authorization(writer, authorization.get(PLUG_IN));
            } else if (authorization.hasDefined(LDAP)) {
                writeLdapAuthorization(writer, authorization.get(LDAP));
            }
        }
        writer.writeEndElement();
    }
}
 
Example 4
Source File: StandaloneXml_6.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 5
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 6
Source File: HostXml_6.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);

    writer.writeEmptyElement(Element.SOCKET.getLocalName());
    NativeManagementResourceDefinition.INTERFACE.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.NATIVE_PORT.marshallAsAttribute(protocol, writer);

    writer.writeEndElement();

    return true;
}
 
Example 7
Source File: InterfacesXml.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Write the interfaces including the criteria elements.
 *
 * @param writer    the xml stream writer
 * @param modelNode the model
 * @throws XMLStreamException
 */
void writeInterfaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
    writer.writeStartElement(Element.INTERFACES.getLocalName());
    final Set<String> interfaces = new TreeSet<>(modelNode.keys());
    for (String ifaceName : interfaces) {
        final ModelNode iface = modelNode.get(ifaceName);
        writer.writeStartElement(Element.INTERFACE.getLocalName());
        writeAttribute(writer, Attribute.NAME, ifaceName);
        // <any-* /> is just handled at the root
        if (iface.get(Element.ANY_ADDRESS.getLocalName()).asBoolean(false)) {
            writer.writeEmptyElement(Element.ANY_ADDRESS.getLocalName());
        } else {
            // Write the other criteria elements
            writeInterfaceCriteria(writer, iface, false);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
Example 8
Source File: HostXml_8.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);

    writer.writeEmptyElement(Element.SOCKET.getLocalName());
    NativeManagementResourceDefinition.INTERFACE.marshallAsAttribute(protocol, writer);
    NativeManagementResourceDefinition.NATIVE_PORT.marshallAsAttribute(protocol, writer);

    writer.writeEndElement();

    return true;
}
 
Example 9
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeIgnoredResources(XMLExtendedStreamWriter writer, ModelNode ignoredTypes) throws XMLStreamException {
    for (String ignoredName : ignoredTypes.keys()) {

        ModelNode ignored = ignoredTypes.get(ignoredName);

        ModelNode names = ignored.hasDefined(NAMES) ? ignored.get(NAMES) : null;
        boolean hasNames = names != null && names.asInt() > 0;
        if (hasNames) {
            writer.writeStartElement(Element.IGNORED_RESOURCE.getLocalName());
        } else {
            writer.writeEmptyElement(Element.IGNORED_RESOURCE.getLocalName());
        }

        writer.writeAttribute(Attribute.TYPE.getLocalName(), ignoredName);
        IgnoredDomainTypeResourceDefinition.WILDCARD.marshallAsAttribute(ignored, writer);

        if (hasNames) {
            for (ModelNode name : names.asList()) {
                writer.writeEmptyElement(Element.INSTANCE.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), name.asString());
            }
            writer.writeEndElement();
        }
    }
}
 
Example 10
Source File: TestParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, ModelMarshallingContext context) throws XMLStreamException {

    String defaultNamespace = writer.getNamespaceContext().getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX);
    try {
        ModelNode subsystems = context.getModelNode().get(SUBSYSTEM);
        if (subsystems.has(mainSubsystemName)) {
            ModelNode subsystem = subsystems.get(mainSubsystemName);
            //We might have been removed
            XMLElementWriter<SubsystemMarshallingContext> subsystemWriter = context.getSubsystemWriter(mainSubsystemName);
            if (subsystemWriter != null) {
                subsystemWriter.writeContent(writer, new SubsystemMarshallingContext(subsystem, writer));
            }
        }else{
            writer.writeEmptyElement(Element.SUBSYSTEM.getLocalName());
        }
    }catch (Throwable t){
        Assert.fail("could not marshal subsystem xml: "+t.getMessage()+":\n"+ Arrays.toString(t.getStackTrace()).replaceAll(", ","\n"));
    } finally {
        writer.setDefaultNamespace(defaultNamespace);
    }
    writer.writeEndDocument();
}
 
Example 11
Source File: WriteUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void writeListAsMultipleElements(final XMLExtendedStreamWriter writer, final Element element, Attribute attribute, final ModelNode subModel) throws XMLStreamException {
    final List<ModelNode> list = subModel.asList();
    for (final ModelNode node : list) {
        writer.writeEmptyElement(element.getLocalName());
        writeAttribute(writer, attribute, node.asString());
    }
}
 
Example 12
Source File: HostXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {

    writer.writeStartElement(Element.HTTP_INTERFACE.getLocalName());
    HttpManagementResourceDefinition.HTTP_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURITY_REALM.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
            HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);
    HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);

    if (HttpManagementResourceDefinition.HTTP_UPGRADE.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.HTTP_UPGRADE.getLocalName());
        HttpManagementResourceDefinition.ENABLED.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
        HttpManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
    }

    writer.writeEmptyElement(Element.SOCKET.getLocalName());
    HttpManagementResourceDefinition.INTERFACE.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.HTTP_PORT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.HTTPS_PORT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURE_INTERFACE.marshallAsAttribute(protocol, writer);

    writer.writeEndElement();

    return true;
}
 
Example 13
Source File: DeploymentScannerParser_1_1.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode scanners = context.getModelNode();
    for (final Property list : scanners.asPropertyList()) {

        final ModelNode node = list.getValue();

        for (final Property scanner : node.asPropertyList()) {

            final String scannerName = scanner.getName();
            final ModelNode configuration = scanner.getValue();

            writer.writeEmptyElement(DEPLOYMENT_SCANNER);

            if (!DeploymentScannerExtension.DEFAULT_SCANNER_NAME.equals(scannerName)) {
                writer.writeAttribute(NAME, scannerName);
            }

            DeploymentScannerDefinition.PATH.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.RELATIVE_TO.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_ENABLED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.SCAN_INTERVAL.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_ZIPPED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_EXPLODED.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.AUTO_DEPLOY_XML.marshallAsAttribute(configuration, writer);
            DeploymentScannerDefinition.DEPLOYMENT_TIMEOUT.marshallAsAttribute(configuration, writer);
        }
        writer.writeEndElement();
    }
}
 
Example 14
Source File: PatchBundleXml_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter writer, BundledPatch bundledPatch) throws XMLStreamException {

    writer.writeStartElement(Element.PATCHES.name);
    writer.writeDefaultNamespace(PatchXml.Namespace.PATCH_BUNDLE_1_0.getNamespace());

    for (final BundledPatch.BundledPatchEntry entry : bundledPatch.getPatches()) {
        writer.writeEmptyElement(Element.PATCH_ELEMENT.name);
        writer.writeAttribute(Attribute.ID.name, entry.getPatchId());
        writer.writeAttribute(Attribute.PATH.name, entry.getPatchPath());
    }

    writer.writeEndElement();
}
 
Example 15
Source File: RemotingSubsystemXMLPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeEndpointIfAttributesSet(final XMLExtendedStreamWriter writer, final ModelNode model) throws XMLStreamException {
    boolean defined = false;
    for (String adName : RemotingEndpointResource.ATTRIBUTES.keySet()) {
        if (model.hasDefined(adName)) {
            defined = true;
            break;
        }
    }
    if (defined) {
        writer.writeEmptyElement(RemotingEndpointResource.ENDPOINT_PATH.getValue());
        for (AttributeDefinition ad : RemotingEndpointResource.ATTRIBUTES.values()) {
            ad.getMarshaller().marshallAsAttribute(ad, model, true, writer);
        }
    }
}
 
Example 16
Source File: JvmXml.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void writeJVMElement(final XMLExtendedStreamWriter writer, final String jvmName, final ModelNode jvmElement)
        throws XMLStreamException {
    writer.writeStartElement(Element.JVM.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), jvmName);

    JvmAttributes.TYPE.marshallAsAttribute(jvmElement, writer);
    JvmAttributes.JAVA_HOME.marshallAsAttribute(jvmElement, writer);
    JvmAttributes.DEBUG_ENABLED.marshallAsAttribute(jvmElement, writer);
    JvmAttributes.DEBUG_OPTIONS.marshallAsAttribute(jvmElement, writer);
    if (JvmAttributes.DEBUG_OPTIONS.isMarshallable(jvmElement)) {
        if (!JvmAttributes.DEBUG_ENABLED.isMarshallable(jvmElement)) {
            writer.writeAttribute(Attribute.DEBUG_ENABLED.getLocalName(), "false");
        }
    }
    JvmAttributes.ENV_CLASSPATH_IGNORED.marshallAsAttribute(jvmElement, writer);
    if (JvmAttributes.HEAP_SIZE.isMarshallable(jvmElement) || JvmAttributes.MAX_HEAP_SIZE.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.HEAP.getLocalName());
        JvmAttributes.HEAP_SIZE.marshallAsAttribute(jvmElement, writer);
        JvmAttributes.MAX_HEAP_SIZE.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.PERMGEN_SIZE.isMarshallable(jvmElement) || JvmAttributes.MAX_PERMGEN_SIZE.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.PERMGEN.getLocalName());
        JvmAttributes.PERMGEN_SIZE.marshallAsAttribute(jvmElement, writer);
        JvmAttributes.MAX_PERMGEN_SIZE.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.STACK_SIZE.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.STACK.getLocalName());
        JvmAttributes.STACK_SIZE.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.AGENT_LIB.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.AGENT_LIB.getLocalName());
        JvmAttributes.AGENT_LIB.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.AGENT_PATH.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.AGENT_PATH.getLocalName());
        JvmAttributes.AGENT_PATH.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.JAVA_AGENT.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.JAVA_AGENT.getLocalName());
        JvmAttributes.JAVA_AGENT.marshallAsAttribute(jvmElement, writer);
    }
    if (JvmAttributes.OPTIONS.isMarshallable(jvmElement)) {
        JvmAttributes.OPTIONS.marshallAsElement(jvmElement, writer);
    }
    if (JvmAttributes.ENVIRONMENT_VARIABLES.isMarshallable(jvmElement)) {
        JvmAttributes.ENVIRONMENT_VARIABLES.marshallAsElement(jvmElement, writer);
    }
    if (JvmAttributes.LAUNCH_COMMAND.isMarshallable(jvmElement)) {
        writer.writeEmptyElement(Element.LAUNCH_COMMAND.getLocalName());
        JvmAttributes.PREFIX.marshallAsAttribute(jvmElement, writer);
    }

    if (JvmAttributes.MODULE_OPTIONS.isMarshallable(jvmElement)) {
        JvmAttributes.MODULE_OPTIONS.marshallAsElement(jvmElement, writer);
    }

    writer.writeEndElement();
}
 
Example 17
Source File: StandaloneXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {

    writer.writeStartElement(Element.HTTP_INTERFACE.getLocalName());
    HttpManagementResourceDefinition.HTTP_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURITY_REALM.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);

    boolean consoleEnabled = protocol.get(ModelDescriptionConstants.CONSOLE_ENABLED).asBoolean(true);
    if (!consoleEnabled) {
        HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
    }

    HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
            HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);

    if (HttpManagementResourceDefinition.HTTP_UPGRADE.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.HTTP_UPGRADE.getLocalName());
        HttpManagementResourceDefinition.ENABLED.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
        HttpManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
    }

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

    if (HttpManagementResourceDefinition.CONSTANT_HEADERS.isMarshallable(protocol)) {
        writer.writeStartElement(Element.CONSTANT_HEADERS.getLocalName());

        for (ModelNode headerMapping : protocol.require(ModelDescriptionConstants.CONSTANT_HEADERS).asList()) {
            writer.writeStartElement(Element.HEADER_MAPPING.getLocalName());
            BaseHttpInterfaceResourceDefinition.PATH.marshallAsAttribute(headerMapping, writer);
            for (ModelNode header : headerMapping.require(ModelDescriptionConstants.HEADERS).asList()) {
                writer.writeEmptyElement(Element.HEADER.getLocalName());
                BaseHttpInterfaceResourceDefinition.HEADER_NAME.marshallAsAttribute(header, writer);
                BaseHttpInterfaceResourceDefinition.HEADER_VALUE.marshallAsAttribute(header, writer);
            }
            writer.writeEndElement();
        }

        writer.writeEndElement();
    }

    writer.writeEndElement();

    return true;
}
 
Example 18
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void writeCountElement(AttributeDefinition attributeDefinition, ModelNode model, XMLExtendedStreamWriter writer) throws XMLStreamException {
    if (attributeDefinition.isMarshallable(model)) {
        writer.writeEmptyElement(attributeDefinition.getXmlName());
        writer.writeAttribute(Attribute.COUNT.getLocalName(), model.get(attributeDefinition.getName()).asString());
    }
}
 
Example 19
Source File: PatchXmlUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected static void writeMiscItem(final XMLExtendedStreamWriter writer, final Element element, final ContentModification modification) throws XMLStreamException {

        writer.writeEmptyElement(element.name);

        final MiscContentItem item = (MiscContentItem) modification.getItem();
        final ModificationType type = modification.getType();

        final StringBuilder path = new StringBuilder();
        for(final String p : item.getPath()) {
            path.append(p).append(PATH_DELIMITER);
        }
        path.append(item.getName());

        writer.writeAttribute(Attribute.PATH.name, path.toString());
        if (item.isDirectory()) {
            writer.writeAttribute(Attribute.DIRECTORY.name, "true");
        }

        final ModificationCondition condition = modification.getCondition();
        if(condition != null) {
            writer.writeAttribute(Attribute.CONDITION.name, condition.toString());
        }

        if(type == ModificationType.REMOVE) {
            final byte[] existingHash = modification.getTargetHash();
            if (existingHash.length > 0) {
                writer.writeAttribute(Attribute.HASH.name, bytesToHexString(existingHash));
            }
            if(item.isAffectsRuntime()) {
                writer.writeAttribute(Attribute.IN_RUNTIME_USE.name, "true");
            }
        } else {
            byte[] hash = item.getContentHash();
            if(hash.length > 0) {
                writer.writeAttribute(Attribute.HASH.name, bytesToHexString(hash));
            }

            if(type == ModificationType.MODIFY) {
                writer.writeAttribute(Attribute.NEW_HASH.name, bytesToHexString(modification.getTargetHash()));
                if (item.isAffectsRuntime()) {
                    writer.writeAttribute(Attribute.IN_RUNTIME_USE.name, "true");
                }
            }
        }
    }
 
Example 20
Source File: DeploymentScannerParser_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode scanners = context.getModelNode();
    for (final Property list : scanners.asPropertyList()) {
        final ModelNode node = list.getValue();

        for (final Property scanner : node.asPropertyList()) {

            writer.writeEmptyElement(CommonAttributes.DEPLOYMENT_SCANNER);
            writer.writeAttribute(CommonAttributes.NAME, scanner.getName());
            ModelNode configuration = scanner.getValue();
            if (configuration.hasDefined(PATH)) {
                writer.writeAttribute(PATH, configuration.get(PATH)
                        .asString());
            }
            if (configuration.hasDefined(CommonAttributes.SCAN_ENABLED)) {
                writer.writeAttribute(CommonAttributes.SCAN_ENABLED,
                        configuration.get(CommonAttributes.SCAN_ENABLED).asString());
            }
            if (configuration.hasDefined(CommonAttributes.SCAN_INTERVAL)) {
                writer.writeAttribute(CommonAttributes.SCAN_INTERVAL,
                        configuration.get(CommonAttributes.SCAN_INTERVAL).asString());
            }
            if (configuration.hasDefined(CommonAttributes.RELATIVE_TO)) {
                writer.writeAttribute(CommonAttributes.RELATIVE_TO,
                        configuration.get(CommonAttributes.RELATIVE_TO).asString());
            }
            if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_ZIPPED)) {
                if (!configuration.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).asBoolean()) {
                    writer.writeAttribute(CommonAttributes.AUTO_DEPLOY_ZIPPED, Boolean.FALSE.toString());
                }
            }
            if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_EXPLODED)) {
                if (configuration.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).asBoolean()) {
                    writer.writeAttribute(CommonAttributes.AUTO_DEPLOY_EXPLODED, Boolean.TRUE.toString());
                }
            }
            if (configuration.hasDefined(CommonAttributes.DEPLOYMENT_TIMEOUT)) {
                writer.writeAttribute(CommonAttributes.DEPLOYMENT_TIMEOUT, configuration.get(CommonAttributes.DEPLOYMENT_TIMEOUT).asString());
            }
        }
        writer.writeEndElement();
    }
}