Top Description Inners Fields Constructors Methods
org.springframework.http.codec.support

pack-priv abstract Class BaseCodecConfigurer

extends Object
implements CodecConfigurer
Class Inheritance
All Implemented Interfaces
org.springframework.http.codec.CodecConfigurer
Known Direct Subclasses
org.springframework.http.codec.support.DefaultClientCodecConfigurer, org.springframework.http.codec.support.DefaultServerCodecConfigurer
Imports
java.util.ArrayList, .LinkedHashMap, .List, .Map, java.util.function.Consumer, org.springframework.core.ResolvableType, org.springframework.core.codec.Decoder, .Encoder, org.springframework.http.codec.CodecConfigurer, .DecoderHttpMessageReader, .EncoderHttpMessageWriter, .HttpMessageReader, .HttpMessageWriter, org.springframework.util.Assert

Default implementation of CodecConfigurer that serves as a base for client and server specific variants.
Authors
Rossen Stoyanchev, Brian Clozel
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
BaseCodecConfigurer.DefaultCustomCodecs

Default implementation of CustomCodecs.

Field Summary

Modifier and TypeField and Description
protected final BaseCodecConfigurer.DefaultCustomCodecs
protected final BaseDefaultCodecs

Constructor Summary

AccessConstructor and Description
pack-priv
BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs)

Constructor with the base BaseDefaultCodecs to use, which can be a client or server specific variant.

protected
BaseCodecConfigurer(BaseCodecConfigurer other)

Create a deep copy of the given BaseCodecConfigurer.

Method Summary

Modifier and TypeMethod and Description
public abstract CodecConfigurer
protected abstract BaseDefaultCodecs
cloneDefaultCodecs()

Subclasses should override this to create a deep copy of BaseDefaultCodecs which can be client or server specific.

public CodecConfigurer.CustomCodecs
customCodecs()

Implements org.springframework.http.codec.CodecConfigurer.customCodecs.

Register custom HTTP message readers or writers in addition to the ones registered by default.

public CodecConfigurer.DefaultCodecs
defaultCodecs()

Implements org.springframework.http.codec.CodecConfigurer.defaultCodecs.

Provides a way to customize or replace HTTP message readers and writers registered by default.

public List<HttpMessageReader<?>>
getReaders()

Implements org.springframework.http.codec.CodecConfigurer.getReaders.

Obtain the configured HTTP message readers.

public List<HttpMessageWriter<?>>
getWriters()

Implements org.springframework.http.codec.CodecConfigurer.getWriters.

Obtain the configured HTTP message writers.

public void
registerDefaults(boolean shouldRegister)

Implements org.springframework.http.codec.CodecConfigurer.registerDefaults.

Provides a way to completely turn off registration of default HTTP message readers and writers, and instead rely only on the ones provided via customCodecs().

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

customCodecsback to summary
protected final BaseCodecConfigurer.DefaultCustomCodecs customCodecs
defaultCodecsback to summary
protected final BaseDefaultCodecs defaultCodecs

Constructor Detail

BaseCodecConfigurerback to summary
pack-priv BaseCodecConfigurer(BaseDefaultCodecs defaultCodecs)

Constructor with the base BaseDefaultCodecs to use, which can be a client or server specific variant.

BaseCodecConfigurerback to summary
protected BaseCodecConfigurer(BaseCodecConfigurer other)

Create a deep copy of the given BaseCodecConfigurer.

Since
5.1.12

Method Detail

cloneback to summary
public abstract CodecConfigurer clone()

Redeclares org.springframework.http.codec.CodecConfigurer.clone.

Overrides java.lang.Object.clone.

Doc from org.springframework.http.codec.CodecConfigurer.clone.

Create a copy of this CodecConfigurer. The returned clone has its own lists of default and custom codecs and generally can be configured independently. Keep in mind however that codec instances (if any are configured) are themselves not cloned.

Returns:CodecConfigurer

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
cloneDefaultCodecsback to summary
protected abstract BaseDefaultCodecs cloneDefaultCodecs()

Subclasses should override this to create a deep copy of BaseDefaultCodecs which can be client or server specific.

Since
5.1.12
customCodecsback to summary
public CodecConfigurer.CustomCodecs customCodecs()

Implements org.springframework.http.codec.CodecConfigurer.customCodecs.

Doc from org.springframework.http.codec.CodecConfigurer.customCodecs.

Register custom HTTP message readers or writers in addition to the ones registered by default.

Annotations
@Override
defaultCodecsback to summary
public CodecConfigurer.DefaultCodecs defaultCodecs()

Implements org.springframework.http.codec.CodecConfigurer.defaultCodecs.

Doc from org.springframework.http.codec.CodecConfigurer.defaultCodecs.

Provides a way to customize or replace HTTP message readers and writers registered by default.

Annotations
@Override
getReadersback to summary
public List<HttpMessageReader<?>> getReaders()

Implements org.springframework.http.codec.CodecConfigurer.getReaders.

Doc from org.springframework.http.codec.CodecConfigurer.getReaders.

Obtain the configured HTTP message readers.

Annotations
@Override
getWritersback to summary
public List<HttpMessageWriter<?>> getWriters()

Implements org.springframework.http.codec.CodecConfigurer.getWriters.

Doc from org.springframework.http.codec.CodecConfigurer.getWriters.

Obtain the configured HTTP message writers.

Annotations
@Override
registerDefaultsback to summary
public void registerDefaults(boolean shouldRegister)

Implements org.springframework.http.codec.CodecConfigurer.registerDefaults.

Doc from org.springframework.http.codec.CodecConfigurer.registerDefaults.

Provides a way to completely turn off registration of default HTTP message readers and writers, and instead rely only on the ones provided via customCodecs().

By default this is set to "true" in which case default registrations are made; setting this to false disables default registrations.

Annotations
@Override
org.springframework.http.codec.support back to summary

protected final Class BaseCodecConfigurer.DefaultCustomCodecs

extends Object
implements CustomCodecs
Class Inheritance
  • java.lang.Object
  • org.springframework.http.codec.support.BaseCodecConfigurer.DefaultCustomCodecs
All Implemented Interfaces
org.springframework.http.codec.CodecConfigurer.CustomCodecs

Default implementation of CustomCodecs.

Field Summary

Modifier and TypeField and Description
private final List<Consumer<CodecConfigurer.DefaultCodecConfig>>
private final Map<HttpMessageReader<?>, Boolean>
private final Map<HttpMessageWriter<?>, Boolean>
private final Map<HttpMessageReader<?>, Boolean>
private final Map<HttpMessageWriter<?>, Boolean>

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
addCodec(Object codec, boolean applyDefaultConfig)

public void
decoder(Decoder<?>
the decoder to add
decoder
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.decoder.

Add a custom Decoder internally wrapped with DecoderHttpMessageReader).

public void
encoder(Encoder<?>
the encoder to add
encoder
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.encoder.

Add a custom Encoder, internally wrapped with EncoderHttpMessageWriter.

pack-priv List<Consumer<CodecConfigurer.DefaultCodecConfig>>
pack-priv Map<HttpMessageReader<?>, Boolean>
pack-priv Map<HttpMessageWriter<?>, Boolean>
pack-priv Map<HttpMessageReader<?>, Boolean>
pack-priv Map<HttpMessageWriter<?>, Boolean>
public void
public void
register(Object
the codec to register
codec
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.register.

Register a custom codec.

public void
registerWithDefaultConfig(Object
the codec to register and apply default config to
codec
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Variant of register(Object) that also applies the below properties, if configured, via defaultCodecs():

public void
registerWithDefaultConfig(Object
the codec to register
codec
,
Consumer<CodecConfigurer.DefaultCodecConfig>
consumer of the default config
configConsumer
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Variant of register(Object) that also allows the caller to apply the properties from DefaultCodecConfig to the given codec.

public void
withDefaultCodecConfig(Consumer<CodecConfigurer.DefaultCodecConfig>
the default codecs configuration callback
codecsConfigConsumer
)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.withDefaultCodecConfig.

Register a callback for the configuration applied to default codecs.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultConfigConsumersback to summary
private final List<Consumer<CodecConfigurer.DefaultCodecConfig>> defaultConfigConsumers
objectReadersback to summary
private final Map<HttpMessageReader<?>, Boolean> objectReaders
objectWritersback to summary
private final Map<HttpMessageWriter<?>, Boolean> objectWriters
typedReadersback to summary
private final Map<HttpMessageReader<?>, Boolean> typedReaders
typedWritersback to summary
private final Map<HttpMessageWriter<?>, Boolean> typedWriters

Constructor Detail

DefaultCustomCodecsback to summary
pack-priv DefaultCustomCodecs()
DefaultCustomCodecsback to summary
pack-priv DefaultCustomCodecs(BaseCodecConfigurer.DefaultCustomCodecs other)

Create a deep copy of the given DefaultCustomCodecs.

Since
5.1.12

Method Detail

addCodecback to summary
private void addCodec(Object codec, boolean applyDefaultConfig)
decoderback to summary
public void decoder(Decoder<?> decoder)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.decoder.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.decoder.

Add a custom Decoder internally wrapped with DecoderHttpMessageReader).

Parameters
decoder:Decoder<?>

the decoder to add

Annotations
@SuppressWarnings:deprecation
@Override
encoderback to summary
public void encoder(Encoder<?> encoder)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.encoder.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.encoder.

Add a custom Encoder, internally wrapped with EncoderHttpMessageWriter.

Parameters
encoder:Encoder<?>

the encoder to add

Annotations
@SuppressWarnings:deprecation
@Override
getDefaultConfigConsumersback to summary
pack-priv List<Consumer<CodecConfigurer.DefaultCodecConfig>> getDefaultConfigConsumers()
getObjectReadersback to summary
pack-priv Map<HttpMessageReader<?>, Boolean> getObjectReaders()
getObjectWritersback to summary
pack-priv Map<HttpMessageWriter<?>, Boolean> getObjectWriters()
getTypedReadersback to summary
pack-priv Map<HttpMessageReader<?>, Boolean> getTypedReaders()
getTypedWritersback to summary
pack-priv Map<HttpMessageWriter<?>, Boolean> getTypedWriters()
readerback to summary
public void reader(HttpMessageReader<?> reader)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.reader.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.reader.

Add a custom HttpMessageReader. For readers of type DecoderHttpMessageReader consider using the shortcut decoder(Decoder) instead.

Parameters
reader:HttpMessageReader<?>

the reader to add

Annotations
@SuppressWarnings:deprecation
@Override
registerback to summary
public void register(Object codec)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.register.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.register.

Register a custom codec. This is expected to be one of the following:

Parameters
codec:Object

the codec to register

Annotations
@Override
registerWithDefaultConfigback to summary
public void registerWithDefaultConfig(Object codec)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Variant of register(Object) that also applies the below properties, if configured, via defaultCodecs():

The properties are applied every time getReaders() or getWriters() are used to obtain the list of configured readers or writers.

Parameters
codec:Object

the codec to register and apply default config to

Annotations
@Override
registerWithDefaultConfigback to summary
public void registerWithDefaultConfig(Object codec, Consumer<CodecConfigurer.DefaultCodecConfig> configConsumer)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.registerWithDefaultConfig.

Variant of register(Object) that also allows the caller to apply the properties from DefaultCodecConfig to the given codec. If you want to apply all the properties, prefer using registerWithDefaultConfig(Object).

The consumer is called every time getReaders() or getWriters() are used to obtain the list of configured readers or writers.

Parameters
codec:Object

the codec to register

configConsumer:Consumer<CodecConfigurer.DefaultCodecConfig>

consumer of the default config

Annotations
@Override
withDefaultCodecConfigback to summary
public void withDefaultCodecConfig(Consumer<CodecConfigurer.DefaultCodecConfig> codecsConfigConsumer)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.withDefaultCodecConfig.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.withDefaultCodecConfig.

Register a callback for the configuration applied to default codecs. This allows custom codecs to follow general guidelines applied to default ones, such as logging details and limiting the amount of buffered data.

Parameters
codecsConfigConsumer:Consumer<CodecConfigurer.DefaultCodecConfig>

the default codecs configuration callback

Annotations
@SuppressWarnings:deprecation
@Override
writerback to summary
public void writer(HttpMessageWriter<?> writer)

Implements org.springframework.http.codec.CodecConfigurer.CustomCodecs.writer.

Doc from org.springframework.http.codec.CodecConfigurer.CustomCodecs.writer.

Add a custom HttpMessageWriter. For writers of type EncoderHttpMessageWriter consider using the shortcut encoder(Encoder) instead.

Parameters
writer:HttpMessageWriter<?>

the writer to add

Annotations
@SuppressWarnings:deprecation
@Override