use of org.mule.runtime.config.internal.parsers.XmlMetadataAnnotations in project mule by mulesoft.
the class XmlApplicationParser method configLineFromElement.
private Optional<ConfigLine> configLineFromElement(Node node, ConfigLineProvider parentProvider) {
if (!isValidType(node)) {
return Optional.empty();
}
String identifier = parseIdentifier(node);
String namespace = parseNamespace(node);
ConfigLine.Builder builder = new ConfigLine.Builder().setIdentifier(identifier).setNamespace(namespace).setNode(node).setParent(parentProvider);
XmlMetadataAnnotations userData = (XmlMetadataAnnotations) node.getUserData(XmlMetadataAnnotations.METADATA_ANNOTATIONS_KEY);
int lineNumber = userData.getLineNumber();
builder.setLineNumber(lineNumber);
to(builder).addNode(node);
Element element = (Element) node;
NamedNodeMap attributes = element.getAttributes();
if (element.hasAttributes()) {
for (int i = 0; i < attributes.getLength(); i++) {
Node attribute = attributes.item(i);
Attr attributeNode = element.getAttributeNode(attribute.getNodeName());
boolean isFromXsd = !attributeNode.getSpecified();
builder.addConfigAttribute(attribute.getNodeName(), attribute.getNodeValue(), isFromXsd);
}
}
if (node.hasChildNodes()) {
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (isTextContent(child)) {
builder.setTextContent(child.getNodeValue());
if (child.getNodeType() == Node.CDATA_SECTION_NODE) {
builder.addCustomAttribute(IS_CDATA, Boolean.TRUE);
break;
}
} else {
configLineFromElement(child, builder::build).ifPresent(builder::addChild);
}
}
}
return Optional.of(builder.build());
}
use of org.mule.runtime.config.internal.parsers.XmlMetadataAnnotations in project mule by mulesoft.
the class CommonBeanDefinitionCreator method processMetadataAnnotationsHelper.
private Map<QName, Object> processMetadataAnnotationsHelper(Element element, String configFileIdentifier, BeanDefinitionBuilder builder) {
Map<QName, Object> annotations = new HashMap<>();
if (element == null) {
return annotations;
} else {
if (Component.class.isAssignableFrom(builder.getBeanDefinition().getBeanClass())) {
XmlMetadataAnnotations elementMetadata = (XmlMetadataAnnotations) element.getUserData("metadataAnnotations");
addMetadataAnnotationsFromXml(annotations, elementMetadata.getElementString());
builder.getBeanDefinition().getPropertyValues().addPropertyValue("annotations", annotations);
}
return annotations;
}
}
Aggregations