Search in sources :

Example 76 with PathAddress

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

the class WebSubsystemParser method readElement.

/**
     * {@inheritDoc}
     */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, WebExtension.SUBSYSTEM_NAME));
    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address.toModelNode());
    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 NATIVE:
                WebDefinition.NATIVE.parseAndSetParameter(value, subsystem, reader);
                break;
            case DEFAULT_VIRTUAL_SERVER:
                WebDefinition.DEFAULT_VIRTUAL_SERVER.parseAndSetParameter(value, subsystem, reader);
                break;
            case INSTANCE_ID:
                WebDefinition.INSTANCE_ID.parseAndSetParameter(value, subsystem, reader);
                break;
            case DEFAULT_SESSION_TIMEOUT:
                attributeSupportedSince(Namespace.WEB_2_2, reader, i);
                WebDefinition.DEFAULT_SESSION_TIMEOUT.parseAndSetParameter(value, subsystem, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    list.add(subsystem);
    boolean containerConfigDefined = false;
    final Namespace namespace = Namespace.forUri(reader.getNamespaceURI());
    // elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch(namespace) {
            case WEB_1_0:
            case WEB_1_1:
            case WEB_1_2:
            case WEB_1_3:
                {
                    final Element element = Element.forName(reader.getLocalName());
                    switch(element) {
                        case CONTAINER_CONFIG:
                            {
                                parseContainerConfig(reader, address, list);
                                containerConfigDefined = true;
                                break;
                            }
                        case CONNECTOR:
                            {
                                parseConnector(reader, address, list);
                                break;
                            }
                        case VIRTUAL_SERVER:
                            {
                                parseHost(reader, address, list);
                                break;
                            }
                        default:
                            {
                                throw unexpectedElement(reader);
                            }
                    }
                    break;
                }
            case WEB_1_4:
            case WEB_1_5:
            case WEB_2_0:
            case WEB_2_1:
            case WEB_2_2:
                {
                    final Element element = Element.forName(reader.getLocalName());
                    switch(element) {
                        case CONTAINER_CONFIG:
                            {
                                parseContainerConfig(reader, address, list);
                                containerConfigDefined = true;
                                break;
                            }
                        case CONNECTOR:
                            {
                                parseConnector(reader, address, list);
                                break;
                            }
                        case VIRTUAL_SERVER:
                            {
                                parseHost(reader, address, list);
                                break;
                            }
                        case VALVE:
                            {
                                parseValve(reader, address, list);
                                break;
                            }
                        default:
                            {
                                throw unexpectedElement(reader);
                            }
                    }
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
    if (!containerConfigDefined) {
        addDefaultContainerConfig(address, list);
    }
}
Also used : ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) PathAddress(org.jboss.as.controller.PathAddress) PathElement(org.jboss.as.controller.PathElement) ParseUtils.readStringAttributeElement(org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 77 with PathAddress

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

the class WebSubsystemParser method parseValve.

private static void parseValve(XMLExtendedStreamReader reader, PathAddress parent, List<ModelNode> list) throws XMLStreamException {
    String name = null;
    final ModelNode valve = new ModelNode();
    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 NAME:
                name = value;
                break;
            case MODULE:
                WebValveDefinition.MODULE.parseAndSetParameter(value, valve, reader);
                break;
            case CLASS_NAME:
                WebValveDefinition.CLASS_NAME.parseAndSetParameter(value, valve, reader);
                break;
            case ENABLED:
                WebValveDefinition.ENABLED.parseAndSetParameter(value, valve, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (name == null) {
        throw missingRequired(reader, Collections.singleton(Attribute.NAME));
    }
    valve.get(OP).set(ADD);
    PathAddress address = PathAddress.pathAddress(parent, PathElement.pathElement(VALVE, name));
    valve.get(OP_ADDR).set(address.toModelNode());
    list.add(valve);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case PARAM:
                final String[] array = requireAttributes(reader, Attribute.PARAM_NAME.getLocalName(), Attribute.PARAM_VALUE.getLocalName());
                valve.get(PARAM).get(array[0]).set(array[1]);
                requireNoContent(reader);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }
}
Also used : ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) PathAddress(org.jboss.as.controller.PathAddress) PathElement(org.jboss.as.controller.PathElement) ParseUtils.readStringAttributeElement(org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 78 with PathAddress

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

the class WebSubsystemTestCase method checkUndefinedCipherSuite.

private void checkUndefinedCipherSuite(KernelServices services, ModelVersion version) throws Exception {
    final ModelNode success = new ModelNode();
    success.get(ModelDescriptionConstants.OUTCOME).set(ModelDescriptionConstants.SUCCESS);
    success.get(ModelDescriptionConstants.RESULT);
    success.protect();
    PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()), PathElement.pathElement("connector", "https"), PathElement.pathElement("configuration", "ssl"));
    ModelNode op = Util.createOperation(WRITE_ATTRIBUTE_OPERATION, addr);
    op.get(NAME).set("cipher-suite");
    op.get(VALUE).set(new ModelNode());
    TransformedOperation transOp = services.transformOperation(version, op);
    Assert.assertTrue(transOp.rejectOperation(success));
    op.get(VALUE).set("SSL_RSA_WITH_3DES_EDE_CBC_SHA");
    transOp = services.transformOperation(version, op);
    Assert.assertFalse(transOp.rejectOperation(success));
}
Also used : TransformedOperation(org.jboss.as.controller.transform.OperationTransformer.TransformedOperation) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 79 with PathAddress

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

the class BroadcastGroupAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
        context.reloadRequired();
    } else {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String name = address.getLastElement().getValue();
        final ServiceTarget target = context.getServiceTarget();
        if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
        // nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
        } else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
            final GroupBindingService bindingService = new GroupBindingService();
            target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 80 with PathAddress

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

the class MailSessionAdd method performRuntime.

/**
     * Make any runtime changes necessary to effect the changes indicated by the given {@code operation}. E
     * <p>
     * It constructs a MailSessionService that provides mail session and registers it to Naming service.
     * </p>
     *
     * @param context             the operation context
     * @param operation           the operation being executed
     * @param model               persistent configuration model node that corresponds to the address of {@code operation}
     * @throws org.jboss.as.controller.OperationFailedException
     *          if {@code operation} is invalid or updating the runtime otherwise fails
     */
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    ModelNode fullTree = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
    installRuntimeServices(context, address, fullTree);
}
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