Skip to content

Commit

Permalink
Use @ALL to inject ObjectMapperCustomizers
Browse files Browse the repository at this point in the history
This way, we are sure they are sorted by @priority.
And they can still be sorted by #getPriority(), this hasn't changed.
  • Loading branch information
gsmet committed Jul 11, 2022
1 parent 0025aff commit de2bbb2
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.TimeZone;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;

Expand All @@ -17,6 +16,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import io.quarkus.arc.All;
import io.quarkus.arc.DefaultBean;
import io.quarkus.jackson.ObjectMapperCustomizer;

Expand All @@ -26,7 +26,7 @@ public class ObjectMapperProducer {
@DefaultBean
@Singleton
@Produces
public ObjectMapper objectMapper(Instance<ObjectMapperCustomizer> customizers,
public ObjectMapper objectMapper(@All List<ObjectMapperCustomizer> customizers,
JacksonBuildTimeConfig jacksonBuildTimeConfig) {
ObjectMapper objectMapper = new ObjectMapper();
if (!jacksonBuildTimeConfig.failOnUnknownProperties) {
Expand Down Expand Up @@ -60,7 +60,7 @@ public ObjectMapper objectMapper(Instance<ObjectMapperCustomizer> customizers,
}

private List<ObjectMapperCustomizer> sortCustomizersInDescendingPriorityOrder(
Instance<ObjectMapperCustomizer> customizers) {
Iterable<ObjectMapperCustomizer> customizers) {
List<ObjectMapperCustomizer> sortedCustomizers = new ArrayList<>();
for (ObjectMapperCustomizer customizer : customizers) {
sortedCustomizers.add(customizer);
Expand Down

0 comments on commit de2bbb2

Please sign in to comment.