本文整理了Java中org.jboss.as.controller.parsing.Namespace
类的一些代码示例,展示了Namespace
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace
类的具体详情如下:
包路径:org.jboss.as.controller.parsing.Namespace
类名称:Namespace
[英]An enumeration of the supported domain model namespaces.
[中]支持的域模型命名空间的枚举。
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
throws XMLStreamException {
final ModelNode address = new ModelNode().setEmptyList();
if (Element.forName(reader.getLocalName()) != Element.HOST) {
throw unexpectedElement(reader);
}
Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
if (readerNS == DOMAIN_1_0) {
readHostElement_1_0(reader, address, operationList);
} else if (readerNS.getMajorVersion() == 1 || readerNS.getMajorVersion() == 2) {
readHostElement_1_1(readerNS, reader, address, operationList);
} else {
// Instead of having to list the remaining versions we just check it is actually a valid version.
for (Namespace current : Namespace.domainValues()) {
if (readerNS.equals(current)) {
readHostElement_3_0(readerNS, reader, address, operationList);
return;
}
}
throw unexpectedElement(reader);
}
}
代码示例来源:origin: org.jboss.as/jboss-as-host-controller
public static ExtensibleConfigurationPersister createHostXmlConfigurationPersister(final ConfigurationFile file, String defaultHostControllerName) {
HostXml hostXml = new HostXml(defaultHostControllerName);
BackupXmlConfigurationPersister persister = new BackupXmlConfigurationPersister(file, new QName(Namespace.CURRENT.getUriString(), "host"), hostXml, hostXml);
for (Namespace namespace : Namespace.domainValues()) {
if (!namespace.equals(Namespace.CURRENT)) {
persister.registerAdditionalRootElement(new QName(namespace.getUriString(), "host"), hostXml);
}
}
return persister;
}
代码示例来源:origin: org.wildfly.core/wildfly-controller
public static Namespace[] domainValues() {
Namespace[] temp = values();
// The 3 is for the 3 namespaces excluded below.
Namespace[] response = new Namespace[temp.length - 3];
int nextPos = 0;
for (Namespace current : temp) {
if (current != UNKNOWN && current != NONE && current != XML_SCHEMA_INSTANCE) {
response[nextPos++] = current;
}
}
return response;
}
代码示例来源:origin: org.wildfly.core/wildfly-controller
/**
* A variation of nextElement that verifies the nextElement is not in a different namespace.
*
* @param reader the XmlExtendedReader to read from.
* @param expectedNamespace the namespace expected.
* @return the element or null if the end is reached
* @throws XMLStreamException if the namespace is wrong or there is a problem accessing the reader
*/
public static Element nextElement(XMLExtendedStreamReader reader, Namespace expectedNamespace) throws XMLStreamException {
Element element = nextElement(reader);
if (element == null) {
return element;
} else if (element != Element.UNKNOWN
&& expectedNamespace.equals(Namespace.forUri(reader.getNamespaceURI()))) {
return element;
}
throw unexpectedElement(reader);
}
代码示例来源: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.jboss.as/jboss-as-host-controller
protected void readDomainElementAttributes_1_3(XMLExtendedStreamReader reader, Namespace expectedNs, ModelNode address, List<ModelNode> list) throws XMLStreamException {
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
Namespace ns = Namespace.forUri(reader.getAttributeNamespace(i));
switch (ns) {
case XML_SCHEMA_INSTANCE: {
switch (Attribute.forName(reader.getAttributeLocalName(i))) {
case SCHEMA_LOCATION: {
parseSchemaLocations(reader, address, list, i);
throw unexpectedAttribute(reader, i);
switch (Attribute.forName(reader.getAttributeLocalName(i))) {
case NAME:
ModelNode op = new ModelNode();
op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set(NAME);
op.get(VALUE).set(ParseUtils.parsePossibleExpression(reader.getAttributeValue(i)));
list.add(op);
break;
default:
throw unexpectedAttribute(reader, i);
代码示例来源:origin: wildfly/wildfly-core
private void parseStaticDiscoveryOption(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, final Set<String> staticDiscoveryOptionNames) throws XMLStreamException {
final ModelNode staticDiscoveryOptionAddress = address.clone();
staticDiscoveryOptionAddress.add(CORE_SERVICE, DISCOVERY_OPTIONS);
final ModelNode addOp = Util.getEmptyOperation(ADD, new ModelNode());
list.add(addOp);
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);
if(namespace.getMajorVersion() > 2) {
StaticDiscoveryResourceDefinition.PROTOCOL.parseAndSetParameter(value, addOp, reader);
} else {
throw unexpectedAttribute(reader, i);
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
break;
default:
switch (namespace.getMajorVersion()) {
case 2:
parseGroupToPrincipalAttributes_1_5_and_2_0(reader, addOp);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
if (elementFound) {
throw unexpectedElement(reader);
break;
default: {
throw unexpectedElement(reader);
addOp.get(OP_ADDR).set(parentAddress.clone().add(GROUP_TO_PRINCIPAL));
代码示例来源:origin: wildfly/wildfly-core
private void parseLdapAuthorization_1_5(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);
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) {
throw unexpectedAttribute(reader, i);
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 (namespace.getMajorVersion()) {
case 1: // 1.5 up to but not including 2.0
parseUsernameToDn_1_5(reader, addr, list);
代码示例来源:origin: org.wildfly.core/wildfly-server
protected void writeSchemaLocation(final XMLExtendedStreamWriter writer, final ModelNode modelNode)
throws XMLStreamException {
if (!modelNode.hasDefined(SCHEMA_LOCATIONS)) {
return;
}
final StringBuilder b = new StringBuilder();
final Iterator<ModelNode> iterator = modelNode.get(SCHEMA_LOCATIONS).asList().iterator();
while (iterator.hasNext()) {
final ModelNode location = iterator.next();
final Property property = location.asProperty();
b.append(property.getName()).append(' ').append(property.getValue().asString());
if (iterator.hasNext()) {
b.append(' ');
}
}
if (b.length() > 0) {
writer.writeAttribute(Namespace.XML_SCHEMA_INSTANCE.getUriString(), Attribute.SCHEMA_LOCATION.getLocalName(),
b.toString());
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
private void parseInterfaceCriteria(final XMLExtendedStreamReader reader, final Namespace expectedNs,
final ModelNode interfaceModel) throws XMLStreamException {
if (reader.nextTag() == END_ELEMENT) {
return;
requireNamespace(reader, expectedNs);
Element element = Element.forName(reader.getLocalName());
switch (element) {
case ANY_IPV4_ADDRESS:
case ANY_IPV6_ADDRESS: {
if (expectedNs.getMajorVersion() >= 3) {
throw ParseUtils.unexpectedElement(reader);
} else {
throw ParseUtils.unsupportedElement(reader, Element.ANY_ADDRESS.getLocalName());
interfaceModel.get(Element.ANY_ADDRESS.getLocalName()).set(true);
requireNoContent(reader); // consume this element
requireNoContent(reader); // consume rest of criteria (no further content allowed)
requireNamespace(reader, expectedNs);
element = Element.forName(reader.getLocalName());
switch (element) {
case ANY:
parseCompoundInterfaceCriterion(reader, expectedNs, interfaceModel.get(ANY).setEmptyObject());
break;
case NOT:
代码示例来源:origin: org.jboss.as/jboss-as-host-controller
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
throws XMLStreamException {
final ModelNode address = new ModelNode().setEmptyList();
if (Element.forName(reader.getLocalName()) != Element.HOST) {
throw unexpectedElement(reader);
}
Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
switch (readerNS) {
case DOMAIN_1_0: {
readHostElement_1_0(reader, address, operationList);
break;
}
case DOMAIN_1_1:
case DOMAIN_1_2:
case DOMAIN_1_3:
case DOMAIN_1_4:{
readHostElement_1_1(readerNS, reader, address, operationList);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
代码示例来源:origin: org.jboss.as/jboss-as-server
protected void writeNamespaces(final XMLExtendedStreamWriter writer, final ModelNode modelNode) throws XMLStreamException {
final boolean needXsd = modelNode.hasDefined(SCHEMA_LOCATIONS) && modelNode.get(SCHEMA_LOCATIONS).asInt() > 0;
final boolean hasNamespaces = modelNode.hasDefined(NAMESPACES);
if (!needXsd && !hasNamespaces) {
return;
}
boolean wroteXsd = false;
final String xsdUri = Namespace.XML_SCHEMA_INSTANCE.getUriString();
if (hasNamespaces) {
for (final Property property : modelNode.get(NAMESPACES).asPropertyList()) {
final String uri = property.getValue().asString();
writer.writeNamespace(property.getName(), uri);
if (!wroteXsd && xsdUri.equals(uri)) {
wroteXsd = true;
}
}
}
if (needXsd && !wroteXsd) {
writer.writeNamespace("xsd", xsdUri);
}
}
代码示例来源:origin: wildfly/wildfly-core
private void parseLdapAuthentication_1_7_and_2_0(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);
switch (namespace.getMajorVersion()) {
case 1:
parseLdapAuthenticationAttributes_1_4(reader, ldapAuthentication);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
if (choiceFound) {
throw unexpectedElement(reader);
case ADVANCED_FILTER:
choiceFound = true;
String filter = readStringAttributeElement(reader, Attribute.FILTER.getLocalName());
LdapAuthenticationResourceDefinition.ADVANCED_FILTER.parseAndSetParameter(filter, ldapAuthentication,
reader);
case USERNAME_FILTER: {
choiceFound = true;
String usernameAttr = readStringAttributeElement(reader, Attribute.ATTRIBUTE.getLocalName());
LdapAuthenticationResourceDefinition.USERNAME_FILTER.parseAndSetParameter(usernameAttr, ldapAuthentication,
reader);
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
private void parseRemoteDomainController_2_0(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
boolean requireDiscoveryOptions;
boolean hasDiscoveryOptions = false;
if (namespace.getMajorVersion()< 3) {
requireDiscoveryOptions = parseRemoteDomainControllerAttributes_2_0(reader, address, list);
} else {
Set<String> staticDiscoveryOptionNames = new HashSet<String>();
Set<String> discoveryOptionNames = new HashSet<String>();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case IGNORED_RESOURCE: {
throw ControllerLogger.ROOT_LOGGER.alreadyDefined(element.getLocalName(), reader.getLocation());
throw unexpectedElement(reader);
Attribute.ADMIN_ONLY_POLICY.getLocalName(), AdminOnlyDomainConfigPolicy.FETCH_FROM_MASTER.toString(),
Element.DISCOVERY_OPTIONS.getLocalName(), Attribute.HOST.getLocalName(), Attribute.PORT.getLocalName(),
reader.getLocation());
代码示例来源:origin: org.wildfly.core/wildfly-domain-management
private void parseServerIdentities_1_0(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 SECRET: {
if (namespace.getMajorVersion() == 1) {
throw unexpectedElement(reader);
代码示例来源:origin: org.wildfly.core/wildfly-host-controller
private void readDomainElementAttributes_1_0(XMLExtendedStreamReader reader, ModelNode address, List<ModelNode> list) throws XMLStreamException {
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
switch (Namespace.forUri(reader.getAttributeNamespace(i))) {
case XML_SCHEMA_INSTANCE: {
switch (Attribute.forName(reader.getAttributeLocalName(i))) {
case SCHEMA_LOCATION: {
parseSchemaLocations(reader, address, list, i);
break;
}
case NO_NAMESPACE_SCHEMA_LOCATION: {
// todo, jeez
break;
}
default: {
throw unexpectedAttribute(reader, i);
}
}
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-controller
/**
* Require that the namespace of the current element matches the required namespace.
*
* @param reader the reader
* @param requiredNs the namespace required
* @throws XMLStreamException if the current namespace does not match the required namespace
*/
public static void requireNamespace(final XMLExtendedStreamReader reader, final Namespace requiredNs) throws XMLStreamException {
Namespace actualNs = Namespace.forUri(reader.getNamespaceURI());
if (actualNs != requiredNs) {
throw unexpectedElement(reader);
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace expectedNs, final List<ModelNode> list) throws XMLStreamException {
switch (expectedNs) {
case DOMAIN_1_0:
throw unexpectedElement(reader);
case DOMAIN_1_1:
case DOMAIN_1_2:
case DOMAIN_1_3:
case DOMAIN_1_4:
case DOMAIN_1_5:
parseVault_1_1(reader, address, expectedNs, list);
break;
default:
if (expectedNs.getMajorVersion() == 2) {
parseVault_1_1(reader, address, expectedNs, list);
} else {
parseVault_1_6_and_3_0(reader, address, expectedNs, list);
}
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> operationList)
throws XMLStreamException {
Namespace readerNS = Namespace.forUri(reader.getNamespaceURI());
switch (readerNS.getMajorVersion()) {
case 1:
case 2:
内容来源于网络,如有侵权,请联系作者删除!