use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-integration by spring-projects.
the class ConverterParser method parseInternal.
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionRegistry registry = parserContext.getRegistry();
BeanComponentDefinition converterDefinition = IntegrationNamespaceUtils.parseInnerHandlerDefinition(element, parserContext);
if (converterDefinition != null) {
INTEGRATION_CONVERTER_INITIALIZER.registerConverter(registry, converterDefinition);
} else {
String beanName = element.getAttribute("ref");
Assert.isTrue(StringUtils.hasText(beanName), "Either a 'ref' attribute pointing to a Converter or a <bean> sub-element defining a Converter is required.");
INTEGRATION_CONVERTER_INITIALIZER.registerConverter(registry, new RuntimeBeanReference(beanName));
}
return null;
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-integration by spring-projects.
the class FixedSubscriberChannelBeanFactoryPostProcessor method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
if (this.candidateFixedChannelHandlerMap.size() > 0) {
for (Entry<String, String> entry : this.candidateFixedChannelHandlerMap.entrySet()) {
String handlerName = entry.getKey();
String channelName = entry.getValue();
BeanDefinition handlerBeanDefinition = null;
if (registry.containsBeanDefinition(handlerName)) {
handlerBeanDefinition = registry.getBeanDefinition(handlerName);
}
if (handlerBeanDefinition != null && registry.containsBeanDefinition(channelName)) {
BeanDefinition inputChannelDefinition = registry.getBeanDefinition(channelName);
if (FixedSubscriberChannel.class.getName().equals(inputChannelDefinition.getBeanClassName())) {
ConstructorArgumentValues constructorArgumentValues = inputChannelDefinition.getConstructorArgumentValues();
Assert.isTrue(constructorArgumentValues.isEmpty(), "Only one subscriber is allowed for a FixedSubscriberChannel.");
constructorArgumentValues.addGenericArgumentValue(handlerBeanDefinition);
}
}
}
}
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-integration by spring-projects.
the class IntegrationConverterInitializer method initialize.
@Override
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
for (String beanName : registry.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
if (beanDefinition instanceof AnnotatedBeanDefinition) {
AnnotationMetadata metadata = ((AnnotatedBeanDefinition) beanDefinition).getMetadata();
boolean hasIntegrationConverter = metadata.hasAnnotation(IntegrationConverter.class.getName());
if (!hasIntegrationConverter && beanDefinition.getSource() instanceof MethodMetadata) {
MethodMetadata beanMethod = (MethodMetadata) beanDefinition.getSource();
hasIntegrationConverter = beanMethod.isAnnotated(IntegrationConverter.class.getName());
}
if (hasIntegrationConverter) {
this.registerConverter(registry, new RuntimeBeanReference(beanName));
}
}
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-integration by spring-projects.
the class DslIntegrationConfigurationInitializer method initialize.
@Override
public void initialize(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
Assert.isInstanceOf(BeanDefinitionRegistry.class, configurableListableBeanFactory, "To use Spring Integration Java DSL the 'beanFactory' has to be an instance of " + "'BeanDefinitionRegistry'. Consider using 'GenericApplicationContext' implementation.");
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) configurableListableBeanFactory;
if (!registry.containsBeanDefinition(INTEGRATION_FLOW_BPP_BEAN_NAME)) {
registry.registerBeanDefinition(INTEGRATION_FLOW_BPP_BEAN_NAME, new RootBeanDefinition(IntegrationFlowBeanPostProcessor.class));
registry.registerBeanDefinition(INTEGRATION_FLOW_CONTEXT_BEAN_NAME, new RootBeanDefinition(StandardIntegrationFlowContext.class));
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-integration by spring-projects.
the class IntegrationFlowBeanPostProcessor method registerComponent.
@SuppressWarnings("unchecked")
private void registerComponent(Object component, String beanName, String parentName, BeanDefinitionCustomizer... customizers) {
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition((Class<Object>) component.getClass(), () -> component).applyCustomizers(customizers).getRawBeanDefinition();
((BeanDefinitionRegistry) this.beanFactory).registerBeanDefinition(beanName, beanDefinition);
if (parentName != null) {
this.beanFactory.registerDependentBean(parentName, beanName);
}
this.beanFactory.getBean(beanName);
}
Aggregations