Search in sources :

Example 76 with AttributeDefinition

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

the class MessagingXMLWriter method writeHornetQServer.

private static void writeHornetQServer(final XMLExtendedStreamWriter writer, final String serverName, final ModelNode node) throws XMLStreamException {
    writer.writeStartElement(Element.HORNETQ_SERVER.getLocalName());
    if (!DEFAULT.equals(serverName)) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), serverName);
    }
    for (AttributeDefinition simpleAttribute : CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES) {
        simpleAttribute.marshallAsElement(node, writer);
    }
    final ModelNode paths = node.get(ModelDescriptionConstants.PATH);
    writeDirectory(writer, Element.PAGING_DIRECTORY, paths);
    writeDirectory(writer, Element.BINDINGS_DIRECTORY, paths);
    writeDirectory(writer, Element.JOURNAL_DIRECTORY, paths);
    writeDirectory(writer, Element.LARGE_MESSAGES_DIRECTORY, paths);
    // New line after the simpler elements
    writeNewLine(writer);
    writeConnectors(writer, node);
    writeAcceptors(writer, node);
    writeBroadcastGroups(writer, node.get(BROADCAST_GROUP));
    writeDiscoveryGroups(writer, node.get(DISCOVERY_GROUP));
    writeDiverts(writer, node.get(DIVERT));
    writeQueues(writer, node.get(CommonAttributes.QUEUE));
    writeBridges(writer, node.get(CommonAttributes.BRIDGE));
    writeClusterConnections(writer, node.get(CommonAttributes.CLUSTER_CONNECTION));
    writeGroupingHandler(writer, node.get(GROUPING_HANDLER));
    writeSecuritySettings(writer, node.get(CommonAttributes.SECURITY_SETTING));
    writeAddressSettings(writer, node.get(ADDRESS_SETTING));
    writeConnectorServices(writer, node.get(CommonAttributes.CONNECTOR_SERVICE));
    if (node.hasDefined(CONNECTION_FACTORY) || node.hasDefined(POOLED_CONNECTION_FACTORY)) {
        ModelNode cf = node.get(CONNECTION_FACTORY);
        ModelNode pcf = node.get(POOLED_CONNECTION_FACTORY);
        boolean hasCf = cf.isDefined() && !cf.keys().isEmpty();
        boolean hasPcf = pcf.isDefined() && !pcf.keys().isEmpty();
        if (hasCf || hasPcf) {
            writer.writeStartElement(JMS_CONNECTION_FACTORIES);
            writeConnectionFactories(writer, cf);
            writePooledConnectionFactories(writer, pcf);
            writer.writeEndElement();
            writeNewLine(writer);
        }
    }
    if (node.hasDefined(JMS_QUEUE) || node.hasDefined(JMS_TOPIC)) {
        ModelNode queue = node.get(JMS_QUEUE);
        ModelNode topic = node.get(JMS_TOPIC);
        boolean hasQueue = queue.isDefined() && !queue.keys().isEmpty();
        boolean hasTopic = topic.isDefined() && !topic.keys().isEmpty();
        if (hasQueue || hasTopic) {
            writer.writeStartElement(JMS_DESTINATIONS);
            writeJmsQueues(writer, node.get(JMS_QUEUE));
            writeTopics(writer, node.get(JMS_TOPIC));
            writer.writeEndElement();
        }
    }
    writer.writeEndElement();
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 77 with AttributeDefinition

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

the class MessagingXMLWriter method writeDiverts.

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

Example 78 with AttributeDefinition

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

the class MessagingXMLWriter method writeBridges.

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

Example 79 with AttributeDefinition

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

the class MessagingXMLWriter method writeGroupingHandler.

private static void writeGroupingHandler(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    boolean wroteHandler = false;
    for (Property handler : node.asPropertyList()) {
        if (wroteHandler) {
            throw MessagingLogger.ROOT_LOGGER.multipleChildrenFound(GROUPING_HANDLER);
        } else {
            wroteHandler = true;
        }
        writer.writeStartElement(Element.GROUPING_HANDLER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), handler.getName());
        final ModelNode resourceModel = handler.getValue();
        for (AttributeDefinition attr : GroupingHandlerDefinition.ATTRIBUTES) {
            attr.marshallAsElement(resourceModel, writer);
        }
        writer.writeEndElement();
        writeNewLine(writer);
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 80 with AttributeDefinition

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

the class PooledConnectionFactoryDefinition method define.

// the generation of the Pooled CF attributes is a bit ugly but it is with purpose:
// * factorize the attributes which are common between the regular CF and the pooled CF
// * keep in a single place the subtle differences (e.g. different default values for reconnect-attempts between
// the regular and pooled CF
// * define the attributes in the *same order than the XSD* to write them to the XML configuration by simply iterating over the array
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
    int size = common.length + specific.length;
    ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
    arraycopy(specific, 0, result, 0, specific.length);
    for (int i = 0; i < common.length; i++) {
        ConnectionFactoryAttribute attr = common[i];
        AttributeDefinition definition = attr.getDefinition();
        ConnectionFactoryAttribute newAttr;
        // replace the reconnect-attempts attribute to use a different default value for pooled CF
        if (definition == Common.RECONNECT_ATTEMPTS) {
            AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
            newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
        } else {
            AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
            newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.isInboundConfig());
        }
        result[specific.length + i] = newAttr;
    }
    return result;
}
Also used : SimpleListAttributeDefinition(org.jboss.as.controller.SimpleListAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleMapAttributeDefinition(org.jboss.as.controller.SimpleMapAttributeDefinition) PrimitiveListAttributeDefinition(org.jboss.as.controller.PrimitiveListAttributeDefinition)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)102 ModelNode (org.jboss.dmr.ModelNode)48 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)40 PathAddress (org.jboss.as.controller.PathAddress)17 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)16 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)14 OperationContext (org.jboss.as.controller.OperationContext)13 Resource (org.jboss.as.controller.registry.Resource)12 Property (org.jboss.dmr.Property)12 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)9 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)9 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)9 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 ArrayList (java.util.ArrayList)7 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)6 Map (java.util.Map)5 AbstractAddStepHandler (org.jboss.as.controller.AbstractAddStepHandler)5 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)5 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5