use of org.springframework.beans.factory.support.ManagedSet in project spring-framework by spring-projects.
the class BeanDefinitionParserDelegate method parseSetElement.
/**
* Parse a set element.
*/
public Set<Object> parseSetElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedSet<Object> target = new ManagedSet<>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
use of org.springframework.beans.factory.support.ManagedSet in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterParser method getInititalEntityClasses.
private static Set<String> getInititalEntityClasses(Element element) {
String basePackage = element.getAttribute(BASE_PACKAGE);
if (!StringUtils.hasText(basePackage)) {
return null;
}
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
Set<String> classes = new ManagedSet<String>();
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
classes.add(candidate.getBeanClassName());
}
return classes;
}
use of org.springframework.beans.factory.support.ManagedSet in project spring-integration by spring-projects.
the class MessageHistoryRegistrar method registerBeanDefinitions.
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(EnableMessageHistory.class.getName());
Object componentNamePatterns = annotationAttributes.get("value");
if (componentNamePatterns instanceof String[]) {
StringBuilder componentNamePatternsString = new StringBuilder();
for (String s : (String[]) componentNamePatterns) {
componentNamePatternsString.append(s).append(",");
}
componentNamePatterns = componentNamePatternsString.substring(0, componentNamePatternsString.length() - 1);
}
if (!registry.containsBeanDefinition(IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME)) {
Set<Object> componentNamePatternsSet = new ManagedSet<Object>();
componentNamePatternsSet.add(componentNamePatterns);
AbstractBeanDefinition messageHistoryConfigurer = BeanDefinitionBuilder.genericBeanDefinition(MessageHistoryConfigurer.class).addPropertyValue("componentNamePatternsSet", componentNamePatternsSet).getBeanDefinition();
registry.registerBeanDefinition(IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME, messageHistoryConfigurer);
} else {
BeanDefinition beanDefinition = registry.getBeanDefinition(IntegrationContextUtils.INTEGRATION_MESSAGE_HISTORY_CONFIGURER_BEAN_NAME);
PropertyValue propertyValue = beanDefinition.getPropertyValues().getPropertyValue("componentNamePatternsSet");
if (propertyValue != null) {
@SuppressWarnings("unchecked") Set<Object> currentComponentNamePatternsSet = (Set<Object>) propertyValue.getValue();
currentComponentNamePatternsSet.add(componentNamePatterns);
} else {
Set<Object> componentNamePatternsSet = new ManagedSet<Object>();
componentNamePatternsSet.add(componentNamePatterns);
beanDefinition.getPropertyValues().addPropertyValue("componentNamePatternsSet", componentNamePatternsSet);
}
}
}
use of org.springframework.beans.factory.support.ManagedSet in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterParser method getInitialEntityClasses.
@Nullable
private static Set<String> getInitialEntityClasses(Element element) {
String basePackage = element.getAttribute(BASE_PACKAGE);
if (!StringUtils.hasText(basePackage)) {
return null;
}
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
Set<String> classes = new ManagedSet<>();
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
classes.add(candidate.getBeanClassName());
}
return classes;
}
use of org.springframework.beans.factory.support.ManagedSet in project spring-integration by spring-projects.
the class IntegrationConverterInitializer method registerConverter.
@SuppressWarnings("unchecked")
public void registerConverter(BeanDefinitionRegistry registry, BeanMetadataElement converterBeanDefinition) {
Set<BeanMetadataElement> converters = new ManagedSet<BeanMetadataElement>();
if (!registry.containsBeanDefinition(IntegrationContextUtils.CONVERTER_REGISTRAR_BEAN_NAME)) {
BeanDefinitionBuilder converterRegistrarBuilder = BeanDefinitionBuilder.genericBeanDefinition(CONTEXT_PACKAGE + "ConverterRegistrar").addConstructorArgValue(converters);
registry.registerBeanDefinition(IntegrationContextUtils.CONVERTER_REGISTRAR_BEAN_NAME, converterRegistrarBuilder.getBeanDefinition());
if (!registry.containsBeanDefinition(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME)) {
registry.registerBeanDefinition(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, new RootBeanDefinition(CONTEXT_PACKAGE + "CustomConversionServiceFactoryBean"));
}
} else {
BeanDefinition converterRegistrarBeanDefinition = registry.getBeanDefinition(IntegrationContextUtils.CONVERTER_REGISTRAR_BEAN_NAME);
converters = (Set<BeanMetadataElement>) converterRegistrarBeanDefinition.getConstructorArgumentValues().getIndexedArgumentValues().values().iterator().next().getValue();
}
converters.add(converterBeanDefinition);
}
Aggregations