Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @All to inject ObjectMapperCustomizers #26660

Merged
merged 2 commits into from Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
@@ -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