use of org.springframework.beans.factory.config.BeanDefinition in project spring-integration by spring-projects.
the class DefaultConfiguringBeanFactoryPostProcessor method registerTaskScheduler.
/**
* Register a TaskScheduler in the given BeanDefinitionRegistry.
*/
private void registerTaskScheduler(BeanDefinitionRegistry registry) {
if (this.logger.isInfoEnabled()) {
this.logger.info("No bean named '" + IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME + "' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.");
}
BeanDefinition scheduler = BeanDefinitionBuilder.genericBeanDefinition(ThreadPoolTaskScheduler.class).addPropertyValue("poolSize", IntegrationProperties.getExpressionFor(IntegrationProperties.TASK_SCHEDULER_POOL_SIZE)).addPropertyValue("threadNamePrefix", "task-scheduler-").addPropertyValue("rejectedExecutionHandler", new CallerRunsPolicy()).addPropertyValue("errorHandler", new RootBeanDefinition(MessagePublishingErrorHandler.class)).getBeanDefinition();
registry.registerBeanDefinition(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, scheduler);
}
use of org.springframework.beans.factory.config.BeanDefinition in project spring-integration by spring-projects.
the class DefaultConfiguringBeanFactoryPostProcessor method registerInfrastructureBean.
private void registerInfrastructureBean(BeanDefinitionRegistry registry, String className) {
String[] definitionNames = registry.getBeanDefinitionNames();
for (String definitionName : definitionNames) {
BeanDefinition definition = registry.getBeanDefinition(definitionName);
if (className.equals(definition.getBeanClassName())) {
if (this.logger.isInfoEnabled()) {
this.logger.info(className + " is already registered and will be used");
}
return;
}
}
RootBeanDefinition beanDefinition = new RootBeanDefinition(className);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, registry);
}
use of org.springframework.beans.factory.config.BeanDefinition in project spring-integration by spring-projects.
the class DefaultConfiguringBeanFactoryPostProcessor method registerNullChannel.
/**
* Register a null channel in the given BeanDefinitionRegistry. The bean name is defined by the constant
* {@link IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME}.
*/
private void registerNullChannel(BeanDefinitionRegistry registry) {
if (registry.containsBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)) {
BeanDefinition nullChannelDefinition = registry.getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
if (NullChannel.class.getName().equals(nullChannelDefinition.getBeanClassName())) {
return;
} else {
throw new IllegalStateException("The bean name '" + IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME + "' is reserved.");
}
} else {
RootBeanDefinition nullChannelDef = new RootBeanDefinition();
nullChannelDef.setBeanClassName(IntegrationConfigUtils.BASE_PACKAGE + ".channel.NullChannel");
BeanDefinitionHolder nullChannelHolder = new BeanDefinitionHolder(nullChannelDef, IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
BeanDefinitionReaderUtils.registerBeanDefinition(nullChannelHolder, registry);
}
}
use of org.springframework.beans.factory.config.BeanDefinition 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.config.BeanDefinition 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));
}
}
}
}
Aggregations