@Configuration
@RequiredArgsConstructor
@EnableBinding({VendorNotificationEventProducer.class}) # (1)
@EnableConfigurationProperties(VendorNotificationProperties.class)
public class VendorServiceAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public VendorService<Vendor> vendorService(VendorRepository<Trackable> vendorRepository,
TypeFactory typeFactory,
DomainMapperManager mapperManager,
@Autowired(required = false) List<SortTransformer> sortTransformers,
EntityValidatorManager entityValidatorManager,
TrackableBehaviorUtil behaviorUtil,
@Autowired(required = false) List<RsqlQueryTransformer> rsqlQueryTransformers,
@Nullable NotificationManager notificationManager) {
VendorCrudEntityHelper crudEntityHelper = new VendorCrudEntityHelper(mapperManager, # (2)
sortTransformers,
entityValidatorManager,
behaviorUtil);
crudEntityHelper.setNotificationManager(notificationManager);
RsqlCrudEntityHelper helper =
new RsqlCrudEntityHelper(crudEntityHelper, rsqlQueryTransformers);
return new DefaultVendorService<>(vendorRepository,
typeFactory,
helper);
}
@Bean
@ConditionalOnMissingBean(name = "vendorNotificationHandler")
public NotificationHandler vendorNotificationHandler(
VendorNotificationEventProducer producer,
VendorNotificationProperties properties,
List<IgnoredNotificationStateRepository> ignoredRepositories,
PersistenceMessageFactory messageFactory,
MessageSerializationHelper helper) {
return new DefaultNotificationHandler(producer::vendorNotificationOutput, # (3)
properties,
VendorNotificationEventProducer.TYPE,
ignoredRepositories,
messageFactory,
helper);
}
@Bean
@ConditionalOnMissingBean(name = "vendorNotificationRetryClusterService")
public RetryClusterService vendorNotificationRetryClusterService(
CamelClusterService camelClusterService,
VendorNotificationProperties properties,
VendorRepository<?> repository,
@Qualifier("vendorNotificationHandler") NotificationHandler handler,
List<IgnoredNotificationStateRepository> ignoredRepositories,
DataRouteReference reference)
throws Exception {
return RetryServiceFactory.create(camelClusterService, properties, # (4)
Collections.singletonList(repository), handler,
VendorNotificationEventProducer.TYPE,
ignoredRepositories, reference);
}
}
@Configuration
@RequiredArgsConstructor
public class VendorJpaAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "vendorNotificationStateDomainMapperMember")
public DomainMapperMember vendorNotificationStateDomainMapperMember(
NotificationStateService notificationStateService) {
return new VendorNotificationStateMapperMember(notificationStateService); # (5)
}
}