Search in sources :

Example 76 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EESubsystemParser10 method parseGlobalModules.

static ModelNode parseGlobalModules(XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode globalModules = new ModelNode();
    requireNoAttributes(reader);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(Element.forName(reader.getLocalName())) {
            case MODULE:
                {
                    final ModelNode module = new ModelNode();
                    final int count = reader.getAttributeCount();
                    String name = null;
                    String slot = null;
                    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:
                                if (name != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                name = value;
                                GlobalModulesDefinition.NAME_AD.parseAndSetParameter(name, module, reader);
                                break;
                            case SLOT:
                                if (slot != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                slot = value;
                                GlobalModulesDefinition.SLOT_AD.parseAndSetParameter(slot, module, reader);
                                break;
                            default:
                                throw unexpectedAttribute(reader, i);
                        }
                    }
                    if (name == null) {
                        throw missingRequired(reader, Collections.singleton(NAME));
                    }
                    globalModules.add(module);
                    requireNoContent(reader);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
    return globalModules;
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Example 77 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EESubsystemParser11 method parseGlobalModules.

static ModelNode parseGlobalModules(XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode globalModules = new ModelNode();
    requireNoAttributes(reader);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(Element.forName(reader.getLocalName())) {
            case MODULE:
                {
                    final ModelNode module = new ModelNode();
                    final int count = reader.getAttributeCount();
                    String name = null;
                    String slot = null;
                    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:
                                if (name != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                name = value;
                                GlobalModulesDefinition.NAME_AD.parseAndSetParameter(name, module, reader);
                                break;
                            case SLOT:
                                if (slot != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                slot = value;
                                GlobalModulesDefinition.SLOT_AD.parseAndSetParameter(slot, module, reader);
                                break;
                            default:
                                throw unexpectedAttribute(reader, i);
                        }
                    }
                    if (name == null) {
                        throw missingRequired(reader, Collections.singleton(NAME));
                    }
                    globalModules.add(module);
                    requireNoContent(reader);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
    return globalModules;
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Example 78 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EESubsystemParser12 method readElement.

/**
     * {@inheritDoc}
     */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    // EE subsystem doesn't have any attributes, so make sure that the xml doesn't have any
    requireNoAttributes(reader);
    final ModelNode eeSubSystem = Util.createAddOperation(PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM));
    // add the subsystem to the ModelNode(s)
    list.add(eeSubSystem);
    // elements
    final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(Namespace.forUri(reader.getNamespaceURI())) {
            case EE_1_2:
                {
                    final Element element = Element.forName(reader.getLocalName());
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    switch(element) {
                        case GLOBAL_MODULES:
                            {
                                final ModelNode model = parseGlobalModules(reader);
                                eeSubSystem.get(GlobalModulesDefinition.GLOBAL_MODULES).set(model);
                                break;
                            }
                        case EAR_SUBDEPLOYMENTS_ISOLATED:
                            {
                                final String earSubDeploymentsIsolated = parseEarSubDeploymentsIsolatedElement(reader);
                                // set the ear subdeployment isolation on the subsystem operation
                                EeSubsystemRootResource.EAR_SUBDEPLOYMENTS_ISOLATED.parseAndSetParameter(earSubDeploymentsIsolated, eeSubSystem, reader);
                                break;
                            }
                        case SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseSpecDescriptorPropertyReplacement(reader);
                                EeSubsystemRootResource.SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        case JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseJBossDescriptorPropertyReplacement(reader);
                                EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        case ANNOTATION_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseEJBAnnotationPropertyReplacement(reader);
                                EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        default:
                            {
                                throw unexpectedElement(reader);
                            }
                    }
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
}
Also used : ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 79 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EESubsystemParser12 method parseGlobalModules.

static ModelNode parseGlobalModules(XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode globalModules = new ModelNode();
    requireNoAttributes(reader);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(Element.forName(reader.getLocalName())) {
            case MODULE:
                {
                    final ModelNode module = new ModelNode();
                    final int count = reader.getAttributeCount();
                    String name = null;
                    String slot = null;
                    String annotations = null;
                    String metaInf = null;
                    String services = null;
                    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:
                                if (name != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                name = value;
                                GlobalModulesDefinition.NAME_AD.parseAndSetParameter(name, module, reader);
                                break;
                            case SLOT:
                                if (slot != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                slot = value;
                                GlobalModulesDefinition.SLOT_AD.parseAndSetParameter(slot, module, reader);
                                break;
                            case ANNOTATIONS:
                                if (annotations != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                annotations = value;
                                GlobalModulesDefinition.ANNOTATIONS_AD.parseAndSetParameter(annotations, module, reader);
                                break;
                            case SERVICES:
                                if (services != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                services = value;
                                GlobalModulesDefinition.SERVICES_AD.parseAndSetParameter(services, module, reader);
                                break;
                            case META_INF:
                                if (metaInf != null) {
                                    throw unexpectedAttribute(reader, i);
                                }
                                metaInf = value;
                                GlobalModulesDefinition.META_INF_AD.parseAndSetParameter(metaInf, module, reader);
                                break;
                            default:
                                throw unexpectedAttribute(reader, i);
                        }
                    }
                    if (name == null) {
                        throw missingRequired(reader, Collections.singleton(NAME));
                    }
                    globalModules.add(module);
                    requireNoContent(reader);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
    return globalModules;
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Example 80 with ModelNode

use of org.jboss.dmr.ModelNode in project wildfly by wildfly.

the class EESubsystemParser20 method readElement.

/**
     * {@inheritDoc}
     */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    // EE subsystem doesn't have any attributes, so make sure that the xml doesn't have any
    requireNoAttributes(reader);
    final PathAddress subsystemPathAddress = PathAddress.pathAddress(EeExtension.PATH_SUBSYSTEM);
    final ModelNode eeSubSystem = Util.createAddOperation(subsystemPathAddress);
    // add the subsystem to the ModelNode(s)
    list.add(eeSubSystem);
    // elements
    final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(Namespace.forUri(reader.getNamespaceURI())) {
            case EE_2_0:
            case EE_3_0:
                {
                    final Element element = Element.forName(reader.getLocalName());
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    switch(element) {
                        case GLOBAL_MODULES:
                            {
                                final ModelNode model = parseGlobalModules(reader);
                                eeSubSystem.get(GlobalModulesDefinition.GLOBAL_MODULES).set(model);
                                break;
                            }
                        case EAR_SUBDEPLOYMENTS_ISOLATED:
                            {
                                final String earSubDeploymentsIsolated = parseEarSubDeploymentsIsolatedElement(reader);
                                // set the ear subdeployment isolation on the subsystem operation
                                EeSubsystemRootResource.EAR_SUBDEPLOYMENTS_ISOLATED.parseAndSetParameter(earSubDeploymentsIsolated, eeSubSystem, reader);
                                break;
                            }
                        case SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseSpecDescriptorPropertyReplacement(reader);
                                EeSubsystemRootResource.SPEC_DESCRIPTOR_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        case JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseJBossDescriptorPropertyReplacement(reader);
                                EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        case ANNOTATION_PROPERTY_REPLACEMENT:
                            {
                                final String enabled = parseEJBAnnotationPropertyReplacement(reader);
                                EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT.parseAndSetParameter(enabled, eeSubSystem, reader);
                                break;
                            }
                        case CONCURRENT:
                            {
                                parseConcurrent(reader, list, subsystemPathAddress);
                                break;
                            }
                        case DEFAULT_BINDINGS:
                            {
                                parseDefaultBindings(reader, list, subsystemPathAddress);
                                break;
                            }
                        default:
                            {
                                throw unexpectedElement(reader);
                            }
                    }
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38