org.axonframework.spring.config.MessageHandlerSubscriberDefinitionRegistrar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axon-spring Show documentation
Show all versions of axon-spring Show documentation
Module providing Spring specific helper functionality to ease configuration / set-up of an Axon application, as
well as some Spring specific infrastructure components.
package org.axonframework.spring.config;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.MultiValueMap;
/**
* @author Allard Buijze
*/
public class MessageHandlerSubscriberDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
MultiValueMap attributes = metadata
.getAllAnnotationAttributes(EnableHandlerSubscription.class.getName());
if (Boolean.TRUE.equals(attributes.getFirst("subscribeEventProcessors"))
|| Boolean.TRUE.equals(attributes.getFirst("subscribeEventListeners"))) {
final GenericBeanDefinition definition = new GenericBeanDefinition();
//definition.setBeanClass(EventListenerSubscriber.class);
final Object eventBusRef = attributes.getFirst("eventBus");
if (!"".equals(eventBusRef)) {
definition.getPropertyValues().add("eventBus",
new RuntimeBeanReference((String) eventBusRef));
}
registry.registerBeanDefinition("EventListenerSubscriber", definition);
}
if (Boolean.TRUE.equals(attributes.getFirst("subscribeCommandHandlers"))) {
final GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(CommandHandlerSubscriber.class);
registry.registerBeanDefinition("CommandHandlerSubscriber", definition);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy