/** * Configures a rule to assign Event Handler beans that match the given {@code criteria} to the Processing Group * with given {@code name}, with neutral priority (value 0). * <p> * Note that, when beans match multiple criteria for different Processing Groups with equal priority, the outcome is * undefined. * * @param processingGroup a {@link String} specifying the name of a processing group to assign matching Event * Handlers or Sagas to * @param criteria a {@link Predicate} defining the criteria for an Event Handler or Saga to match * @return the current {@link EventProcessingConfigurer} instance, for fluent interfacing */ default EventProcessingConfigurer assignHandlerTypesMatching(String processingGroup, Predicate<Class<?>> criteria) { return assignHandlerTypesMatching(processingGroup, 0, criteria); }
@SuppressWarnings("unchecked") private void registerSagaBeanDefinitions(EventProcessingConfigurer configurer) { String[] sagas = beanFactory.getBeanNamesForAnnotation(Saga.class); for (String saga : sagas) { Saga sagaAnnotation = beanFactory.findAnnotationOnBean(saga, Saga.class); Class sagaType = beanFactory.getType(saga); ProcessingGroup processingGroupAnnotation = beanFactory.findAnnotationOnBean(saga, ProcessingGroup.class); if (processingGroupAnnotation != null && !"".equals(processingGroupAnnotation.value())) { configurer.assignHandlerTypesMatching(processingGroupAnnotation.value(), sagaType::equals); } configurer.registerSaga(sagaType, sagaConfigurer -> { if (sagaAnnotation != null && !"".equals(sagaAnnotation.sagaStore())) { sagaConfigurer.configureSagaStore(c -> beanFactory.getBean(sagaAnnotation.sagaStore(), SagaStore.class)); } }); } }
/** * Configures a rule to assign Event Handler beans that match the given {@code criteria} to the Processing Group * with given {@code name}, with neutral priority (value 0). * <p> * Note that, when beans match multiple criteria for different Processing Groups with equal priority, the outcome is * undefined. * * @param processingGroup a {@link String} specifying the name of a processing group to assign matching Event * Handlers or Sagas to * @param criteria a {@link Predicate} defining the criteria for an Event Handler or Saga to match * @return the current {@link EventProcessingConfigurer} instance, for fluent interfacing */ default EventProcessingConfigurer assignHandlerTypesMatching(String processingGroup, Predicate<Class<?>> criteria) { return assignHandlerTypesMatching(processingGroup, 0, criteria); }