org.jboss.as.controller.parsing.Element类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.7k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中org.jboss.as.controller.parsing.Element类的一些代码示例,展示了Element类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element类的具体详情如下:
包路径:org.jboss.as.controller.parsing.Element
类名称:Element

Element介绍

[英]An enumeration of all the recognized core configuration XML element local names, by name.
[中]按名称枚举所有已识别的核心配置XML元素本地名称。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

  1. @Override
  2. public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
  3. resourceModel = resourceModel.get(attribute.getXmlName());
  4. writer.writeStartElement(attribute.getName());
  5. final List<Property> properties = resourceModel.asPropertyList();
  6. for (Property property: properties) {
  7. writer.writeStartElement(org.jboss.as.controller.parsing.Element.PROPERTY.getLocalName());
  8. writer.writeAttribute(org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), property.getName());
  9. writer.writeCharacters(property.getValue().asString());
  10. writer.writeEndElement();
  11. }
  12. writer.writeEndElement();
  13. }

代码示例来源:origin: wildfly/wildfly

  1. private void parseIndexing(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
  2. ModelNode operation = operations.get(cacheAddress);
  3. for (int i = 0; i < reader.getAttributeCount(); i++) {
  4. XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
  5. switch (attribute) {
  6. case INDEX: {
  7. readAttribute(reader, i, operation, CacheResourceDefinition.DeprecatedAttribute.INDEXING);
  8. break;
  9. }
  10. default: {
  11. throw ParseUtils.unexpectedAttribute(reader, i);
  12. }
  13. }
  14. }
  15. while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
  16. Element element = Element.forName(reader.getLocalName());
  17. switch (element) {
  18. case PROPERTY: {
  19. ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName());
  20. readElement(reader, operation, CacheResourceDefinition.DeprecatedAttribute.INDEXING_PROPERTIES);
  21. break;
  22. }
  23. default: {
  24. throw ParseUtils.unexpectedElement(reader);
  25. }
  26. }
  27. }
  28. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. private void parsePlugIns(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list)
  2. throws XMLStreamException {
  3. while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  4. requireNamespace(reader, namespace);
  5. final Element element = Element.forName(reader.getLocalName());
  6. switch (element) {
  7. case PLUG_IN: {
  8. ModelNode plugIn = new ModelNode();
  9. plugIn.get(OP).set(ADD);
  10. String moduleValue = readStringAttributeElement(reader, Attribute.MODULE.getLocalName());
  11. final ModelNode newAddress = realmAddress.clone();
  12. newAddress.add(PLUG_IN, moduleValue);
  13. plugIn.get(OP_ADDR).set(newAddress);
  14. list.add(plugIn);
  15. break;
  16. }
  17. default: {
  18. throw unexpectedElement(reader);
  19. }
  20. }
  21. }
  22. }

代码示例来源:origin: org.wildfly.core/wildfly-server

  1. public void parseInterfaces(final XMLExtendedStreamReader reader, final Set<String> names, final ModelNode address,
  2. final Namespace expectedNs, final List<ModelNode> list, final boolean checkSpecified) throws XMLStreamException {
  3. requireNoAttributes(reader);
  4. while (reader.nextTag() != END_ELEMENT) {
  5. requireNamespace(reader, expectedNs);
  6. Element element = Element.forName(reader.getLocalName());
  7. if (Element.INTERFACE != element) {
  8. throw unexpectedElement(reader);
  9. }
  10. // Attributes
  11. requireSingleAttribute(reader, Attribute.NAME.getLocalName());
  12. final String name = reader.getAttributeValue(0);
  13. if (!names.add(name)) {
  14. throw ControllerLogger.ROOT_LOGGER.duplicateInterfaceDeclaration(reader.getLocation());
  15. }
  16. final ModelNode interfaceAdd = new ModelNode();
  17. interfaceAdd.get(OP_ADDR).set(address).add(ModelDescriptionConstants.INTERFACE, name);
  18. interfaceAdd.get(OP).set(ADD);
  19. final ModelNode criteriaNode = interfaceAdd;
  20. parseInterfaceCriteria(reader, expectedNs, interfaceAdd);
  21. if (checkSpecified && criteriaNode.getType() != ModelType.STRING && criteriaNode.getType() != ModelType.EXPRESSION
  22. && criteriaNode.asInt() == 0) {
  23. throw unexpectedEndElement(reader);
  24. }
  25. list.add(interfaceAdd);
  26. }
  27. }

代码示例来源:origin: org.jboss.as/jboss-as-host-controller

  1. public static ModelNode parseEnvironmentVariables(final XMLExtendedStreamReader reader, final Namespace expectedNs, ModelNode addOp) throws XMLStreamException {
  2. final ModelNode properties = new ModelNode();
  3. while (reader.nextTag() != END_ELEMENT) {
  4. requireNamespace(reader, expectedNs);
  5. if (Element.forName(reader.getLocalName()) != Element.VARIABLE) {
  6. throw unexpectedElement(reader);
  7. }
  8. final String[] array = requireAttributes(reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
  9. requireNoContent(reader);
  10. properties.add(array[0], ParseUtils.parsePossibleExpression(array[1]));
  11. }
  12. if (!properties.isDefined()) {
  13. throw missingRequiredElement(reader, Collections.singleton(Element.OPTION));
  14. }
  15. addOp.get(JvmAttributes.JVM_ENV_VARIABLES).set(properties);
  16. return properties;
  17. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. private void parseUser(final XMLExtendedStreamReader reader,
  2. final ModelNode usersAddress, final List<ModelNode> list) throws XMLStreamException {
  3. requireSingleAttribute(reader, Attribute.USERNAME.getLocalName());
  4. // After double checking the name of the only attribute we can retrieve it.
  5. final String userName = reader.getAttributeValue(0);
  6. final ModelNode userAddress = usersAddress.clone().add(USER, userName);
  7. ModelNode user = Util.getEmptyOperation(ADD, userAddress);
  8. list.add(user);
  9. String password = null;
  10. while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  11. requireNamespace(reader, namespace);
  12. final Element element = Element.forName(reader.getLocalName());
  13. switch (element) {
  14. case PASSWORD: {
  15. password = reader.getElementText();
  16. UserResourceDefinition.PASSWORD.parseAndSetParameter(password, user, reader);
  17. break;
  18. }
  19. default: {
  20. throw unexpectedElement(reader);
  21. }
  22. }
  23. }
  24. if (password == null) {
  25. throw missingRequiredElement(reader, EnumSet.of(Element.PASSWORD));
  26. }
  27. }

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

  1. @Override
  2. public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> nodes) throws XMLStreamException {
  3. if (Element.forName(reader.getLocalName()) != Element.DOMAIN) {
  4. throw unexpectedElement(reader);
  5. }
  6. // Instead of having to list the remaining versions we just check it is actually a valid version.
  7. for (Namespace current : Namespace.domainValues()) {
  8. if (namespace.equals(current)) {
  9. readDomainElement(reader, new ModelNode(), nodes);
  10. return;
  11. }
  12. }
  13. throw unexpectedElement(reader);
  14. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. private void parseSecret(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list)
  2. throws XMLStreamException {
  3. ModelNode secret = new ModelNode();
  4. secret.get(OP).set(ADD);
  5. secret.get(OP_ADDR).set(realmAddress).add(SERVER_IDENTITY, SECRET);
  6. final int count = reader.getAttributeCount();
  7. boolean hasSecret = false;
  8. if (count > 0) {
  9. String secretValue = readStringAttributeElement(reader, Attribute.VALUE.getLocalName());
  10. SecretServerIdentityResourceDefinition.VALUE.parseAndSetParameter(secretValue, secret, reader);
  11. hasSecret = true;
  12. } else {
  13. while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  14. requireNamespace(reader, namespace);
  15. final Element element = Element.forName(reader.getLocalName());
  16. switch (element) {
  17. case CREDENTIAL_REFERENCE: {
  18. throw unexpectedElement(reader);
  19. throw missingRequired(reader, Collections.singleton(Attribute.VALUE.getLocalName()));

代码示例来源:origin: org.wildfly.core/wildfly-server

  1. private void parseVault_1_1(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
  2. final int vaultAttribCount = reader.getAttributeCount();
  3. ModelNode vault = new ModelNode();
  4. String code = null;
  5. requireNoNamespaceAttribute(reader, i);
  6. final String value = reader.getAttributeValue(i);
  7. final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
  8. switch (attribute) {
  9. case CODE: {
  10. VaultResourceDefinition.CODE.parseAndSetParameter(value, vault, reader);
  11. break;
  12. throw unexpectedAttribute(reader, i);
  13. ModelNode vaultAddress = address.clone();
  14. vaultAddress.add(CORE_SERVICE, VAULT);
  15. if (code != null) {
  16. vault.get(Attribute.CODE.getLocalName()).set(code);
  17. vault.get(OP_ADDR).set(vaultAddress);
  18. while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  19. requireNamespace(reader, expectedNs);
  20. final Element element = Element.forName(reader.getLocalName());
  21. switch (element) {
  22. case VAULT_OPTION: {

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

  1. private void writeIgnoredResources(XMLExtendedStreamWriter writer, ModelNode ignoredTypes) throws XMLStreamException {
  2. for (String ignoredName : ignoredTypes.keys()) {
  3. ModelNode ignored = ignoredTypes.get(ignoredName);
  4. ModelNode names = ignored.hasDefined(NAMES) ? ignored.get(NAMES) : null;
  5. boolean hasNames = names != null && names.asInt() > 0;
  6. if (hasNames) {
  7. writer.writeStartElement(Element.IGNORED_RESOURCE.getLocalName());
  8. } else {
  9. writer.writeEmptyElement(Element.IGNORED_RESOURCE.getLocalName());
  10. }
  11. writer.writeAttribute(Attribute.TYPE.getLocalName(), ignoredName);
  12. IgnoredDomainTypeResourceDefinition.WILDCARD.marshallAsAttribute(ignored, writer);
  13. if (hasNames) {
  14. for (ModelNode name : names.asList()) {
  15. writer.writeEmptyElement(Element.INSTANCE.getLocalName());
  16. writer.writeAttribute(Attribute.NAME.getLocalName(), name.asString());
  17. }
  18. writer.writeEndElement();
  19. }
  20. }
  21. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. private void writeFileAuditLogHandler(XMLExtendedStreamWriter writer, ModelNode auditLog, String name) throws XMLStreamException {
  2. // added ROTATE_AT_STARTUP attribute
  3. if (auditLog.hasDefined(ModelDescriptionConstants.FILE_HANDLER, name)) {
  4. writer.writeStartElement(Element.FILE_HANDLER.getLocalName());
  5. writer.writeAttribute(Attribute.NAME.getLocalName(), name);
  6. ModelNode handler = auditLog.get(ModelDescriptionConstants.FILE_HANDLER, name);
  7. FileAuditLogHandlerResourceDefinition.FORMATTER.marshallAsAttribute(handler, writer);
  8. FileAuditLogHandlerResourceDefinition.MAX_FAILURE_COUNT.marshallAsAttribute(handler, writer);
  9. FileAuditLogHandlerResourceDefinition.PATH.marshallAsAttribute(handler, writer);
  10. FileAuditLogHandlerResourceDefinition.RELATIVE_TO.marshallAsAttribute(handler, writer);
  11. FileAuditLogHandlerResourceDefinition.ROTATE_AT_STARTUP.marshallAsAttribute(handler, writer);
  12. writer.writeEndElement();
  13. }
  14. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. public void parseAccessControlRoleMapping(final XMLExtendedStreamReader reader, final ModelNode accContAddr,
  2. final List<ModelNode> list) throws XMLStreamException {
  3. requireNoAttributes(reader);
  4. while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
  5. requireNamespace(reader, namespace);
  6. final Element element = Element.forName(reader.getLocalName());
  7. if (element == Element.ROLE) {
  8. parseRole(reader, accContAddr, list);
  9. } else {
  10. throw unexpectedElement(reader);
  11. }
  12. }
  13. }

代码示例来源:origin: org.wildfly.core/wildfly-server

  1. void writeVault(XMLExtendedStreamWriter writer, ModelNode vault) throws XMLStreamException {
  2. writer.writeStartElement(Element.VAULT.getLocalName());
  3. VaultResourceDefinition.CODE.marshallAsAttribute(vault, writer);
  4. VaultResourceDefinition.MODULE.marshallAsAttribute(vault, writer);
  5. if (vault.hasDefined(VAULT_OPTIONS)) {
  6. ModelNode properties = vault.get(VAULT_OPTIONS);
  7. for (Property prop : properties.asPropertyList()) {
  8. writer.writeEmptyElement(Element.VAULT_OPTION.getLocalName());
  9. writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
  10. writer.writeAttribute(Attribute.VALUE.getLocalName(), prop.getValue().asString());
  11. }
  12. }
  13. writer.writeEndElement();
  14. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. private void writePrincipal(XMLExtendedStreamWriter writer, String alias, ModelNode principal) throws XMLStreamException {
  2. String elementName = principal.require(TYPE).asString().equalsIgnoreCase(GROUP) ? Element.GROUP.getLocalName() : Element.USER.getLocalName();
  3. writer.writeStartElement(elementName);
  4. String realm = principal.get(REALM).isDefined() ? principal.require(REALM).asString() : null;
  5. String name = principal.require(NAME).asString();
  6. String expectedAlias = AccessControlXml.generateAlias(elementName, name, realm);
  7. if (alias.equals(expectedAlias)==false) {
  8. writeAttribute(writer, Attribute.ALIAS, alias);
  9. }
  10. PrincipalResourceDefinition.REALM.marshallAsAttribute(principal, writer);
  11. PrincipalResourceDefinition.NAME.marshallAsAttribute(principal, writer);
  12. writer.writeEndElement();
  13. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public void marshallAsElement(AttributeDefinition attribute, ModelNode model, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
  3. if (model.hasDefined(attribute.getName())) {
  4. for (Property property : model.get(attribute.getName()).asPropertyList()) {
  5. writer.writeStartElement(Element.PROPERTY.getLocalName());
  6. writer.writeAttribute(Element.NAME.getLocalName(), property.getName());
  7. writer.writeCharacters(property.getValue().asString());
  8. writer.writeEndElement();
  9. }
  10. }
  11. }
  12. };

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

  1. private void writeServerGroupDeployments(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
  2. final Set<String> deploymentNames = modelNode.keys();
  3. if (deploymentNames.size() > 0) {
  4. writer.writeStartElement(Element.DEPLOYMENTS.getLocalName());
  5. for (String uniqueName : deploymentNames) {
  6. final ModelNode deployment = modelNode.get(uniqueName);
  7. writer.writeStartElement(Element.DEPLOYMENT.getLocalName());
  8. WriteUtils.writeAttribute(writer, Attribute.NAME, uniqueName);
  9. DeploymentAttributes.RUNTIME_NAME.marshallAsAttribute(deployment, writer);
  10. DeploymentAttributes.ENABLED.marshallAsAttribute(deployment, writer);
  11. writer.writeEndElement();
  12. }
  13. writer.writeEndElement();
  14. }
  15. }

代码示例来源:origin: org.wildfly/wildfly-controller

  1. private void marshalToElement(ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException {
  2. if (!resourceModel.isDefined()) { return; }
  3. for (Property property : resourceModel.asPropertyList()) {
  4. writer.writeStartElement(PROPERTY.getLocalName());
  5. writer.writeAttribute(NAME.getLocalName(), property.getName());
  6. writer.writeCharacters(property.getValue().asString());
  7. writer.writeEndElement();
  8. }
  9. }
  10. }

代码示例来源:origin: org.wildfly.core/wildfly-host-controller

  1. private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
  2. boolean hasRolloutPlans = modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH);
  3. boolean mustWrite = hasRolloutPlans; // || other elements we may add later
  4. if (mustWrite) {
  5. writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName());
  6. if (hasRolloutPlans) {
  7. writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName());
  8. writer.writeAttribute(Attribute.SHA1.getLocalName(), HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes()));
  9. }
  10. writer.writeEndElement();
  11. }
  12. }

代码示例来源:origin: org.wildfly.core/wildfly-controller

  1. public static Element nextElement(XMLExtendedStreamReader reader) throws XMLStreamException {
  2. if (reader.nextTag() == END_ELEMENT) {
  3. return null;
  4. }
  5. return Element.forName(reader.getLocalName());
  6. }

代码示例来源:origin: org.wildfly.core/wildfly-domain-management

  1. @Override
  2. public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
  3. writer.writeEmptyElement(Element.HOST.getLocalName());
  4. writer.writeAttribute(Attribute.NAME.getLocalName(), resourceModel.asString());
  5. }
  6. }).build())

相关文章