Skip to content

Commit

Permalink
Merge pull request quarkusio#26660 from gsmet/jackson-priority-ordering
Browse files Browse the repository at this point in the history
Use @ALL to inject ObjectMapperCustomizers
  • Loading branch information
gsmet authored Jul 11, 2022
2 parents b01ec42 + 17c0497 commit 864e707
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 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
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.quarkus.jsonb;

import java.util.List;

import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.Produces;
import javax.inject.Singleton;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;

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

@Singleton
Expand All @@ -16,7 +18,7 @@ public class JsonbProducer {
@Produces
@Dependent //JsonbConfig is not thread safe so it must not be made singleton.
@DefaultBean
public JsonbConfig jsonbConfig(Instance<JsonbConfigCustomizer> customizers) {
public JsonbConfig jsonbConfig(@All List<JsonbConfigCustomizer> customizers) {
JsonbConfig jsonbConfig = new JsonbConfig();
for (JsonbConfigCustomizer customizer : customizers) {
customizer.customize(jsonbConfig);
Expand Down

0 comments on commit 864e707

Please sign in to comment.