本文整理了Java中org.jboss.as.controller.parsing.Element
类的一些代码示例,展示了Element
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element
类的具体详情如下:
包路径:org.jboss.as.controller.parsing.Element
类名称:Element
[英]An enumeration of all the recognized core configuration XML element local names, by name.
[中]按名称枚举所有已识别的核心配置XML元素本地名称。
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
resourceModel = resourceModel.get(attribute.getXmlName());
writer.writeStartElement(attribute.getName());
final List<Property> properties = resourceModel.asPropertyList();
for (Property property: properties) {
writer.writeStartElement(org.jboss.as.controller.parsing.Element.PROPERTY.getLocalName());
writer.writeAttribute(org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), property.getName());
writer.writeCharacters(property.getValue().asString());
writer.writeEndElement();
}
writer.writeEndElement();
}
代码示例来源:origin: wildfly/wildfly
private void parseIndexing(XMLExtendedStreamReader reader, PathAddress cacheAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException {
ModelNode operation = operations.get(cacheAddress);
for (int i = 0; i < reader.getAttributeCount(); i++) {
XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case INDEX: {
readAttribute(reader, i, operation, CacheResourceDefinition.DeprecatedAttribute.INDEXING);
break;
}
default: {
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
Element element = Element.forName(reader.getLocalName());
switch (element) {
case PROPERTY: {
ParseUtils.requireSingleAttribute(reader, XMLAttribute.NAME.getLocalName());
readElement(reader, operation, CacheResourceDefinition.DeprecatedAttribute.INDEXING_PROPERTIES);
break;
}
default: {
throw ParseUtils.unexpectedElement(reader);
}
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void parsePlugIns(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list)
throws XMLStreamException {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case PLUG_IN: {
ModelNode plugIn = new ModelNode();
plugIn.get(OP).set(ADD);
String moduleValue = readStringAttributeElement(reader, Attribute.MODULE.getLocalName());
final ModelNode newAddress = realmAddress.clone();
newAddress.add(PLUG_IN, moduleValue);
plugIn.get(OP_ADDR).set(newAddress);
list.add(plugIn);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
public void parseInterfaces(final XMLExtendedStreamReader reader, final Set<String> names, final ModelNode address,
final Namespace expectedNs, final List<ModelNode> list, final boolean checkSpecified) throws XMLStreamException {
requireNoAttributes(reader);
while (reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, expectedNs);
Element element = Element.forName(reader.getLocalName());
if (Element.INTERFACE != element) {
throw unexpectedElement(reader);
}
// Attributes
requireSingleAttribute(reader, Attribute.NAME.getLocalName());
final String name = reader.getAttributeValue(0);
if (!names.add(name)) {
throw ControllerLogger.ROOT_LOGGER.duplicateInterfaceDeclaration(reader.getLocation());
}
final ModelNode interfaceAdd = new ModelNode();
interfaceAdd.get(OP_ADDR).set(address).add(ModelDescriptionConstants.INTERFACE, name);
interfaceAdd.get(OP).set(ADD);
final ModelNode criteriaNode = interfaceAdd;
parseInterfaceCriteria(reader, expectedNs, interfaceAdd);
if (checkSpecified && criteriaNode.getType() != ModelType.STRING && criteriaNode.getType() != ModelType.EXPRESSION
&& criteriaNode.asInt() == 0) {
throw unexpectedEndElement(reader);
}
list.add(interfaceAdd);
}
}
代码示例来源:origin: org.jboss.as/jboss-as-host-controller
public static ModelNode parseEnvironmentVariables(final XMLExtendedStreamReader reader, final Namespace expectedNs, ModelNode addOp) throws XMLStreamException {
final ModelNode properties = new ModelNode();
while (reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, expectedNs);
if (Element.forName(reader.getLocalName()) != Element.VARIABLE) {
throw unexpectedElement(reader);
}
final String[] array = requireAttributes(reader, Attribute.NAME.getLocalName(), Attribute.VALUE.getLocalName());
requireNoContent(reader);
properties.add(array[0], ParseUtils.parsePossibleExpression(array[1]));
}
if (!properties.isDefined()) {
throw missingRequiredElement(reader, Collections.singleton(Element.OPTION));
}
addOp.get(JvmAttributes.JVM_ENV_VARIABLES).set(properties);
return properties;
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void parseUser(final XMLExtendedStreamReader reader,
final ModelNode usersAddress, final List<ModelNode> list) throws XMLStreamException {
requireSingleAttribute(reader, Attribute.USERNAME.getLocalName());
// After double checking the name of the only attribute we can retrieve it.
final String userName = reader.getAttributeValue(0);
final ModelNode userAddress = usersAddress.clone().add(USER, userName);
ModelNode user = Util.getEmptyOperation(ADD, userAddress);
list.add(user);
String password = null;
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case PASSWORD: {
password = reader.getElementText();
UserResourceDefinition.PASSWORD.parseAndSetParameter(password, user, reader);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
if (password == null) {
throw missingRequiredElement(reader, EnumSet.of(Element.PASSWORD));
}
}
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> nodes) throws XMLStreamException {
if (Element.forName(reader.getLocalName()) != Element.DOMAIN) {
throw unexpectedElement(reader);
}
// Instead of having to list the remaining versions we just check it is actually a valid version.
for (Namespace current : Namespace.domainValues()) {
if (namespace.equals(current)) {
readDomainElement(reader, new ModelNode(), nodes);
return;
}
}
throw unexpectedElement(reader);
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void parseSecret(final XMLExtendedStreamReader reader, final ModelNode realmAddress, final List<ModelNode> list)
throws XMLStreamException {
ModelNode secret = new ModelNode();
secret.get(OP).set(ADD);
secret.get(OP_ADDR).set(realmAddress).add(SERVER_IDENTITY, SECRET);
final int count = reader.getAttributeCount();
boolean hasSecret = false;
if (count > 0) {
String secretValue = readStringAttributeElement(reader, Attribute.VALUE.getLocalName());
SecretServerIdentityResourceDefinition.VALUE.parseAndSetParameter(secretValue, secret, reader);
hasSecret = true;
} else {
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case CREDENTIAL_REFERENCE: {
throw unexpectedElement(reader);
throw missingRequired(reader, Collections.singleton(Attribute.VALUE.getLocalName()));
代码示例来源:origin: org.wildfly.core/wildfly-server
private void parseVault_1_1(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
final int vaultAttribCount = reader.getAttributeCount();
ModelNode vault = new ModelNode();
String code = null;
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case CODE: {
VaultResourceDefinition.CODE.parseAndSetParameter(value, vault, reader);
break;
throw unexpectedAttribute(reader, i);
ModelNode vaultAddress = address.clone();
vaultAddress.add(CORE_SERVICE, VAULT);
if (code != null) {
vault.get(Attribute.CODE.getLocalName()).set(code);
vault.get(OP_ADDR).set(vaultAddress);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, expectedNs);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case VAULT_OPTION: {
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
private void writeIgnoredResources(XMLExtendedStreamWriter writer, ModelNode ignoredTypes) throws XMLStreamException {
for (String ignoredName : ignoredTypes.keys()) {
ModelNode ignored = ignoredTypes.get(ignoredName);
ModelNode names = ignored.hasDefined(NAMES) ? ignored.get(NAMES) : null;
boolean hasNames = names != null && names.asInt() > 0;
if (hasNames) {
writer.writeStartElement(Element.IGNORED_RESOURCE.getLocalName());
} else {
writer.writeEmptyElement(Element.IGNORED_RESOURCE.getLocalName());
}
writer.writeAttribute(Attribute.TYPE.getLocalName(), ignoredName);
IgnoredDomainTypeResourceDefinition.WILDCARD.marshallAsAttribute(ignored, writer);
if (hasNames) {
for (ModelNode name : names.asList()) {
writer.writeEmptyElement(Element.INSTANCE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), name.asString());
}
writer.writeEndElement();
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void writeFileAuditLogHandler(XMLExtendedStreamWriter writer, ModelNode auditLog, String name) throws XMLStreamException {
// added ROTATE_AT_STARTUP attribute
if (auditLog.hasDefined(ModelDescriptionConstants.FILE_HANDLER, name)) {
writer.writeStartElement(Element.FILE_HANDLER.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), name);
ModelNode handler = auditLog.get(ModelDescriptionConstants.FILE_HANDLER, name);
FileAuditLogHandlerResourceDefinition.FORMATTER.marshallAsAttribute(handler, writer);
FileAuditLogHandlerResourceDefinition.MAX_FAILURE_COUNT.marshallAsAttribute(handler, writer);
FileAuditLogHandlerResourceDefinition.PATH.marshallAsAttribute(handler, writer);
FileAuditLogHandlerResourceDefinition.RELATIVE_TO.marshallAsAttribute(handler, writer);
FileAuditLogHandlerResourceDefinition.ROTATE_AT_STARTUP.marshallAsAttribute(handler, writer);
writer.writeEndElement();
}
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
public void parseAccessControlRoleMapping(final XMLExtendedStreamReader reader, final ModelNode accContAddr,
final List<ModelNode> list) throws XMLStreamException {
requireNoAttributes(reader);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
if (element == Element.ROLE) {
parseRole(reader, accContAddr, list);
} else {
throw unexpectedElement(reader);
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
void writeVault(XMLExtendedStreamWriter writer, ModelNode vault) throws XMLStreamException {
writer.writeStartElement(Element.VAULT.getLocalName());
VaultResourceDefinition.CODE.marshallAsAttribute(vault, writer);
VaultResourceDefinition.MODULE.marshallAsAttribute(vault, writer);
if (vault.hasDefined(VAULT_OPTIONS)) {
ModelNode properties = vault.get(VAULT_OPTIONS);
for (Property prop : properties.asPropertyList()) {
writer.writeEmptyElement(Element.VAULT_OPTION.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
writer.writeAttribute(Attribute.VALUE.getLocalName(), prop.getValue().asString());
}
}
writer.writeEndElement();
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void writePrincipal(XMLExtendedStreamWriter writer, String alias, ModelNode principal) throws XMLStreamException {
String elementName = principal.require(TYPE).asString().equalsIgnoreCase(GROUP) ? Element.GROUP.getLocalName() : Element.USER.getLocalName();
writer.writeStartElement(elementName);
String realm = principal.get(REALM).isDefined() ? principal.require(REALM).asString() : null;
String name = principal.require(NAME).asString();
String expectedAlias = AccessControlXml.generateAlias(elementName, name, realm);
if (alias.equals(expectedAlias)==false) {
writeAttribute(writer, Attribute.ALIAS, alias);
}
PrincipalResourceDefinition.REALM.marshallAsAttribute(principal, writer);
PrincipalResourceDefinition.NAME.marshallAsAttribute(principal, writer);
writer.writeEndElement();
}
代码示例来源:origin: wildfly/wildfly
@Override
public void marshallAsElement(AttributeDefinition attribute, ModelNode model, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
if (model.hasDefined(attribute.getName())) {
for (Property property : model.get(attribute.getName()).asPropertyList()) {
writer.writeStartElement(Element.PROPERTY.getLocalName());
writer.writeAttribute(Element.NAME.getLocalName(), property.getName());
writer.writeCharacters(property.getValue().asString());
writer.writeEndElement();
}
}
}
};
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
private void writeServerGroupDeployments(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
final Set<String> deploymentNames = modelNode.keys();
if (deploymentNames.size() > 0) {
writer.writeStartElement(Element.DEPLOYMENTS.getLocalName());
for (String uniqueName : deploymentNames) {
final ModelNode deployment = modelNode.get(uniqueName);
writer.writeStartElement(Element.DEPLOYMENT.getLocalName());
WriteUtils.writeAttribute(writer, Attribute.NAME, uniqueName);
DeploymentAttributes.RUNTIME_NAME.marshallAsAttribute(deployment, writer);
DeploymentAttributes.ENABLED.marshallAsAttribute(deployment, writer);
writer.writeEndElement();
}
writer.writeEndElement();
}
}
代码示例来源:origin: org.wildfly/wildfly-controller
private void marshalToElement(ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException {
if (!resourceModel.isDefined()) { return; }
for (Property property : resourceModel.asPropertyList()) {
writer.writeStartElement(PROPERTY.getLocalName());
writer.writeAttribute(NAME.getLocalName(), property.getName());
writer.writeCharacters(property.getValue().asString());
writer.writeEndElement();
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
private void writeManagementClientContent(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
boolean hasRolloutPlans = modelNode.hasDefined(ROLLOUT_PLANS) && modelNode.get(ROLLOUT_PLANS).hasDefined(HASH);
boolean mustWrite = hasRolloutPlans; // || other elements we may add later
if (mustWrite) {
writer.writeStartElement(Element.MANAGEMENT_CLIENT_CONTENT.getLocalName());
if (hasRolloutPlans) {
writer.writeEmptyElement(Element.ROLLOUT_PLANS.getLocalName());
writer.writeAttribute(Attribute.SHA1.getLocalName(), HashUtil.bytesToHexString(modelNode.get(ROLLOUT_PLANS).get(HASH).asBytes()));
}
writer.writeEndElement();
}
}
代码示例来源:origin: org.wildfly.core/wildfly-controller
public static Element nextElement(XMLExtendedStreamReader reader) throws XMLStreamException {
if (reader.nextTag() == END_ELEMENT) {
return null;
}
return Element.forName(reader.getLocalName());
}
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
@Override
public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
writer.writeEmptyElement(Element.HOST.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), resourceModel.asString());
}
}).build())
内容来源于网络,如有侵权,请联系作者删除!