Search in sources :

Example 1 with SimpleAttributeDefinition

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

the class CmpSubsystem10Parser method parseHilo.

protected ModelNode parseHilo(final XMLExtendedStreamReader reader, final PathAddress parentAddress) throws XMLStreamException {
    String name = null;
    int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case NAME:
                {
                    name = value;
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw missingRequired(reader, Collections.singleton(Attribute.NAME));
    }
    final ModelNode op = Util.createAddOperation(parentAddress.append(HILO_KEY_GENERATOR, name));
    final EnumSet<Element> required = EnumSet.of(Element.DATA_SOURCE, Element.TABLE_NAME, Element.ID_COLUMN, Element.SEQUENCE_COLUMN, Element.SEQUENCE_NAME);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String value = reader.getElementText();
        final String tag = reader.getLocalName();
        final Element element = Element.forName(tag);
        required.remove(element);
        SimpleAttributeDefinition attribute = HiLoKeyGeneratorResourceDefinition.ATTRIBUTE_MAP.get(tag);
        if (attribute == null) {
            throw unexpectedElement(reader);
        }
        attribute.parseAndSetParameter(value, op, reader);
    }
    if (!required.isEmpty()) {
        throw missingRequiredElement(reader, required);
    }
    return op;
}
Also used : ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.missingRequiredElement(org.jboss.as.controller.parsing.ParseUtils.missingRequiredElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with SimpleAttributeDefinition

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

the class ModClusterSubsystemXMLReader_1_2 method parsePropConf.

void parsePropConf(XMLExtendedStreamReader reader, ModelNode conf) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ADVERTISE_SOCKET:
            case PROXY_URL:
            case ADVERTISE:
            case ADVERTISE_SECURITY_KEY:
            case EXCLUDED_CONTEXTS:
            case AUTO_ENABLE_CONTEXTS:
            case STOP_CONTEXT_TIMEOUT:
            case SOCKET_TIMEOUT:
            case STICKY_SESSION:
            case STICKY_SESSION_REMOVE:
            case STICKY_SESSION_FORCE:
            case WORKER_TIMEOUT:
            case MAX_ATTEMPTS:
            case FLUSH_PACKETS:
            case FLUSH_WAIT:
            case PING:
            case SMAX:
            case TTL:
            case NODE_TIMEOUT:
            case BALANCER:
            case LOAD_BALANCING_GROUP:
            case CONNECTOR:
            case SESSION_DRAINING_STRATEGY:
                ((SimpleAttributeDefinition) ModClusterConfigResourceDefinition.ATTRIBUTES_BY_NAME.get(attribute.getLocalName())).parseAndSetParameter(value, conf, reader);
                break;
            case PROXY_LIST:
                // Keep deprecated PROXY_LIST to be able to support EAP 6.x slaves
                ModClusterConfigResourceDefinition.PROXY_LIST.parseAndSetParameter(value, conf, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Example 3 with SimpleAttributeDefinition

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

the class ModClusterSubsystemXMLReader_2_0 method parsePropConf.

void parsePropConf(XMLExtendedStreamReader reader, ModelNode conf) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ADVERTISE_SOCKET:
            case PROXY_URL:
            case ADVERTISE:
            case ADVERTISE_SECURITY_KEY:
            case EXCLUDED_CONTEXTS:
            case AUTO_ENABLE_CONTEXTS:
            case STOP_CONTEXT_TIMEOUT:
            case SOCKET_TIMEOUT:
            case STICKY_SESSION:
            case STICKY_SESSION_REMOVE:
            case STICKY_SESSION_FORCE:
            case WORKER_TIMEOUT:
            case MAX_ATTEMPTS:
            case FLUSH_PACKETS:
            case FLUSH_WAIT:
            case PING:
            case SMAX:
            case TTL:
            case NODE_TIMEOUT:
            case BALANCER:
            case LOAD_BALANCING_GROUP:
            case CONNECTOR:
            case STATUS_INTERVAL:
            case SESSION_DRAINING_STRATEGY:
                ((SimpleAttributeDefinition) ModClusterConfigResourceDefinition.ATTRIBUTES_BY_NAME.get(attribute.getLocalName())).parseAndSetParameter(value, conf, reader);
                break;
            case PROXIES:
                ModClusterConfigResourceDefinition.PROXIES.getParser().parseAndSetParameter(ModClusterConfigResourceDefinition.PROXIES, value, conf, reader);
                break;
            case PROXY_LIST:
                // Keep deprecated PROXY_LIST to be able to support EAP 6.x slaves
                ModClusterConfigResourceDefinition.PROXY_LIST.parseAndSetParameter(value, conf, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Example 4 with SimpleAttributeDefinition

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

the class ModClusterSubsystemXMLWriter method writeSSL.

static void writeSSL(XMLExtendedStreamWriter writer, ModelNode sslConfig) throws XMLStreamException {
    writer.writeStartElement(Element.SSL.getLocalName());
    for (SimpleAttributeDefinition def : ModClusterSSLResourceDefinition.ATTRIBUTES) {
        def.marshallAsAttribute(sslConfig, false, writer);
    }
    writer.writeEndElement();
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Example 5 with SimpleAttributeDefinition

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

the class ModClusterSubsystemXMLReader_1_1 method parsePropConf.

void parsePropConf(XMLExtendedStreamReader reader, ModelNode conf) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ADVERTISE_SOCKET:
            case PROXY_URL:
            case ADVERTISE:
            case ADVERTISE_SECURITY_KEY:
            case EXCLUDED_CONTEXTS:
            case AUTO_ENABLE_CONTEXTS:
            case STOP_CONTEXT_TIMEOUT:
            case SOCKET_TIMEOUT:
            case STICKY_SESSION:
            case STICKY_SESSION_REMOVE:
            case STICKY_SESSION_FORCE:
            case WORKER_TIMEOUT:
            case MAX_ATTEMPTS:
            case FLUSH_PACKETS:
            case FLUSH_WAIT:
            case PING:
            case SMAX:
            case TTL:
            case NODE_TIMEOUT:
            case BALANCER:
            case LOAD_BALANCING_GROUP:
            case CONNECTOR:
                ((SimpleAttributeDefinition) ModClusterConfigResourceDefinition.ATTRIBUTES_BY_NAME.get(attribute.getLocalName())).parseAndSetParameter(value, conf, reader);
                break;
            case PROXY_LIST:
                // Keep deprecated PROXY_LIST to be able to support EAP 6.x slaves
                ModClusterConfigResourceDefinition.PROXY_LIST.parseAndSetParameter(value, conf, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition)

Aggregations

SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)89 ModelNode (org.jboss.dmr.ModelNode)47 PathAddress (org.jboss.as.controller.PathAddress)14 Property (org.jboss.dmr.Property)13 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)9 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)9 HashSet (java.util.HashSet)8 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)8 XMLStreamException (javax.xml.stream.XMLStreamException)7 OperationContext (org.jboss.as.controller.OperationContext)4 ArrayList (java.util.ArrayList)3 AbstractAttributeDefinitionBuilder (org.jboss.as.controller.AbstractAttributeDefinitionBuilder)3 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)3 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)3 SimpleListAttributeDefinition (org.jboss.as.controller.SimpleListAttributeDefinition)3 SimpleMapAttributeDefinition (org.jboss.as.controller.SimpleMapAttributeDefinition)3 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)3 ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)2 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)2