use of org.jboss.as.controller.AttributeParser in project wildfly by wildfly.
the class BatchSubsystemParser_1_0 method readElement.
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> ops) throws XMLStreamException {
final ThreadsParser threadsParser = ThreadsParser.getInstance();
final PathAddress subsystemAddress = PathAddress.pathAddress(BatchSubsystemDefinition.SUBSYSTEM_PATH);
// Add the subsystem
final ModelNode subsystemAddOp = Util.createAddOperation(subsystemAddress);
ops.add(subsystemAddOp);
// Find the required elements
final Set<Element> requiredElements = EnumSet.of(Element.JOB_REPOSITORY, Element.THREAD_POOL);
attributeElements.forEach((element, attribute) -> {
if (!attribute.isAllowNull() && attribute.getDefaultValue() == null) {
requiredElements.add(element);
}
});
final Namespace namespace = Namespace.forUri(reader.getNamespaceURI());
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final String localName = reader.getLocalName();
final Element element = Element.forName(localName);
final SimpleAttributeDefinition attribute = attributeElements.get(element);
if (attribute != null) {
final AttributeParser parser = attribute.getParser();
if (parser.isParseAsElement()) {
parser.parseElement(attribute, reader, subsystemAddOp);
} else {
// Assume this is an element with a single name attribute
parser.parseAndSetParameter(attribute, AttributeParsers.readNameAttribute(reader), subsystemAddOp, reader);
ParseUtils.requireNoContent(reader);
}
requiredElements.remove(element);
} else if (element == Element.JOB_REPOSITORY) {
final String name = AttributeParsers.readNameAttribute(reader);
parseJobRepository(reader, subsystemAddress, name, ops);
requiredElements.remove(Element.JOB_REPOSITORY);
} else if (element == Element.THREAD_POOL) {
threadsParser.parseUnboundedQueueThreadPool(reader, namespace.getUriString(), THREADS_1_1, subsystemAddress.toModelNode(), ops, BatchThreadPoolResourceDefinition.NAME, null);
requiredElements.remove(Element.THREAD_POOL);
} else if (element == Element.THREAD_FACTORY) {
threadsParser.parseThreadFactory(reader, namespace.getUriString(), THREADS_1_1, subsystemAddress.toModelNode(), ops, BatchSubsystemDefinition.THREAD_FACTORY, null);
} else {
throw ParseUtils.unexpectedElement(reader);
}
}
if (!requiredElements.isEmpty()) {
throw ParseUtils.missingRequired(reader, requiredElements);
}
ParseUtils.requireNoContent(reader);
}
Aggregations