Class ReactiveHandlersBeanPostProcessor

java.lang.Object
dk.cloudcreate.essentials.reactive.spring.ReactiveHandlersBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.context.ApplicationContextAware

public class ReactiveHandlersBeanPostProcessor extends Object implements org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.context.ApplicationContextAware
When using Spring or Spring Boot it will be easier to register the EventBus, CommandBus, CommandHandler and EventHandler instances as @Bean or @Component and automatically have the CommandHandler beans registered as with the single CommandBus bean and the EventHandler beans registered as subscribers with one or more EventBus beans.
All you need to do is to add a @Bean of type ReactiveHandlersBeanPostProcessor which: Registers CommandHandler or EventHandler's in the application context with the single EventBus's and CommandBus defined in the application context.
EventHandler's are registered as synchronous event handler's (EventBus.addSyncSubscriber(EventHandler)) unless it's annotated with the AsyncEventHandler annotation, in which case it's registered as an asynchronous event handler (EventBus.addAsyncSubscriber(EventHandler)
  • Constructor Details

    • ReactiveHandlersBeanPostProcessor

      public ReactiveHandlersBeanPostProcessor()
  • Method Details

    • postProcessAfterInitialization

      public Object postProcessAfterInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
      Specified by:
      postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • postProcessBeforeDestruction

      public void postProcessBeforeDestruction(Object bean, String beanName) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • requiresDestruction

      public boolean requiresDestruction(Object bean)
      Specified by:
      requiresDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException