Skip to content

Commit

Permalink
Refactorings and improvements to OccurrentMongoAutoConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhaleby committed Dec 22, 2023
1 parent 1ef32ea commit 95403c4
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.occurrent.subscription.mongodb.spring.blocking.SpringMongoSubscriptionModel;
import org.occurrent.subscription.mongodb.spring.blocking.SpringMongoSubscriptionPositionStorage;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
Expand Down Expand Up @@ -116,16 +117,16 @@ public SubscriptionModel occurrentCompetingDurableSubscriptionModel(MongoTemplat

@Bean
@ConditionalOnMissingBean(CloudEventConverter.class)
public CloudEventConverter<E> occurrentCloudEventConverter(Optional<ObjectMapper> objectMapper, OccurrentProperties occurrentProperties, Optional<CloudEventTypeMapper<E>> cloudEventTypeMapper) {
@ConditionalOnBean(CloudEventTypeMapper.class)
public CloudEventConverter<E> occurrentCloudEventConverter(Optional<ObjectMapper> objectMapper, OccurrentProperties occurrentProperties, CloudEventTypeMapper<E> cloudEventTypeMapper) {
ObjectMapper om = objectMapper.orElseGet(ObjectMapper::new);
CloudEventTypeMapper<E> cm = cloudEventTypeMapper.orElseGet(this::newDefaultCloudEventTypeMapper);
return new JacksonCloudEventConverter.Builder<E>(om, occurrentProperties.getCloudEventConverter().getCloudEventSource())
.typeMapper(cm)
.typeMapper(cloudEventTypeMapper)
.build();
}

@Bean
@ConditionalOnMissingBean(CloudEventTypeMapper.class)
@ConditionalOnMissingBean({CloudEventTypeMapper.class, CloudEventConverter.class})
public CloudEventTypeMapper<E> occurrentTypeMapper() {
return newDefaultCloudEventTypeMapper();
}
Expand Down

0 comments on commit 95403c4

Please sign in to comment.