use of org.springframework.beans.factory.support.ManagedMap in project sharding-jdbc by shardingjdbc.
the class ShardingDataSourceBeanDefinitionParser method parseDataSources.
private Map<String, RuntimeBeanReference> parseDataSources(final Element element) {
Element shardingRuleElement = DomUtils.getChildElementByTagName(element, ShardingDataSourceBeanDefinitionParserTag.SHARDING_RULE_CONFIG_TAG);
List<String> dataSources = Splitter.on(",").trimResults().splitToList(shardingRuleElement.getAttribute(ShardingDataSourceBeanDefinitionParserTag.DATA_SOURCE_NAMES_TAG));
Map<String, RuntimeBeanReference> result = new ManagedMap<>(dataSources.size());
for (String each : dataSources) {
result.put(each, new RuntimeBeanReference(each));
}
return result;
}
use of org.springframework.beans.factory.support.ManagedMap in project sharding-jdbc by shardingjdbc.
the class OrchestrationShardingDataSourceBeanDefinitionParser method parseDataSources.
private Map<String, RuntimeBeanReference> parseDataSources(final Element element) {
Element shardingRuleElement = DomUtils.getChildElementByTagName(element, ShardingDataSourceBeanDefinitionParserTag.SHARDING_RULE_CONFIG_TAG);
List<String> dataSources = Splitter.on(",").trimResults().splitToList(shardingRuleElement.getAttribute(ShardingDataSourceBeanDefinitionParserTag.DATA_SOURCE_NAMES_TAG));
Map<String, RuntimeBeanReference> result = new ManagedMap<>(dataSources.size());
for (String each : dataSources) {
result.put(each, new RuntimeBeanReference(each));
}
return result;
}
use of org.springframework.beans.factory.support.ManagedMap in project mule by mulesoft.
the class PropertyComponentUtils method getPropertyValueFromPropertyComponent.
/**
* Creates a {@link Pair} from a generic property/ies component in the configuration.
*
* @param propertyComponentModel the component model for spring:property, spring:properties or property.
* @return a {@code PropertyValue} with the parsed content of the component.
*/
public static Pair<String, Object> getPropertyValueFromPropertyComponent(ComponentModel propertyComponentModel) {
Pair<String, Object> propertyValue;
String refKey = getReferenceAttributeName(propertyComponentModel.getIdentifier());
String nameKey = getNameAttributeName(propertyComponentModel.getIdentifier());
if (propertyComponentModel.getInnerComponents().isEmpty()) {
Object value;
if (propertyComponentModel.getParameters().containsKey(refKey)) {
value = new RuntimeBeanReference(propertyComponentModel.getParameters().get(refKey));
} else {
value = propertyComponentModel.getParameters().get(VALUE_PARAMETER_NAME);
}
if (!propertyComponentModel.getParameters().containsKey(nameKey)) {
propertyValue = new Pair<>(PROPERTY_NAME_PROPERTY_ATTRIBUTE, new RuntimeBeanReference(propertyComponentModel.getParameters().get("ref")));
} else {
propertyValue = new Pair<>(propertyComponentModel.getParameters().get(nameKey), value);
}
} else if (propertyComponentModel.getInnerComponents().get(0).getIdentifier().getName().equals("map")) {
ComponentModel springMap = propertyComponentModel.getInnerComponents().get(0);
ManagedMap<String, Object> propertiesMap = new ManagedMap<>();
springMap.getInnerComponents().stream().forEach(mapEntry -> {
Object value;
if (mapEntry.getParameters().containsKey(VALUE_PARAMETER_NAME)) {
value = mapEntry.getParameters().get(VALUE_PARAMETER_NAME);
} else {
value = new RuntimeBeanReference(mapEntry.getParameters().get(REFERENCE_MULE_PROPERTY_ATTRIBUTE));
}
propertiesMap.put(mapEntry.getParameters().get(PROPERTY_NAME_MULE_PROPERTY_ATTRIBUTE), value);
});
propertyValue = new Pair<>(propertyComponentModel.getNameAttribute(), propertiesMap);
} else {
throw new MuleRuntimeException(createStaticMessage("Unrecognized property model identifier: " + propertyComponentModel.getInnerComponents().get(0).getIdentifier()));
}
return propertyValue;
}
use of org.springframework.beans.factory.support.ManagedMap in project spring-integration by spring-projects.
the class DefaultRouterParser method postProcess.
@Override
protected void postProcess(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
List<Element> mappingElements = DomUtils.getChildElementsByTagName(element, "mapping");
if (!CollectionUtils.isEmpty(mappingElements)) {
ManagedMap<String, String> channelMappings = new ManagedMap<String, String>();
for (Element mappingElement : mappingElements) {
channelMappings.put(mappingElement.getAttribute("value"), mappingElement.getAttribute("channel"));
}
builder.addPropertyValue("channelMappings", channelMappings);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "default-output-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "timeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "resolution-required");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "apply-sequence");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-send-failures");
}
use of org.springframework.beans.factory.support.ManagedMap in project spring-integration by spring-projects.
the class EnricherParser method propertySubElements.
private void propertySubElements(Element element, ParserContext parserContext, final BeanDefinitionBuilder builder) {
List<Element> subElements = DomUtils.getChildElementsByTagName(element, "property");
if (!CollectionUtils.isEmpty(subElements)) {
ManagedMap<String, Object> expressions = new ManagedMap<String, Object>();
ManagedMap<String, Object> nullResultExpressions = new ManagedMap<String, Object>();
for (Element subElement : subElements) {
String name = subElement.getAttribute("name");
String value = subElement.getAttribute("value");
String type = subElement.getAttribute(TYPE_ATTRIBUTE);
String expression = subElement.getAttribute(EXPRESSION_ATTRIBUTE);
String nullResultExpression = subElement.getAttribute("null-result-expression");
boolean hasAttributeValue = StringUtils.hasText(value);
boolean hasAttributeExpression = StringUtils.hasText(expression);
boolean hasAttributeNullResultExpression = StringUtils.hasText(nullResultExpression);
if (hasAttributeValue && hasAttributeExpression) {
parserContext.getReaderContext().error("Only one of 'value' or 'expression' is allowed", element);
}
if (!hasAttributeValue && !hasAttributeExpression && !hasAttributeNullResultExpression) {
parserContext.getReaderContext().error("One of 'value' or 'expression' or 'null-result-expression' is required", element);
}
expression(element, parserContext, expressions, nullResultExpressions, name, value, type, expression, nullResultExpression, hasAttributeValue, hasAttributeExpression, hasAttributeNullResultExpression);
}
if (expressions.size() > 0) {
builder.addPropertyValue("propertyExpressions", expressions);
}
if (nullResultExpressions.size() > 0) {
builder.addPropertyValue("nullResultPropertyExpressions", nullResultExpressions);
}
}
}
Aggregations