Search in sources :

Example 21 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class MessagingXMLWriter method writeTopics.

private static void writeTopics(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    if (node.asInt() > 0) {
        for (String name : node.keys()) {
            final ModelNode topic = node.get(name);
            if (topic.isDefined()) {
                writer.writeStartElement(Element.JMS_TOPIC.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), name);
                for (AttributeDefinition attribute : JMSTopicDefinition.ATTRIBUTES) {
                    attribute.marshallAsElement(topic, writer);
                }
                writer.writeEndElement();
            }
        }
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 22 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class MessagingXMLWriter method writeJmsBridge.

private void writeJmsBridge(XMLExtendedStreamWriter writer, String bridgeName, ModelNode value) throws XMLStreamException {
    writer.writeStartElement(Element.JMS_BRIDGE.getLocalName());
    if (!DEFAULT.equals(bridgeName)) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), bridgeName);
    }
    JMSBridgeDefinition.MODULE.marshallAsAttribute(value, writer);
    writer.writeStartElement(SOURCE.getLocalName());
    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_SOURCE_ATTRIBUTES) {
        attr.marshallAsElement(value, writer);
    }
    writer.writeEndElement();
    writer.writeStartElement(TARGET.getLocalName());
    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_TARGET_ATTRIBUTES) {
        attr.marshallAsElement(value, writer);
    }
    writer.writeEndElement();
    for (AttributeDefinition attr : JMSBridgeDefinition.JMS_BRIDGE_ATTRIBUTES) {
        if (attr == JMSBridgeDefinition.MODULE) {
            // handled as a XML attribute
            continue;
        }
        attr.marshallAsElement(value, writer);
    }
    writer.writeEndElement();
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition)

Example 23 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class MessagingXMLWriter method writeConnectionFactories.

private static void writeConnectionFactories(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    if (node.asInt() > 0) {
        for (String name : node.keys()) {
            final ModelNode factory = node.get(name);
            if (factory.isDefined()) {
                writer.writeStartElement(Element.CONNECTION_FACTORY.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), name);
                for (AttributeDefinition attribute : ConnectionFactoryDefinition.ATTRIBUTES) {
                    attribute.marshallAsElement(factory, writer);
                }
                writer.writeEndElement();
            }
        }
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 24 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class MessagingXMLWriter method writeConnectorServices.

private static void writeConnectorServices(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.CONNECTOR_SERVICES.getLocalName());
        for (final Property property : node.asPropertyList()) {
            writer.writeStartElement(Element.CONNECTOR_SERVICE.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            final ModelNode service = property.getValue();
            for (AttributeDefinition attribute : ConnectorServiceDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(property.getValue(), writer);
            }
            // TODO use a custom attribute marshaller
            if (service.hasDefined(CommonAttributes.PARAM)) {
                for (Property param : service.get(CommonAttributes.PARAM).asPropertyList()) {
                    writer.writeEmptyElement(Element.PARAM.getLocalName());
                    writer.writeAttribute(Attribute.KEY.getLocalName(), param.getName());
                    writer.writeAttribute(Attribute.VALUE.getLocalName(), param.getValue().get(ConnectorServiceParamDefinition.VALUE.getName()).asString());
                }
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 25 with AttributeDefinition

use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.

the class MessagingXMLWriter method writeBroadcastGroups.

private static void writeBroadcastGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.BROADCAST_GROUPS.getLocalName());
        for (final Property property : properties) {
            writer.writeStartElement(Element.BROADCAST_GROUP.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            for (AttributeDefinition attribute : BroadcastGroupDefinition.ATTRIBUTES) {
                attribute.marshallAsElement(property.getValue(), writer);
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) Property(org.jboss.dmr.Property)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)79 ModelNode (org.jboss.dmr.ModelNode)43 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)33 OperationContext (org.jboss.as.controller.OperationContext)16 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 PathAddress (org.jboss.as.controller.PathAddress)12 Resource (org.jboss.as.controller.registry.Resource)11 Property (org.jboss.dmr.Property)11 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)10 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 AbstractAddStepHandler (org.jboss.as.controller.AbstractAddStepHandler)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 PathElement (org.jboss.as.controller.PathElement)5 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)5 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)5 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)5 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5