keycloakjar.org.springframework.http.codec.CodecConfigurer Maven / Gradle / Ivy
Show all versions of camunda-bpm-identity-keycloak-all Show documentation
/*
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.http.codec;
import java.util.List;
import java.util.function.Consumer;
import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.Encoder;
import org.springframework.lang.Nullable;
/**
* Defines a common interface for configuring either client or server HTTP
* message readers and writers. This is used as follows:
*
* - Use {@link ClientCodecConfigurer#create()} or
* {@link ServerCodecConfigurer#create()} to create an instance.
*
- Use {@link #defaultCodecs()} to customize HTTP message readers or writers
* registered by default.
*
- Use {@link #customCodecs()} to add custom HTTP message readers or writers.
*
- Use {@link #getReaders()} and {@link #getWriters()} to obtain the list of
* configured HTTP message readers and writers.
*
*
* HTTP message readers and writers are divided into 3 categories that are
* ordered as follows:
*
* - Typed readers and writers that support specific types, e.g. byte[], String.
*
- Object readers and writers, e.g. JSON, XML.
*
- Catch-all readers or writers, e.g. String with any media type.
*
*
* Typed and object readers are further sub-divided and ordered as follows:
*
* - Default HTTP reader and writer registrations.
*
- Custom readers and writers.
*
*
* @author Rossen Stoyanchev
* @since 5.0
*/
public interface CodecConfigurer {
/**
* Provides a way to customize or replace HTTP message readers and writers
* registered by default.
* @see #registerDefaults(boolean)
*/
DefaultCodecs defaultCodecs();
/**
* Register custom HTTP message readers or writers in addition to the ones
* registered by default.
*/
CustomCodecs customCodecs();
/**
* Provides a way to completely turn off registration of default HTTP message
* readers and writers, and instead rely only on the ones provided via
* {@link #customCodecs()}.
* By default this is set to {@code "true"} in which case default
* registrations are made; setting this to {@code false} disables default
* registrations.
*/
void registerDefaults(boolean registerDefaults);
/**
* Obtain the configured HTTP message readers.
*/
List> getReaders();
/**
* Obtain the configured HTTP message writers.
*/
List> getWriters();
/**
* Create a copy of this {@link 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.
* @since 5.1.12
*/
CodecConfigurer clone();
/**
* Customize or replace the HTTP message readers and writers registered by
* default. The options are further extended by
* {@link ClientCodecConfigurer.ClientDefaultCodecs ClientDefaultCodecs} and
* {@link ServerCodecConfigurer.ServerDefaultCodecs ServerDefaultCodecs}.
*/
interface DefaultCodecs {
/**
* Override the default Jackson JSON {@code Decoder}.
* Note that {@link #maxInMemorySize(int)}, if configured, will be
* applied to the given decoder.
* @param decoder the decoder instance to use
* @see org.springframework.http.codec.json.Jackson2JsonDecoder
*/
void jackson2JsonDecoder(Decoder> decoder);
/**
* Override the default Jackson JSON {@code Encoder}.
* @param encoder the encoder instance to use
* @see org.springframework.http.codec.json.Jackson2JsonEncoder
*/
void jackson2JsonEncoder(Encoder> encoder);
/**
* Override the default Jackson Smile {@code Decoder}.
*
Note that {@link #maxInMemorySize(int)}, if configured, will be
* applied to the given decoder.
* @param decoder the decoder instance to use
* @see org.springframework.http.codec.json.Jackson2SmileDecoder
*/
void jackson2SmileDecoder(Decoder> decoder);
/**
* Override the default Jackson Smile {@code Encoder}.
* @param encoder the encoder instance to use
* @see org.springframework.http.codec.json.Jackson2SmileEncoder
*/
void jackson2SmileEncoder(Encoder> encoder);
/**
* Override the default Protobuf {@code Decoder}.
*
Note that {@link #maxInMemorySize(int)}, if configured, will be
* applied to the given decoder.
* @param decoder the decoder instance to use
* @since 5.1
* @see org.springframework.http.codec.protobuf.ProtobufDecoder
*/
void protobufDecoder(Decoder> decoder);
/**
* Override the default Protobuf {@code Encoder}.
* @param encoder the encoder instance to use
* @since 5.1
* @see org.springframework.http.codec.protobuf.ProtobufEncoder
* @see org.springframework.http.codec.protobuf.ProtobufHttpMessageWriter
*/
void protobufEncoder(Encoder> encoder);
/**
* Override the default JAXB2 {@code Decoder}.
*
Note that {@link #maxInMemorySize(int)}, if configured, will be
* applied to the given decoder.
* @param decoder the decoder instance to use
* @since 5.1.3
* @see org.springframework.http.codec.xml.Jaxb2XmlDecoder
*/
void jaxb2Decoder(Decoder> decoder);
/**
* Override the default JABX2 {@code Encoder}.
* @param encoder the encoder instance to use
* @since 5.1.3
* @see org.springframework.http.codec.xml.Jaxb2XmlEncoder
*/
void jaxb2Encoder(Encoder> encoder);
/**
* Override the default Kotlin Serialization JSON {@code Decoder}.
* @param decoder the decoder instance to use
* @since 5.3
* @see org.springframework.http.codec.json.KotlinSerializationJsonDecoder
*/
void kotlinSerializationJsonDecoder(Decoder> decoder);
/**
* Override the default Kotlin Serialization JSON {@code Encoder}.
* @param encoder the encoder instance to use
* @since 5.3
* @see org.springframework.http.codec.json.KotlinSerializationJsonEncoder
*/
void kotlinSerializationJsonEncoder(Encoder> encoder);
/**
* Register a consumer to apply to default config instances. This can be
* used to configure rather than replace a specific codec or multiple
* codecs. The consumer is applied to every default {@link Encoder},
* {@link Decoder}, {@link HttpMessageReader} and {@link HttpMessageWriter}
* instance.
* @param codecConsumer the consumer to apply
* @since 5.3.4
*/
void configureDefaultCodec(Consumer