Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamReader#getLocalName()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamReader#getLocalName() . 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: PatchBundleXml_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(final XMLExtendedStreamReader reader, final PatchXml.Result<BundledPatch> result) throws XMLStreamException {

    final List<BundledPatch.BundledPatchEntry> patches = new ArrayList<BundledPatch.BundledPatchEntry>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String localName = reader.getLocalName();
        final Element element = Element.forName(localName);
        switch (element) {
            case PATCH_ELEMENT:
                parseElement(reader, patches);
                break;
            default:
                throw unexpectedElement(reader);
        }
    }
    result.setResult(new BundledPatch() {
        @Override
        public List<BundledPatchEntry> getPatches() {
            return patches;
        }
    });
}
 
Example 2
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes
    ParseUtils.requireNoAttributes(reader);
    ModelNode addKeycloakSub = Util.createAddOperation(PathAddress.pathAddress(PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(WEB_CONTEXT.getXmlName())) {
            WEB_CONTEXT.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(PROVIDERS.getXmlName())) {
            readProviders(reader, addKeycloakSub);
        } else if (reader.getLocalName().equals(MASTER_REALM_NAME.getXmlName())) {
            MASTER_REALM_NAME.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(SCHEDULED_TASK_INTERVAL.getXmlName())) {
            SCHEDULED_TASK_INTERVAL.parseAndSetParameter(reader.getElementText(), addKeycloakSub, reader);
        } else if (reader.getLocalName().equals(ThemeResourceDefinition.TAG_NAME)) {
            readTheme(list, reader);
        } else if (reader.getLocalName().equals(SpiResourceDefinition.TAG_NAME)) {
            readSpi(list, reader);
        } else {
            throw new XMLStreamException("Unknown keycloak-server subsystem tag: " + reader.getLocalName());
        }
    }
}
 
Example 3
Source File: GmlcSubsystemParser.java    From gmlc with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
  PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, GmlcExtension.SUBSYSTEM_NAME));

  final ModelNode subsystem = new ModelNode();
  subsystem.get(OP).set(ADD);
  subsystem.get(OP_ADDR).set(address.toModelNode());
  list.add(subsystem);

  // mbean elements
  while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
    switch (Namespace.forUri(reader.getNamespaceURI())) {
      case SMPPEXT_1_0: {
        final String tagName = reader.getLocalName();
        if (tagName.equals(GmlcMbeanDefinition.MBEAN)) {
          parseMbean(reader, address, list);
        }
        break;
      }
      default: {
        throw unexpectedElement(reader);
      }
    }
  }
}
 
Example 4
Source File: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void readHistory(XMLExtendedStreamReader reader, Namespace expectedNs, CliConfigImpl config) throws XMLStreamException {
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        assertExpectedNamespace(reader, expectedNs);
        final String localName = reader.getLocalName();
        final String resolved = resolveString(reader.getElementText());
        if (ENABLED.equals(localName)) {
            config.historyEnabled = Boolean.parseBoolean(resolved);
        } else if (FILE_NAME.equals(localName)) {
            config.historyFileName = resolved;
        } else if (FILE_DIR.equals(localName)) {
            config.historyFileDir = resolved;
        } else if (MAX_SIZE.equals(localName)) {
            try {
                config.historyMaxSize = Integer.parseInt(resolved);
            } catch(NumberFormatException e) {
                throw new XMLStreamException("Failed to parse " + HISTORY + " " + MAX_SIZE + " value '" + resolved + "'", e);
            }
        } else {
            throw new XMLStreamException("Unexpected child of " + DEFAULT_CONTROLLER + ": " + localName);
        }
    }
}
 
Example 5
Source File: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void readSSLElement_1_0(XMLExtendedStreamReader reader, Namespace expectedNs, SslConfig config) throws XMLStreamException {
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        assertExpectedNamespace(reader, expectedNs);
        final String localName = reader.getLocalName();
        if ("keyStore".equals(localName)) {
            config.setKeyStore(reader.getElementText());
        } else if ("keyStorePassword".equals(localName)) {
            config.setKeyStorePassword(reader.getElementText());
        } else if ("trustStore".equals(localName)) {
            config.setTrustStore(reader.getElementText());
        } else if ("trustStorePassword".equals(localName)) {
            config.setTrustStorePassword(reader.getElementText());
        } else if ("modifyTrustStore".equals(localName)) {
            config.setModifyTrustStore(resolveBoolean(reader.getElementText()));
        } else {
            throw new XMLStreamException("Unexpected child of ssl : " + localName);
        }
    }
}
 
Example 6
Source File: VaultConfig.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, VaultConfig config) throws XMLStreamException {

    String rootName = reader.getLocalName();
    if (VAULT.equals(rootName) == false) {
        throw new XMLStreamException("Unexpected element: " + rootName);
    }

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        unexpectedVaultAttribute(reader.getAttributeLocalName(i), reader);
    }
    if (config.code == null && config.module != null){
        throw new XMLStreamException("Attribute 'module' was specified without an attribute"
                + " 'code' for element '" + VAULT + "' at " + reader.getLocation());
    }
    readVaultOptions(reader, config);
}
 
Example 7
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void readRoleIdentifiers(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();

        if (!Constants.XML.ATTRIBUTE.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }

        ParseUtils.requireSingleAttribute(reader, Constants.XML.NAME);
        String name = ParseUtils.readStringAttributeElement(reader, Constants.XML.NAME);

        ServiceProviderDefinition.ROLE_ATTRIBUTES.parseAndAddParameterElement(name, addServiceProvider, reader);
    }
}
 
Example 8
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void readSecureResource(String tagName, AbstractAdapterConfigurationDefinition resource, XMLExtendedStreamReader reader, List<ModelNode> resourcesToAdd) throws XMLStreamException {
    String name = readNameAttribute(reader);
    ModelNode addSecureDeployment = new ModelNode();
    addSecureDeployment.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, KeycloakExtension.SUBSYSTEM_NAME),
            PathElement.pathElement(tagName, name));
    addSecureDeployment.get(ModelDescriptionConstants.OP_ADDR).set(addr.toModelNode());
    List<ModelNode> credentialsToAdd = new ArrayList<ModelNode>();
    List<ModelNode> redirectRulesToAdd = new ArrayList<ModelNode>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String localName = reader.getLocalName();
        if (localName.equals(CredentialDefinition.TAG_NAME)) {
            readCredential(reader, addr, credentialsToAdd);
            continue;
        }
        if (localName.equals(RedirecRewritetRuleDefinition.TAG_NAME)) {
            readRewriteRule(reader, addr, redirectRulesToAdd);
            continue;
        }

        SimpleAttributeDefinition def = resource.lookup(localName);
        if (def == null) throw new XMLStreamException("Unknown secure-deployment tag " + localName);
        def.parseAndSetParameter(reader.getElementText(), addSecureDeployment, reader);
    }

    // Must add credentials after the deployment is added.
    resourcesToAdd.add(addSecureDeployment);
    resourcesToAdd.addAll(credentialsToAdd);
    resourcesToAdd.addAll(redirectRulesToAdd);
}
 
Example 9
Source File: DeploymentScannerParser_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    // no attributes
    requireNoAttributes(reader);

    final ModelNode address = new ModelNode();
    address.add(ModelDescriptionConstants.SUBSYSTEM, DeploymentScannerExtension.SUBSYSTEM_NAME);
    address.protect();

    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address);
    list.add(subsystem);

    // elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch (Namespace.forUri(reader.getNamespaceURI())) {
            case DEPLOYMENT_SCANNER_1_0: {
                final String element = reader.getLocalName();
                switch (element) {
                    case CommonAttributes.DEPLOYMENT_SCANNER: {
                        //noinspection unchecked
                        parseScanner(reader, address, list);
                        break;
                    }
                    default: throw unexpectedElement(reader);
                }
                break;
            }
            default: throw unexpectedElement(reader);
        }
    }
}
 
Example 10
Source File: DeploymentScannerParser_1_1.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    // no attributes
    requireNoAttributes(reader);

    final ModelNode address = new ModelNode();
    address.add(ModelDescriptionConstants.SUBSYSTEM, DeploymentScannerExtension.SUBSYSTEM_NAME);
    address.protect();

    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address);
    list.add(subsystem);

    // elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch (Namespace.forUri(reader.getNamespaceURI())) {
            case DEPLOYMENT_SCANNER_1_0:
            case DEPLOYMENT_SCANNER_1_1: {
                final String element = reader.getLocalName();
                switch (element) {
                    case DEPLOYMENT_SCANNER: {
                        //noinspection unchecked
                        parseScanner(reader, address, list);
                        break;
                    }
                    default:
                        throw unexpectedElement(reader);
                }
                break;
            }
            default:
                throw unexpectedElement(reader);
        }
    }
}
 
Example 11
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readRoleMappingsProvider(final ModelNode addServiceProvider, final XMLExtendedStreamReader reader) throws XMLStreamException {
    String providerId = readRequiredAttribute(reader, Constants.XML.ID);
    ServiceProviderDefinition.ROLE_MAPPINGS_PROVIDER_ID.parseAndSetParameter(providerId, addServiceProvider, reader);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (!Constants.XML.PROPERTY.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }
        final String[] array = ParseUtils.requireAttributes(reader, Constants.XML.NAME, Constants.XML.VALUE);
        ServiceProviderDefinition.ROLE_MAPPINGS_PROVIDER_CONFIG.parseAndAddParameterElement(array[0], array[1], addServiceProvider, reader);
        ParseUtils.requireNoContent(reader);
    }
}
 
Example 12
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readKeyStore(ModelNode addKey, XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode addKeyStore = addKey.get(Constants.Model.KEY_STORE);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        SimpleAttributeDefinition attr = KeyStoreDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, addKeyStore, reader);
    }

    if (!addKeyStore.hasDefined(Constants.Model.FILE) && !addKeyStore.hasDefined(Constants.Model.RESOURCE)) {
        throw new XMLStreamException("KeyStore element must have 'file' or 'resource' attribute set", reader.getLocation());
    }
    if (!addKeyStore.hasDefined(Constants.Model.PASSWORD)) {
        throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PASSWORD));
    }

    Set<String> parsedElements = new HashSet<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (parsedElements.contains(tagName)) {
            // all sub-elements of the keystore type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }
        if (Constants.XML.PRIVATE_KEY.equals(tagName)) {
            readPrivateKey(reader, addKeyStore);
        } else if (Constants.XML.CERTIFICATE.equals(tagName)) {
            readCertificate(reader, addKeyStore);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
 
Example 13
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readKey(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddr) throws XMLStreamException {
    PathAddress addr = PathAddress.pathAddress(parentAddr,
            PathElement.pathElement(Constants.Model.KEY, "key-" + list.size()));
    ModelNode addKey = Util.createAddOperation(addr);
    list.add(addKey);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        SimpleAttributeDefinition attr = KeyDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, addKey, reader);
    }

    Set<String> parsedElements = new HashSet<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (parsedElements.contains(tagName)) {
            // all sub-elements of the key type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }

        if (Constants.XML.KEY_STORE.equals(tagName)) {
            readKeyStore(addKey, reader);
        } else if (Constants.XML.PRIVATE_KEY_PEM.equals(tagName)
                || Constants.XML.PUBLIC_KEY_PEM.equals(tagName)
                || Constants.XML.CERTIFICATE_PEM.equals(tagName)) {

            readNoAttrElementContent(KeyDefinition.lookupElement(tagName), addKey, reader);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
 
Example 14
Source File: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private ControllerAddress readController(boolean allowProtocol, XMLExtendedStreamReader reader, Namespace expectedNs) throws XMLStreamException {
    String protocol = null;
    String host = null;
    int port = -1;

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        assertExpectedNamespace(reader, expectedNs);
        final String localName = reader.getLocalName();
        final String resolved = resolveString(reader.getElementText());
        if (HOST.equals(localName) && host == null) {
            host = resolved;
        } else if (PROTOCOL.equals(localName) && protocol == null && allowProtocol) {
            protocol = resolved;
        } else if (PORT.equals(localName) && port < 0) {
            try {
                port = Integer.parseInt(resolved);
                if (port < 0) {
                    throw new XMLStreamException("Invalid negative port \"" + resolved + "\"");
                }
            } catch (NumberFormatException e) {
                throw new XMLStreamException("Failed to parse " + DEFAULT_CONTROLLER + " " + PORT + " value '"
                        + resolved + "'", e);
            }
        } else {
            throw new XMLStreamException("Unexpected child of " + DEFAULT_CONTROLLER + ": " + localName);
        }
    }

    return new ControllerAddress(protocol, host == null ? "localhost" : host, port);
}
 
Example 15
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readKeys(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddr) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    List<ModelNode> keyList = new LinkedList<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (!Constants.XML.KEY.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }
        readKey(keyList, reader, parentAddr);
    }
    list.addAll(keyList);
}
 
Example 16
Source File: PackageDepsSpecXmlParser.java    From galleon with Apache License 2.0 5 votes vote down vote up
private static void parseOrigin(XMLExtendedStreamReader reader, PackageDepsSpecBuilder<?> pkgDeps) throws XMLStreamException {
    String origin = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch (attribute) {
            case NAME:
                origin = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (origin == null) {
        throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.NAME));
    }

    while (reader.hasNext()) {
        switch (reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT: {
                return;
            }
            case XMLStreamConstants.START_ELEMENT: {
                switch (reader.getLocalName()) {
                    case PACKAGE:
                        pkgDeps.addPackageDep(origin, parsePackageDependency(reader));
                        break;
                    default:
                        throw ParsingUtils.unexpectedContent(reader);
                }
                break;
            }
            default: {
                throw ParsingUtils.unexpectedContent(reader);
            }
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
 
Example 17
Source File: ConfigXmlParser10.java    From galleon with Apache License 2.0 5 votes vote down vote up
@Override
public void readElement(XMLExtendedStreamReader reader, Configuration t) throws XMLStreamException {
    while (reader.hasNext()) {
        switch (reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT: {
                // DONE.
                return;
            }
            case XMLStreamConstants.START_ELEMENT: {
                switch (reader.getLocalName()) {
                    case MavenConfigXml.MAVEN: {
                        try {
                            MavenConfigXml.read(reader, t.getMavenConfig());
                        } catch (ProvisioningException | IOException ex) {
                            throw new XMLStreamException(ex);
                        }
                        break;
                    }
                    default: {
                        throw ParsingUtils.unexpectedContent(reader);
                    }
                }
                break;
            }
            default: {
                throw ParsingUtils.unexpectedContent(reader);
            }
        }
    }
}
 
Example 18
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void readRoleMappingsProvider(final ModelNode addServiceProvider, final XMLExtendedStreamReader reader) throws XMLStreamException {
    String providerId = readRequiredAttribute(reader, Constants.XML.ID);
    ServiceProviderDefinition.ROLE_MAPPINGS_PROVIDER_ID.parseAndSetParameter(providerId, addServiceProvider, reader);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (!Constants.XML.PROPERTY.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }
        final String[] array = ParseUtils.requireAttributes(reader, Constants.XML.NAME, Constants.XML.VALUE);
        ServiceProviderDefinition.ROLE_MAPPINGS_PROVIDER_CONFIG.parseAndAddParameterElement(array[0], array[1], addServiceProvider, reader);
        ParseUtils.requireNoContent(reader);
    }
}
 
Example 19
Source File: CliConfigImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void readElement(XMLExtendedStreamReader reader, CliConfigImpl config) throws XMLStreamException {
    String localName = reader.getLocalName();
    if (JBOSS_CLI.equals(localName) == false) {
        throw new XMLStreamException("Unexpected element: " + localName);
    }

    Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
    for (Namespace current : Namespace.cliValues()) {
        if (readerNS.equals(current)) {
            switch (readerNS) {
                case CLI_1_0:
                    readCLIElement_1_0(reader, readerNS, config);
                    break;
                case CLI_1_1:
                    readCLIElement_1_1(reader, readerNS, config);
                    break;
                case CLI_1_2:
                case CLI_1_3:
                    readCLIElement_1_2(reader, readerNS, config);
                    break;
                case CLI_2_0:
                    readCLIElement_2_0(reader, readerNS, config);
                    break;
                case CLI_3_0:
                    readCLIElement_3_0(reader, readerNS, config);
                    break;
                case CLI_3_1:
                    readCLIElement_3_1(reader, readerNS, config);
                    break;
                case CLI_3_2:
                    readCLIElement_3_2(reader, readerNS, config);
                    break;
                case CLI_3_3:
                    readCLIElement_3_3(reader, readerNS, config);
                    break;
                default:
                    readCLIElement_3_4(reader, readerNS, config);
            }
            return;
        }
    }
    throw new XMLStreamException("Unexpected element: " + localName);
}
 
Example 20
Source File: GmlcSubsystemParser.java    From gmlc with GNU Affero General Public License v3.0 4 votes vote down vote up
static void parseMbean(XMLExtendedStreamReader reader, PathAddress parent, List<ModelNode> list)
    throws XMLStreamException {
  String name = null;
  final ModelNode mbean = new ModelNode();

  // MBean Attributes
  final int count = reader.getAttributeCount();
  for (int i = 0; i < count; i++) {
    requireNoNamespaceAttribute(reader, i);
    final String attribute = reader.getAttributeLocalName(i);
    final String value = reader.getAttributeValue(i);
    switch (GmlcMbeanDefinition.Element.of(attribute)) {
      case NAME: {
        name = value;
        GmlcMbeanDefinition.NAME_ATTR.parseAndSetParameter(value, mbean, reader);
        break;
      }
      case TYPE: {
        GmlcMbeanDefinition.TYPE_ATTR.parseAndSetParameter(value, mbean, reader);
        break;
      }
      default: {
        throw unexpectedAttribute(reader, i);
      }
    }
  }

  //ParseUtils.requireNoContent(reader);

  if (name == null) {
    throw missingRequired(reader, Collections.singleton(Attribute.NAME));
  }

  mbean.get(OP).set(ADD);
  PathAddress address = PathAddress.pathAddress(parent,
      PathElement.pathElement(GmlcMbeanDefinition.MBEAN, name));
  mbean.get(OP_ADDR).set(address.toModelNode());
  list.add(mbean);

  // properties elements
  while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
    switch (Namespace.forUri(reader.getNamespaceURI())) {
      case SMPPEXT_1_0: {
        final String tagName = reader.getLocalName();
        switch (tagName) {
          case GmlcMbeanPropertyDefinition.PROPERTY: {
            parseProperty(reader, address, list);
            break;
          }
          default: {
            break;
          }
        }
        break;
      }
      default: {
        throw unexpectedElement(reader);
      }
    }
  }
}