Class MicronautJsonbProvider.MicronautJsonb
java.lang.Object
io.micronaut.serde.jsonb.MicronautJsonbProvider.MicronautJsonb
- All Implemented Interfaces:
jakarta.json.bind.Jsonb, AutoCloseable
- Enclosing class:
MicronautJsonbProvider
protected static class MicronautJsonbProvider.MicronautJsonb
extends Object
implements jakarta.json.bind.Jsonb
- Since:
- 3.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final Charsetprotected final tools.jackson.core.json.JsonFactoryprotected final ObjectMapperprotected final booleanprotected final SerdeRegistryprotected final @Nullable SerdeConfigurationprotected final boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper mapper, @Nullable SerdeConfiguration serdeConfiguration, Runnable closeAction) protectedMicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper objectMapper, SerdeConfiguration serdeConfiguration, SerializationConfiguration serializationConfiguration, DeserializationConfiguration deserializationConfiguration) protectedMicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper mapper, Runnable closeAction) protectedMicronautJsonb(jakarta.json.bind.JsonbConfig config, @Nullable jakarta.json.spi.JsonProvider jsonProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected static String[]additionalPackages(jakarta.json.bind.JsonbConfig config) protected static io.micronaut.core.type.Argument<?> protected static StringbinaryDataStrategy(jakarta.json.bind.JsonbConfig config) protected <T> booleancanCreateGeneratedDeserializer(io.micronaut.core.type.Argument<T> argument) Checks whether a generated deserializer can be created for the argument.protected <T> booleancanCreateGeneratedSerializer(io.micronaut.core.type.Argument<T> argument) Checks whether a generated serializer can be created for the argument.protected static Charsetcharset(jakarta.json.bind.JsonbConfig config) voidclose()protected voidEnsures reflection-only JSON-B features are not used by the generated provider.<T> @Nullable TfromJson(InputStream stream, Class<T> type) <T> @Nullable TfromJson(InputStream stream, Type runtimeType) <T> @Nullable T<T> @Nullable T<T> @Nullable T<T> @Nullable Tprotected static <K,V> ConcurrentMap <K, V> Creates a bounded cache for per-mapper generated Serde capability checks.protected static booleanisJsonScalar(Class<?> type) protected final LimitingStream.RemainingLimitslimits()mappedPropertyNamingStrategy(jakarta.json.bind.JsonbConfig config) properties(jakarta.json.bind.JsonbConfig config) protected static StringpropertyOrderStrategy(jakarta.json.bind.JsonbConfig config) protected <T> @Nullable TreadGenerated(io.micronaut.core.type.Argument<T> argument, MicronautJsonbProvider.ParserSource parserSource) Reads JSON from a parser source with the generated deserializer for the supplied argument.protected <T> @Nullable TreadReader(Reader reader, io.micronaut.core.type.Argument<T> argument) Reads JSON from a reader through the generated deserializer path.protected <T> @Nullable TreadStream(InputStream stream, io.micronaut.core.type.Argument<T> argument) Reads JSON from a stream through the generated deserializer path.protected <T> @Nullable TreadString(String str, io.micronaut.core.type.Argument<T> argument) Reads a JSON string through the generated deserializer path.voidtoJson(Object object, OutputStream stream) voidvoidtoJson(Object object, Type runtimeType, OutputStream stream) voidprotected voidvalidateStrictTopLevel(@Nullable Object object) Validates strict I-JSON top-level constraints before writing.protected <T> voidwriteGenerated(@Nullable T object, io.micronaut.core.type.Argument<T> argument, MicronautJsonbProvider.GeneratorSource generatorSource) Writes JSON through the generated serializer path.
-
Field Details
-
mapper
-
registry
-
jsonFactory
protected final tools.jackson.core.json.JsonFactory jsonFactory -
charset
-
prettyPrint
protected final boolean prettyPrint -
strictIJson
protected final boolean strictIJson -
binaryDataStrategy
-
serdeConfiguration
-
-
Constructor Details
-
MicronautJsonb
protected MicronautJsonb(jakarta.json.bind.JsonbConfig config, @Nullable jakarta.json.spi.JsonProvider jsonProvider) -
MicronautJsonb
protected MicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper objectMapper, SerdeConfiguration serdeConfiguration, SerializationConfiguration serializationConfiguration, DeserializationConfiguration deserializationConfiguration) -
MicronautJsonb
protected MicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper mapper, Runnable closeAction) -
MicronautJsonb
protected MicronautJsonb(jakarta.json.bind.JsonbConfig config, ObjectMapper mapper, @Nullable SerdeConfiguration serdeConfiguration, Runnable closeAction)
-
-
Method Details
-
generatedSerdeCache
Creates a bounded cache for per-mapper generated Serde capability checks. The cache is intentionally small because it protects hot reflection-provider routing paths, not application domain data.- Type Parameters:
K- The cache key typeV- The cache value type- Returns:
- A concurrent bounded cache
-
fromJson
-
fromJson
-
fromJson
-
fromJson
-
fromJson
public <T> @Nullable T fromJson(InputStream stream, Class<T> type) throws jakarta.json.bind.JsonbException - Specified by:
fromJsonin interfacejakarta.json.bind.Jsonb- Throws:
jakarta.json.bind.JsonbException
-
fromJson
public <T> @Nullable T fromJson(InputStream stream, Type runtimeType) throws jakarta.json.bind.JsonbException - Specified by:
fromJsonin interfacejakarta.json.bind.Jsonb- Throws:
jakarta.json.bind.JsonbException
-
toJson
-
toJson
-
toJson
-
toJson
-
toJson
- Specified by:
toJsonin interfacejakarta.json.bind.Jsonb- Throws:
jakarta.json.bind.JsonbException
-
toJson
public void toJson(Object object, Type runtimeType, OutputStream stream) throws jakarta.json.bind.JsonbException - Specified by:
toJsonin interfacejakarta.json.bind.Jsonb- Throws:
jakarta.json.bind.JsonbException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
readString
Reads a JSON string through the generated deserializer path. Subclasses may override to provide non-generated fallback behavior.- Type Parameters:
T- The target type- Parameters:
str- The JSON stringargument- The target argument- Returns:
- The decoded value
-
readReader
Reads JSON from a reader through the generated deserializer path. Subclasses may override to provide non-generated fallback behavior while preserving streaming reads.- Type Parameters:
T- The target type- Parameters:
reader- The JSON readerargument- The target argument- Returns:
- The decoded value
-
readStream
protected <T> @Nullable T readStream(InputStream stream, io.micronaut.core.type.Argument<T> argument) Reads JSON from a stream through the generated deserializer path. Subclasses may override to provide non-generated fallback behavior while preserving streaming reads.- Type Parameters:
T- The target type- Parameters:
stream- The JSON input streamargument- The target argument- Returns:
- The decoded value
-
readGenerated
protected <T> @Nullable T readGenerated(io.micronaut.core.type.Argument<T> argument, MicronautJsonbProvider.ParserSource parserSource) Reads JSON from a parser source with the generated deserializer for the supplied argument.- Type Parameters:
T- The target type- Parameters:
argument- The target argumentparserSource- The parser source- Returns:
- The decoded value
-
canCreateGeneratedDeserializer
protected <T> boolean canCreateGeneratedDeserializer(io.micronaut.core.type.Argument<T> argument) Checks whether a generated deserializer can be created for the argument.Registry lookup is intentionally cached because negative checks can be exception-heavy when JSON-B reflection fallback probes whether a value may use the generated path directly.
- Type Parameters:
T- The target type- Parameters:
argument- The target argument- Returns:
- Whether the deserializer can be created
-
canCreateGeneratedSerializer
protected <T> boolean canCreateGeneratedSerializer(io.micronaut.core.type.Argument<T> argument) Checks whether a generated serializer can be created for the argument.Registry lookup is intentionally cached because negative checks can be exception-heavy when JSON-B reflection fallback probes whether a value may use the generated path directly.
- Type Parameters:
T- The target type- Parameters:
argument- The target argument- Returns:
- Whether the serializer can be created
-
writeGenerated
protected <T> void writeGenerated(@Nullable T object, io.micronaut.core.type.Argument<T> argument, MicronautJsonbProvider.GeneratorSource generatorSource) throws IOException Writes JSON through the generated serializer path.- Type Parameters:
T- The value type- Parameters:
object- The value to writeargument- The value argumentgeneratorSource- The generator source- Throws:
IOException- If JSON writing fails
-
limits
-
validateStrictTopLevel
Validates strict I-JSON top-level constraints before writing.- Parameters:
object- The value to write
-
ensureGeneratedOnlyFeatures
protected void ensureGeneratedOnlyFeatures()Ensures reflection-only JSON-B features are not used by the generated provider. -
argument
-
properties
-
additionalPackages
-
mappedPropertyNamingStrategy
-
propertyOrderStrategy
-
binaryDataStrategy
-
charset
-
isJsonScalar
-