Search in sources :

Example 91 with PathAddress

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

the class TransportConfigurationBuilder method configure.

@Override
public Builder<TransportConfiguration<T>> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.socketBinding = new InjectedValueDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, SOCKET_BINDING.resolveModelAttribute(context, model).asString()), SocketBinding.class);
    this.diagnosticsSocketBinding = ModelNodes.optionalString(DIAGNOSTICS_SOCKET_BINDING.resolveModelAttribute(context, model)).map(diagnosticsBinding -> new InjectedValueDependency<>(CommonUnaryRequirement.SOCKET_BINDING.getServiceName(context, diagnosticsBinding), SocketBinding.class)).orElse(null);
    Optional<String> machine = ModelNodes.optionalString(MACHINE.resolveModelAttribute(context, model));
    Optional<String> rack = ModelNodes.optionalString(RACK.resolveModelAttribute(context, model));
    Optional<String> site = ModelNodes.optionalString(SITE.resolveModelAttribute(context, model));
    if (site.isPresent() || rack.isPresent() || machine.isPresent()) {
        this.topology = new Topology() {

            @Override
            public String getMachine() {
                return machine.orElse(null);
            }

            @Override
            public String getRack() {
                return rack.orElse(null);
            }

            @Override
            public String getSite() {
                return site.orElse(null);
            }
        };
    }
    PathAddress address = context.getCurrentAddress();
    EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.TIMER)).forEach(pool -> this.threadPoolFactories.put(pool, new InjectedValueDependency<>(new ThreadPoolServiceNameProvider(address, pool.getPathElement()), ThreadPoolFactory.class)));
    this.timerFactory = new InjectedValueDependency<>(new ThreadPoolServiceNameProvider(address, ThreadPoolResourceDefinition.TIMER.getPathElement()), TimerFactory.class);
    return super.configure(context, model);
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) PathAddress(org.jboss.as.controller.PathAddress)

Example 92 with PathAddress

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

the class JGroupsSubsystemXMLReader method parseRelay.

private void parseRelay(XMLExtendedStreamReader reader, PathAddress stackAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
    PathAddress address = stackAddress.append(RelayResourceDefinition.PATH);
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case SITE:
                {
                    readAttribute(reader, i, operation, RelayResourceDefinition.Attribute.SITE);
                    break;
                }
            default:
                {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    if (!operation.hasDefined(RelayResourceDefinition.Attribute.SITE.getName())) {
        throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.SITE));
    }
    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
        XMLElement element = XMLElement.forName(reader.getLocalName());
        switch(element) {
            case REMOTE_SITE:
                {
                    this.parseRemoteSite(reader, address, operations);
                    break;
                }
            case PROPERTY:
                {
                    this.parseProperty(reader, address, operations);
                    break;
                }
            default:
                {
                    throw ParseUtils.unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 93 with PathAddress

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

the class JGroupsSubsystemXMLReader method parseChannel.

private void parseChannel(XMLExtendedStreamReader reader, PathAddress subsystemAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
    String name = require(reader, XMLAttribute.NAME);
    PathAddress address = subsystemAddress.append(ChannelResourceDefinition.pathElement(name));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        ParseUtils.requireNoNamespaceAttribute(reader, i);
        XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case NAME:
                {
                    // Already parsed
                    break;
                }
            case STACK:
                {
                    readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.STACK);
                    break;
                }
            case MODULE:
                {
                    readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.MODULE);
                    break;
                }
            case CLUSTER:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_4_0)) {
                        readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.CLUSTER);
                        break;
                    }
                }
            case STATISTICS_ENABLED:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_4_1)) {
                        readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.STATISTICS_ENABLED);
                        break;
                    }
                }
            default:
                {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
        XMLElement element = XMLElement.forName(reader.getLocalName());
        switch(element) {
            case FORK:
                {
                    this.parseFork(reader, address, operations);
                    break;
                }
            default:
                {
                    throw ParseUtils.unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 94 with PathAddress

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

the class JGroupsSubsystemXMLReader method parseSocketProtocol.

private void parseSocketProtocol(XMLExtendedStreamReader reader, PathAddress stackAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
    String type = require(reader, XMLAttribute.TYPE);
    PathAddress address = stackAddress.append(ProtocolResourceDefinition.pathElement(type));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        this.parseSocketProtocolAttribute(reader, i, operation);
    }
    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
        this.parseProtocolElement(reader, address, operations);
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 95 with PathAddress

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

the class JGroupsSubsystemXMLReader method parseStack.

private void parseStack(XMLExtendedStreamReader reader, PathAddress subsystemAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
    String name = require(reader, XMLAttribute.NAME);
    PathAddress address = subsystemAddress.append(StackResourceDefinition.pathElement(name));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);
    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
        XMLElement element = XMLElement.forName(reader.getLocalName());
        switch(element) {
            case TRANSPORT:
                {
                    this.parseTransport(reader, address, operations);
                    break;
                }
            case PROTOCOL:
                {
                    this.parseProtocol(reader, address, operations);
                    break;
                }
            case RELAY:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_2_0)) {
                        this.parseRelay(reader, address, operations);
                        break;
                    }
                }
            case SOCKET_PROTOCOL:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_4_1)) {
                        this.parseSocketProtocol(reader, address, operations);
                        break;
                    }
                }
            case JDBC_PROTOCOL:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_4_1)) {
                        this.parseJDBCProtocol(reader, address, operations);
                        break;
                    }
                }
            case ENCRYPT_PROTOCOL:
                {
                    if (this.schema.since(JGroupsSchema.VERSION_4_1)) {
                        this.parseEncryptProtocol(reader, address, operations);
                        break;
                    }
                }
            default:
                {
                    throw ParseUtils.unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)473 ModelNode (org.jboss.dmr.ModelNode)345 PathElement (org.jboss.as.controller.PathElement)54 Resource (org.jboss.as.controller.registry.Resource)53 ServiceName (org.jboss.msc.service.ServiceName)53 OperationFailedException (org.jboss.as.controller.OperationFailedException)48 Test (org.junit.Test)36 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 OperationContext (org.jboss.as.controller.OperationContext)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)25 KernelServices (org.jboss.as.subsystem.test.KernelServices)24 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)23 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)23 Map (java.util.Map)22 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)19 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)19 ArrayList (java.util.ArrayList)18 TransformationContext (org.jboss.as.controller.transform.TransformationContext)17 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)15