From 9e96cfa7cdb07b5fc147ae78fe25e72dd1475b12 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 27 Mar 2017 15:08:46 -0400 Subject: [PATCH] Polish --- .../http/codec/AbstractCodecConfigurer.java | 43 +++---------------- .../http/codec/ClientCodecConfigurer.java | 9 ++++ 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/codec/AbstractCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/AbstractCodecConfigurer.java index 5198176ef8c..e6d9d09be8c 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/AbstractCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/AbstractCodecConfigurer.java @@ -41,7 +41,7 @@ import org.springframework.util.Assert; import org.springframework.util.ClassUtils; /** - * Base class for client or server codec configurers. + * Base class for client or server HTTP message reader and writer configurers. * * @author Rossen Stoyanchev * @since 5.0 @@ -103,13 +103,13 @@ public abstract class AbstractCodecConfigurer { List> result = new ArrayList<>(); addDefaultTypedReaders(result); - addCustomTypedReaders(result); + customCodec().addTypedReadersTo(result); addDefaultObjectReaders(result); - addCustomObjectReaders(result); + customCodec().addObjectReadersTo(result); + // String + "*/*" defaultCodec().addStringReaderTo(result); - return result; } @@ -124,13 +124,6 @@ public abstract class AbstractCodecConfigurer { defaultCodec().addStringReaderTextOnlyTo(result); } - /** - * Add custom, concrete, Java type readers. - */ - protected void addCustomTypedReaders(List> result) { - customCodec().addTypedReadersTo(result); - } - /** * Add built-in, Object-based readers. */ @@ -143,14 +136,6 @@ public abstract class AbstractCodecConfigurer { } } - /** - * Add custom, Object-based readers. - */ - protected void addCustomObjectReaders(List> result) { - customCodec().addObjectReadersTo(result); - } - - /** * Prepare a list of HTTP message writers. */ @@ -159,14 +144,13 @@ public abstract class AbstractCodecConfigurer { List> result = new ArrayList<>(); addDefaultTypedWriter(result); - addCustomTypedWriter(result); + customCodec().addTypedWritersTo(result); addDefaultObjectWriters(result); - addCustomObjectWriters(result); + customCodec().addObjectWritersTo(result); // String + "*/*" defaultCodec().addStringWriterTo(result); - return result; } @@ -181,13 +165,6 @@ public abstract class AbstractCodecConfigurer { defaultCodec().addStringWriterTextPlainOnlyTo(result); } - /** - * Add custom, concrete, Java type readers. - */ - protected void addCustomTypedWriter(List> result) { - customCodec().addTypedWritersTo(result); - } - /** * Add built-in, Object-based readers. */ @@ -200,14 +177,6 @@ public abstract class AbstractCodecConfigurer { } } - /** - * Add custom, Object-based readers. - */ - protected void addCustomObjectWriters(List> result) { - customCodec().addObjectWritersTo(result); - } - - /** * A registry and a factory for built-in HTTP message readers and writers. diff --git a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java index d8df8615940..f224524088e 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ClientCodecConfigurer.java @@ -21,6 +21,15 @@ import org.springframework.core.codec.Decoder; import org.springframework.http.codec.json.Jackson2JsonDecoder; /** + * Helps to configure a list of client-side HTTP message readers and writers + * with support for built-in defaults and options to register additional custom + * readers and writers via {@link #customCodec()}. + * + *

The built-in defaults include basic data types such as various byte + * representations, resources, strings, forms, but also others like JAXB2 and + * Jackson 2 based on classpath detection. There are options to + * {@link #defaultCodec() override} some of the defaults or to have them + * {@link #registerDefaults(boolean) turned off} completely. * * @author Rossen Stoyanchev * @since 5.0