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-security by spring-projects.
the class HttpConfigurationBuilder method parseInterceptUrlsForChannelSecurity.
/**
* Parses the intercept-url elements to obtain the map used by channel security. This
* will be empty unless the <tt>requires-channel</tt> attribute has been used on a URL
* path.
*/
private ManagedMap<BeanMetadataElement, BeanDefinition> parseInterceptUrlsForChannelSecurity() {
ManagedMap<BeanMetadataElement, BeanDefinition> channelRequestMap = new ManagedMap<>();
for (Element urlElt : this.interceptUrls) {
String path = urlElt.getAttribute(HttpSecurityBeanDefinitionParser.ATT_PATH_PATTERN);
String method = urlElt.getAttribute(HttpSecurityBeanDefinitionParser.ATT_HTTP_METHOD);
String matcherRef = urlElt.getAttribute(HttpSecurityBeanDefinitionParser.ATT_REQUEST_MATCHER_REF);
boolean hasMatcherRef = StringUtils.hasText(matcherRef);
if (!hasMatcherRef && !StringUtils.hasText(path)) {
this.pc.getReaderContext().error("pattern attribute cannot be empty or null", urlElt);
}
String requiredChannel = urlElt.getAttribute(HttpSecurityBeanDefinitionParser.ATT_REQUIRES_CHANNEL);
if (StringUtils.hasText(requiredChannel)) {
BeanMetadataElement matcher = hasMatcherRef ? new RuntimeBeanReference(matcherRef) : this.matcherType.createMatcher(this.pc, path, method);
RootBeanDefinition channelAttributes = new RootBeanDefinition(ChannelAttributeFactory.class);
channelAttributes.getConstructorArgumentValues().addGenericArgumentValue(requiredChannel);
channelAttributes.setFactoryMethodName("createChannelAttributes");
channelRequestMap.put(matcher, channelAttributes);
}
}
return channelRequestMap;
}
use of org.springframework.beans.factory.support.ManagedMap in project spring-security by spring-projects.
the class CsrfBeanDefinitionParser method createAccessDeniedHandler.
/**
* Creates the {@link AccessDeniedHandler} from the result of
* {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} and
* {@link #getInvalidSessionStrategy(HttpSecurityBuilder)}. If
* {@link #getInvalidSessionStrategy(HttpSecurityBuilder)} is non-null, then a
* {@link DelegatingAccessDeniedHandler} is used in combination with
* {@link InvalidSessionAccessDeniedHandler} and the
* {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)}. Otherwise, only
* {@link #getDefaultAccessDeniedHandler(HttpSecurityBuilder)} is used.
* @param invalidSessionStrategy the {@link InvalidSessionStrategy} to use
* @param defaultDeniedHandler the {@link AccessDeniedHandler} to use
* @return the {@link BeanMetadataElement} that is the {@link AccessDeniedHandler} to
* populate on the {@link CsrfFilter}
*/
private BeanMetadataElement createAccessDeniedHandler(BeanDefinition invalidSessionStrategy, BeanMetadataElement defaultDeniedHandler) {
if (invalidSessionStrategy == null) {
return defaultDeniedHandler;
}
ManagedMap<Class<? extends AccessDeniedException>, BeanDefinition> handlers = new ManagedMap<>();
BeanDefinitionBuilder invalidSessionHandlerBldr = BeanDefinitionBuilder.rootBeanDefinition(InvalidSessionAccessDeniedHandler.class);
invalidSessionHandlerBldr.addConstructorArgValue(invalidSessionStrategy);
handlers.put(MissingCsrfTokenException.class, invalidSessionHandlerBldr.getBeanDefinition());
BeanDefinitionBuilder deniedBldr = BeanDefinitionBuilder.rootBeanDefinition(DelegatingAccessDeniedHandler.class);
deniedBldr.addConstructorArgValue(handlers);
deniedBldr.addConstructorArgValue(defaultDeniedHandler);
return deniedBldr.getBeanDefinition();
}
Aggregations