Search in sources :

Example 81 with ModelNode

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

the class EESubsystemParser20 method parseManagedThreadFactory.

static void parseManagedThreadFactory(XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress subsystemPathAddress) throws XMLStreamException {
    final ModelNode addOperation = Util.createAddOperation();
    final int count = reader.getAttributeCount();
    String name = null;
    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.JNDI_NAME);
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch(attribute) {
            case NAME:
                name = value.trim();
                break;
            case JNDI_NAME:
                ManagedThreadFactoryResourceDefinition.JNDI_NAME_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case CONTEXT_SERVICE:
                ManagedThreadFactoryResourceDefinition.CONTEXT_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case PRIORITY:
                ManagedThreadFactoryResourceDefinition.PRIORITY_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (!required.isEmpty()) {
        throw missingRequired(reader, required);
    }
    requireNoContent(reader);
    final PathAddress address = subsystemPathAddress.append(EESubsystemModel.MANAGED_THREAD_FACTORY, name);
    addOperation.get(OP_ADDR).set(address.toModelNode());
    operations.add(addOperation);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 82 with ModelNode

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

the class EESubsystemParser20 method parseDefaultBindings.

static void parseDefaultBindings(XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress subsystemPathAddress) throws XMLStreamException {
    final ModelNode addOperation = Util.createAddOperation();
    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 CONTEXT_SERVICE:
                DefaultBindingsResourceDefinition.CONTEXT_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case DATASOURCE:
                DefaultBindingsResourceDefinition.DATASOURCE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case JMS_CONNECTION_FACTORY:
                DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_EXECUTOR_SERVICE:
                DefaultBindingsResourceDefinition.MANAGED_EXECUTOR_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_SCHEDULED_EXECUTOR_SERVICE:
                DefaultBindingsResourceDefinition.MANAGED_SCHEDULED_EXECUTOR_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_THREAD_FACTORY:
                DefaultBindingsResourceDefinition.MANAGED_THREAD_FACTORY_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    requireNoContent(reader);
    final PathAddress address = subsystemPathAddress.append(EESubsystemModel.DEFAULT_BINDINGS_PATH);
    addOperation.get(OP_ADDR).set(address.toModelNode());
    operations.add(addOperation);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 83 with ModelNode

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

the class EESubsystemParser40 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_4_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) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 84 with ModelNode

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

the class EESubsystemParser40 method parseDefaultBindings.

static void parseDefaultBindings(XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress subsystemPathAddress) throws XMLStreamException {
    final ModelNode addOperation = Util.createAddOperation();
    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 CONTEXT_SERVICE:
                DefaultBindingsResourceDefinition.CONTEXT_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case DATASOURCE:
                DefaultBindingsResourceDefinition.DATASOURCE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case JMS_CONNECTION_FACTORY:
                DefaultBindingsResourceDefinition.JMS_CONNECTION_FACTORY_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_EXECUTOR_SERVICE:
                DefaultBindingsResourceDefinition.MANAGED_EXECUTOR_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_SCHEDULED_EXECUTOR_SERVICE:
                DefaultBindingsResourceDefinition.MANAGED_SCHEDULED_EXECUTOR_SERVICE_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            case MANAGED_THREAD_FACTORY:
                DefaultBindingsResourceDefinition.MANAGED_THREAD_FACTORY_AD.parseAndSetParameter(value, addOperation, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    requireNoContent(reader);
    final PathAddress address = subsystemPathAddress.append(EESubsystemModel.DEFAULT_BINDINGS_PATH);
    addOperation.get(OP_ADDR).set(address.toModelNode());
    operations.add(addOperation);
}
Also used : ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 85 with ModelNode

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

the class EJB3Subsystem50Parser method parseIdentity.

private void parseIdentity(final XMLExtendedStreamReader reader, final List<ModelNode> operations) throws XMLStreamException {
    final PathAddress address = this.getEJB3SubsystemAddress().append(SERVICE, IDENTITY);
    ModelNode addIdentity = Util.createAddOperation(address);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case OUTFLOW_SECURITY_DOMAINS:
                {
                    for (String outflowDomain : reader.getListAttributeValue(i)) {
                        IdentityResourceDefinition.OUTFLOW_SECURITY_DOMAINS.parseAndAddParameterElement(outflowDomain, addIdentity, reader);
                    }
                    break;
                }
            default:
                {
                    throw unexpectedAttribute(reader, i);
                }
        }
    }
    requireNoContent(reader);
    operations.add(addIdentity);
}
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