Commit ce4f6e9
authored
create JsonMapper.Builder as prototype bean (#12239)
* create JsonMapper.Builder as prototype bean
This could allow to register for example filter providers in Jackson 3:
```
package io.micronaut.serde.tck.jackson.databind;
import io.micronaut.context.event.BeanCreatedEvent;
import io.micronaut.context.event.BeanCreatedEventListener;
import org.jspecify.annotations.NonNull;
import jakarta.inject.Singleton;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.ser.std.SimpleFilterProvider;
@singleton
public class JsonsMapperBeanCreatedEventListener implements BeanCreatedEventListener<JsonMapper.Builder> {
private final DatabindPredicateFilter predicateFilter;
public JsonsMapperBeanCreatedEventListener(DatabindPredicateFilter predicateFilter) {
this.predicateFilter = predicateFilter;
}
@OverRide
public JsonMapper.Builder onCreated(@nonnull BeanCreatedEvent<JsonMapper.Builder> event) {
JsonMapper.Builder builder = event.getBean();
SimpleFilterProvider filterProvider = new SimpleFilterProvider();
filterProvider.addFilter("ignore-value", predicateFilter);
builder.filterProvider(filterProvider);
return builder;
}
}
```
* JsonMapper.Builder
* fix checkstyleMain
* annotate also builder with @BootstrapContextCompatible1 parent 6093fb2 commit ce4f6e9
File tree
4 files changed
+24
-11
lines changed- jackson-databind/src
- main/java/io/micronaut/jackson
- databind
- test/groovy/io/micronaut
- jackson/serialize
- json
4 files changed
+24
-11
lines changedLines changed: 21 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
| 134 | + | |
134 | 135 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 136 | + | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
| |||
261 | 274 | | |
262 | 275 | | |
263 | 276 | | |
264 | | - | |
| 277 | + | |
265 | 278 | | |
266 | 279 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
jackson-databind/src/test/groovy/io/micronaut/jackson/serialize/JacksonObjectSerializerSpec.groovy
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments