Search in sources :

Example 71 with AttributeDefinition

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

the class MessagingSubsystemParser method processHornetQServer.

protected void processHornetQServer(final XMLExtendedStreamReader reader, final ModelNode subsystemAddress, final List<ModelNode> list, Namespace namespace) throws XMLStreamException {
    String hqServerName = null;
    String elementName = null;
    if (namespace == Namespace.MESSAGING_1_0) {
        // We're parsing the 1.0 xsd's <subsystem> element
        requireNoAttributes(reader);
        elementName = ModelDescriptionConstants.SUBSYSTEM;
    } else {
        final int count = reader.getAttributeCount();
        if (count > 0) {
            requireSingleAttribute(reader, Attribute.NAME.getLocalName());
            hqServerName = reader.getAttributeValue(0).trim();
        }
        elementName = HORNETQ_SERVER;
    }
    if (hqServerName == null || hqServerName.length() == 0) {
        hqServerName = DEFAULT;
    }
    final ModelNode address = subsystemAddress.clone();
    address.add(HORNETQ_SERVER, hqServerName);
    address.protect();
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    operation.get(OP_ADDR).set(address);
    list.add(operation);
    EnumSet<Element> seen = EnumSet.noneOf(Element.class);
    // Handle elements
    String localName = null;
    do {
        reader.nextTag();
        localName = reader.getLocalName();
        final Element element = Element.forName(reader.getLocalName());
        if (!seen.add(element)) {
            throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
        }
        switch(element) {
            case ACCEPTORS:
                processAcceptors(reader, address, list);
                break;
            case ADDRESS_SETTINGS:
                processAddressSettings(reader, address, list);
                break;
            case BINDINGS_DIRECTORY:
                parseDirectory(reader, CommonAttributes.BINDINGS_DIRECTORY, address, list);
                break;
            case BRIDGES:
                processBridges(reader, address, list);
                break;
            case BROADCAST_GROUPS:
                processBroadcastGroups(reader, address, list);
                break;
            case CLUSTER_CONNECTIONS:
                processClusterConnections(reader, address, list);
                break;
            case CONNECTORS:
                processConnectors(reader, address, list);
                break;
            case CONNECTOR_SERVICES:
                processConnectorServices(reader, address, list);
                break;
            case DISCOVERY_GROUPS:
                processDiscoveryGroups(reader, address, list);
                break;
            case DIVERTS:
                parseDiverts(reader, address, list);
                break;
            case FILE_DEPLOYMENT_ENABLED:
                // This isn't an element in the xsd as there is no filesystem support in AS
                unhandledElement(reader, element);
                break;
            case GROUPING_HANDLER:
                processGroupingHandler(reader, address, list);
                break;
            case JOURNAL_DIRECTORY:
                parseDirectory(reader, CommonAttributes.JOURNAL_DIRECTORY, address, list);
                break;
            case LARGE_MESSAGES_DIRECTORY:
                parseDirectory(reader, CommonAttributes.LARGE_MESSAGES_DIRECTORY, address, list);
                break;
            case LIVE_CONNECTOR_REF:
                {
                    MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
                    skipElementText(reader);
                    break;
                }
            case PAGING_DIRECTORY:
                parseDirectory(reader, CommonAttributes.PAGING_DIRECTORY, address, list);
                break;
            case REMOTING_INTERCEPTORS:
                processRemotingInterceptors(reader, operation);
                break;
            case SECURITY_DOMAIN:
                handleElementText(reader, element, null, operation);
                break;
            case SECURITY_SETTINGS:
                {
                    // process security settings
                    processSecuritySettings(reader, address, list);
                    break;
                }
            case CORE_QUEUES:
                {
                    parseQueues(reader, address, list);
                    break;
                }
            case CONNECTION_FACTORIES:
                {
                    processConnectionFactories(reader, address, list);
                    break;
                }
            case JMS_DESTINATIONS:
                {
                    processJmsDestinations(reader, address, list);
                    break;
                }
            case SCHEDULED_THREAD_POOL_MAX_SIZE:
            case THREAD_POOL_MAX_SIZE:
                {
                    // Use the "server" variant
                    handleElementText(reader, element, "server", operation);
                    break;
                }
            case MESSAGE_COUNTER_ENABLED:
                {
                    MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString(), Element.STATISTICS_ENABLED.toString());
                    handleElementText(reader, element, operation);
                    break;
                }
            case HORNETQ_SERVER:
                // The end of the hornetq-server element
                if (namespace == Namespace.MESSAGING_1_0) {
                    throw unexpectedEndElement(reader);
                }
                break;
            case SUBSYSTEM:
                // The end of the subsystem element
                if (namespace != Namespace.MESSAGING_1_0) {
                    throw unexpectedEndElement(reader);
                }
                break;
            case CLUSTERED:
                // log that the attribute is deprecated but handle it anyway
                MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
            default:
                if (SIMPLE_ROOT_RESOURCE_ELEMENTS.contains(element)) {
                    AttributeDefinition attributeDefinition = element.getDefinition();
                    if (attributeDefinition instanceof SimpleAttributeDefinition) {
                        handleElementText(reader, element, operation);
                    } else {
                        // These should be handled in specific case blocks above, e.g. case REMOTING_INTERCEPTORS:
                        handleComplexConfigurationAttribute(reader, element, operation);
                    }
                } else {
                    handleUnknownConfigurationAttribute(reader, element, operation);
                }
        }
    } while (reader.hasNext() && localName.equals(elementName) == false);
}
Also used : ParseUtils.readStringAttributeElement(org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ParseUtils.unexpectedEndElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedEndElement) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ListAttributeDefinition(org.jboss.as.controller.ListAttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 72 with AttributeDefinition

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

the class HornetQServerResourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    OperationStepHandler writeHandler = new ModelOnlyWriteAttributeHandler(CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES);
    for (AttributeDefinition ad : CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES) {
        if (ad.getName().equals(CLUSTERED.getName())) {
            resourceRegistration.registerReadWriteAttribute(CLUSTERED, ClusteredAttributeHandlers.READ_HANDLER, ClusteredAttributeHandlers.WRITE_HANDLER);
        } else if (ad.getName().equals(MESSAGE_COUNTER_ENABLED.getName())) {
            MessageCounterEnabledHandler handler = new MessageCounterEnabledHandler();
            resourceRegistration.registerReadWriteAttribute(MESSAGE_COUNTER_ENABLED, handler, handler);
        } else {
            resourceRegistration.registerReadWriteAttribute(ad, null, writeHandler);
        }
    }
    // handle deprecate attributes
    resourceRegistration.registerReadWriteAttribute(CommonAttributes.LIVE_CONNECTOR_REF, null, DeprecatedAttributeWriteHandler.INSTANCE);
}
Also used : ModelOnlyWriteAttributeHandler(org.jboss.as.controller.ModelOnlyWriteAttributeHandler) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) AttributeDefinition(org.jboss.as.controller.AttributeDefinition)

Example 73 with AttributeDefinition

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

the class MessagingXMLWriter method writeClusterConnections.

private static void writeClusterConnections(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.CLUSTER_CONNECTIONS.getLocalName());
        for (final Property property : node.asPropertyList()) {
            writer.writeStartElement(Element.CLUSTER_CONNECTION.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            final ModelNode cluster = property.getValue();
            for (AttributeDefinition attribute : ClusterConnectionDefinition.ATTRIBUTES) {
                if (attribute == ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY) {
                    // we nest it in static-connectors
                    continue;
                }
                if (attribute == CONNECTOR_REFS) {
                    if (attribute.isMarshallable(cluster)) {
                        writer.writeStartElement(Element.STATIC_CONNECTORS.getLocalName());
                        ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
                        CONNECTOR_REFS.marshallAsElement(cluster, writer);
                        writer.writeEndElement();
                    } else if (ALLOW_DIRECT_CONNECTIONS_ONLY.isMarshallable(cluster)) {
                        writer.writeEmptyElement(Element.STATIC_CONNECTORS.getLocalName());
                        ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
                    }
                } else {
                    attribute.marshallAsElement(property.getValue(), writer);
                }
            }
            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 74 with AttributeDefinition

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

the class MessagingXMLWriter method writeJmsQueues.

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

Example 75 with AttributeDefinition

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

the class MessagingXMLWriter method writeDiscoveryGroups.

private static void writeDiscoveryGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined()) {
        return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
        writer.writeStartElement(Element.DISCOVERY_GROUPS.getLocalName());
        for (final Property property : properties) {
            writer.writeStartElement(Element.DISCOVERY_GROUP.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
            for (AttributeDefinition attribute : DiscoveryGroupDefinition.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)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