Java Code Examples for org.jboss.as.controller.operations.common.Util#getEmptyOperation()

The following examples show how to use org.jboss.as.controller.operations.common.Util#getEmptyOperation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        // Handle attributes
        parseNativeManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    parseNativeManagementSocket(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 2
Source File: HostXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        // Handle attributes
        parseNativeManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    parseNativeManagementSocket(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 3
Source File: MetricsRegistrationTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private ManagementResourceRegistration setupController(ProcessType processType, TestResourceDefinition resourceDefinition) throws InterruptedException {

        System.out.println("=========  New Test \n");
        container = ServiceContainer.Factory.create(TEST_METRIC);
        ServiceTarget target = container.subTarget();
        ModelControllerService svc = new ModelControllerService(processType, resourceDefinition);
        target.addService(ServiceName.of("ModelController")).setInstance(svc).install();
        svc.awaitStartup(30, TimeUnit.SECONDS);
        controller = svc.getValue();
        ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
        controller.execute(setup, null, null, null);

        client = controller.createClient(executor);

        return svc.managementControllerResource;
    }
 
Example 4
Source File: StandaloneXml_13.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {
    final ModelNode operationAddress = address.clone();
    operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
    final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

    // Handle attributes
    parseNativeManagementInterfaceAttributes(reader, addOp);

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SOCKET:
                throw ControllerLogger.ROOT_LOGGER.unsupportedElement(reader.getName(),reader.getLocation(), SOCKET_BINDING);
            case SOCKET_BINDING:
                parseNativeManagementSocketBinding(reader, addOp);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }

    list.add(addOp);
}
 
Example 5
Source File: HostXml_6.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseNativeManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, NATIVE_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        // Handle attributes
        parseNativeManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    parseNativeManagementSocket(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 6
Source File: HostXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseHttpManagementInterface(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list)  throws XMLStreamException {

        final ModelNode operationAddress = address.clone();
        operationAddress.add(MANAGEMENT_INTERFACE, HTTP_INTERFACE);
        final ModelNode addOp = Util.getEmptyOperation(ADD, operationAddress);

        // Handle attributes
        parseHttpManagementInterfaceAttributes(reader, addOp);

        // Handle elements
        while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
            requireNamespace(reader, namespace);
            final Element element = Element.forName(reader.getLocalName());
            switch (element) {
                case SOCKET:
                    parseHttpManagementSocket(reader, addOp);
                    break;
                case HTTP_UPGRADE:
                    parseHttpUpgrade(reader, addOp);
                    break;
                default:
                    throw unexpectedElement(reader);
            }
        }

        list.add(addOp);
    }
 
Example 7
Source File: DomainModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void startServers(boolean enabledAutoStart) {
    ModelNode addr = new ModelNode();
    addr.add(HOST, hostControllerInfo.getLocalHostName());
    ModelNode op = Util.getEmptyOperation(StartServersHandler.OPERATION_NAME, addr);
    op.get(ENABLE_AUTO_START).set(enabledAutoStart);

    getValue().execute(op, null, null, null);
}
 
Example 8
Source File: DomainXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseRolloutPlans(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {

        String hash = readStringAttributeElement(reader, Attribute.SHA1.getLocalName());

        ModelNode addAddress = address.clone().add(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
        ModelNode addOp = Util.getEmptyOperation(ADD, addAddress);
        try {
            addOp.get(HASH).set(HashUtil.hexStringToByteArray(hash));
        } catch (final Exception e) {
            throw ControllerLogger.ROOT_LOGGER.invalidSha1Value(e, hash, Attribute.SHA1.getLocalName(), reader.getLocation());
        }

        list.add(addOp);
    }
 
Example 9
Source File: FileSystemDeploymentService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected ModelNode getUpdate() {
    final ModelNode address = new ModelNode().add(DEPLOYMENT, deploymentName);
    final ModelNode redployOp = Util.getEmptyOperation(DeploymentRedeployHandler.OPERATION_NAME, address);
    redployOp.get(OWNER).set(resourceAddress);
    return redployOp;
}
 
Example 10
Source File: FileSystemDeploymentService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected ModelNode getUpdate() {
    final ModelNode address = new ModelNode().add(DEPLOYMENT, deploymentName);
    final ModelNode addOp = Util.getEmptyOperation(DeploymentAddHandler.OPERATION_NAME, address);
    addOp.get(CONTENT).set(createContent());
    addOp.get(PERSISTENT).set(false);
    addOp.get(OWNER).set(resourceAddress);
    final ModelNode deployOp = Util.getEmptyOperation(DeploymentDeployHandler.OPERATION_NAME, address);
    deployOp.get(OWNER).set(resourceAddress);
    return getCompositeUpdate(addOp, deployOp);
}
 
Example 11
Source File: ManagementXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseLdapAuthentication_1_4(final XMLExtendedStreamReader reader,
        final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException {
    ModelNode addr = realmAddress.clone().add(AUTHENTICATION, LDAP);
    ModelNode ldapAuthentication = Util.getEmptyOperation(ADD, addr);

    list.add(ldapAuthentication);

    parseLdapAuthenticationAttributes_1_4(reader, ldapAuthentication);

    boolean choiceFound = false;
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        if (choiceFound) {
            throw unexpectedElement(reader);
        }
        choiceFound = true;
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case ADVANCED_FILTER:
                String filter = readStringAttributeElement(reader, Attribute.FILTER.getLocalName());
                LdapAuthenticationResourceDefinition.ADVANCED_FILTER.parseAndSetParameter(filter, ldapAuthentication,
                        reader);
                break;
            case USERNAME_FILTER: {
                String usernameAttr = readStringAttributeElement(reader, Attribute.ATTRIBUTE.getLocalName());
                LdapAuthenticationResourceDefinition.USERNAME_FILTER.parseAndSetParameter(usernameAttr, ldapAuthentication,
                        reader);
                break;
            }

            default: {
                throw unexpectedElement(reader);
            }
        }
    }
    if (!choiceFound) {
        throw missingOneOf(reader, EnumSet.of(Element.ADVANCED_FILTER, Element.USERNAME_FILTER));
    }
}
 
Example 12
Source File: DomainXml_11.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void parseRolloutPlans(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {

        String hash = readStringAttributeElement(reader, Attribute.SHA1.getLocalName());

        ModelNode addAddress = address.clone().add(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
        ModelNode addOp = Util.getEmptyOperation(ADD, addAddress);
        try {
            addOp.get(HASH).set(HashUtil.hexStringToByteArray(hash));
        } catch (final Exception e) {
            throw ControllerLogger.ROOT_LOGGER.invalidSha1Value(e, hash, Attribute.SHA1.getLocalName(), reader.getLocation());
        }

        list.add(addOp);
    }
 
Example 13
Source File: DomainXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initializeRolloutPlans(ModelNode address, List<ModelNode> list) {

        ModelNode addAddress = address.clone().add(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
        ModelNode addOp = Util.getEmptyOperation(ADD, addAddress);
        list.add(addOp);
    }
 
Example 14
Source File: ManagementXml_4.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseLdapAuthorization(final XMLExtendedStreamReader reader,
        final ModelNode realmAddress, final List<ModelNode> list) throws XMLStreamException {
    ModelNode addr = realmAddress.clone().add(AUTHORIZATION, LDAP);
    ModelNode ldapAuthorization = Util.getEmptyOperation(ADD, addr);

    list.add(ldapAuthorization);

    Set<Attribute> required = EnumSet.of(Attribute.CONNECTION);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            required.remove(attribute);
            switch (attribute) {
                case CONNECTION: {
                    LdapAuthorizationResourceDefinition.CONNECTION.parseAndSetParameter(value, ldapAuthorization, reader);
                    break;
                }
                default: {
                    throw unexpectedAttribute(reader, i);
                }
            }
        }
    }

    if (required.isEmpty() == false) {
        throw missingRequired(reader, required);
    }

    Set<Element> foundElements = new HashSet<Element>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        if (foundElements.add(element) == false) {
            throw unexpectedElement(reader); // Only one of each allowed.
        }
        switch (element) {
            case USERNAME_TO_DN: {
                parseUsernameToDn(reader, addr, list);
                break;
            }
            case GROUP_SEARCH: {
                parseGroupSearch(reader, addr, list);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 15
Source File: HostXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        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));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 16
Source File: HostXml_9.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {

        // OP_ADDR will be set after parsing the NAME attribute
        final ModelNode staticDiscoveryOptionAddress = address.clone();
        staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
        final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
        list.add(addOp);

        // Handle attributes
        final Set<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.HOST, Attribute.PORT);
        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));
            required.remove(attribute);
            switch (attribute) {
                case NAME: {
                    if (!staticDiscoveryOptionNames.add(value)) {
                        throw ParseUtils.duplicateNamedElement(reader, value);
                    }
                    addOp.get(OP_ADDR).set(staticDiscoveryOptionAddress).add(STATIC_DISCOVERY, value);
                    break;
                }
                case HOST: {
                    StaticDiscoveryResourceDefinition.HOST.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PROTOCOL: {
                    StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                case PORT: {
                    StaticDiscoveryResourceDefinition.PORT.parseAndSetParameter(value, addOp, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }

        if (required.size() > 0) {
            throw missingRequired(reader, required);
        }

        requireNoContent(reader);
    }
 
Example 17
Source File: StandaloneXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parseSocketBindingGroup_1_0(final XMLExtendedStreamReader reader, final Set<String> interfaces,
                                         final ModelNode address, final List<ModelNode> updates) throws XMLStreamException {

    // unique names socket-binding(s)
    final Set<String> uniqueBindingNames = new HashSet<String>();

    ModelNode op = Util.getEmptyOperation(ADD, null);
    // Handle attributes
    String socketBindingGroupName = null;

    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.DEFAULT_INTERFACE);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch (attribute) {
            case NAME: {
                socketBindingGroupName = value;
                required.remove(attribute);
                break;
            }
            case DEFAULT_INTERFACE: {
                SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.parseAndSetParameter(value, op, reader);
                required.remove(attribute);
                if (op.get(SocketBindingGroupResourceDefinition.DEFAULT_INTERFACE.getName()).getType() != ModelType.EXPRESSION
                        && !interfaces.contains(value)) {
                    throw ControllerLogger.ROOT_LOGGER.unknownInterface(value, Attribute.DEFAULT_INTERFACE.getLocalName(), Element.INTERFACES.getLocalName(), reader.getLocation());
                }
                break;
            }
            case PORT_OFFSET: {
                SocketBindingGroupResourceDefinition.PORT_OFFSET.parseAndSetParameter(value, op, reader);
                break;
            }
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }

    if (!required.isEmpty()) {
        throw missingRequired(reader, required);
    }


    ModelNode groupAddress = address.clone().add(SOCKET_BINDING_GROUP, socketBindingGroupName);
    op.get(OP_ADDR).set(groupAddress);

    updates.add(op);

    // Handle elements
    while (reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SOCKET_BINDING: {
                // FIXME JBAS-8825
                final String bindingName = parseSocketBinding(reader, interfaces, groupAddress, updates);
                if (!uniqueBindingNames.add(bindingName)) {
                    throw ControllerLogger.ROOT_LOGGER.alreadyDeclared(Element.SOCKET_BINDING.getLocalName(), bindingName, Element.SOCKET_BINDING_GROUP.getLocalName(), socketBindingGroupName, reader.getLocation());
                }
                break;
            }
            default:
                throw unexpectedElement(reader);
        }
    }
}
 
Example 18
Source File: ManagementXml_Legacy.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void parsePropertiesAuthentication_1_0(final XMLExtendedStreamReader reader,
                                               final ModelNode realmAddress, final List<ModelNode> list)
        throws XMLStreamException {
    ModelNode addr = realmAddress.clone().add(AUTHENTICATION, PROPERTIES);
    ModelNode properties = Util.getEmptyOperation(ADD, addr);

    list.add(properties);

    String path = null;

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case PATH:
                    path = value;
                    PropertiesAuthenticationResourceDefinition.PATH.parseAndSetParameter(value, properties, reader);
                    break;
                case RELATIVE_TO: {
                    PropertiesAuthenticationResourceDefinition.RELATIVE_TO.parseAndSetParameter(value, properties, reader);
                    break;
                }
                default: {
                    throw unexpectedAttribute(reader, i);
                }
            }
        }
    }

    if (path == null)
        throw missingRequired(reader, Collections.singleton(Attribute.PATH));

    requireNoContent(reader);
    // This property was not supported in version 1.0 of the schema, however it is set to true here to ensure
    // the default behaviour if a document based on 1.0 of the schema is parsed, 1.1 now defaults this to false.
    properties.get(PLAIN_TEXT).set(true);
}
 
Example 19
Source File: DomainXml_12.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initializeRolloutPlans(ModelNode address, List<ModelNode> list) {

        ModelNode addAddress = address.clone().add(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS);
        ModelNode addOp = Util.getEmptyOperation(ADD, addAddress);
        list.add(addOp);
    }
 
Example 20
Source File: PlatformMBeanResourceUnitTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static ModelNode getOperation(final String opName, final String type, final String name) {
    return Util.getEmptyOperation(opName,  getAddress(type, name));
}