18
18
19
19
import org .springframework .http .converter .FormHttpMessageConverter ;
20
20
import org .springframework .http .converter .cbor .KotlinSerializationCborHttpMessageConverter ;
21
+ import org .springframework .http .converter .cbor .MappingJackson2CborHttpMessageConverter ;
21
22
import org .springframework .http .converter .json .GsonHttpMessageConverter ;
22
23
import org .springframework .http .converter .json .JsonbHttpMessageConverter ;
23
24
import org .springframework .http .converter .json .KotlinSerializationJsonHttpMessageConverter ;
31
32
32
33
/**
33
34
* Extension of {@link org.springframework.http.converter.FormHttpMessageConverter},
34
- * adding support for XML and JSON-based parts.
35
+ * adding support for XML, JSON, Smile, CBOR, Protobuf and Yaml based parts when
36
+ * related libraries are present in the classpath.
35
37
*
36
38
* @author Rossen Stoyanchev
37
39
* @author Juergen Hoeller
@@ -48,6 +50,8 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
48
50
49
51
private static final boolean jackson2SmilePresent ;
50
52
53
+ private static final boolean jackson2CborPresent ;
54
+
51
55
private static final boolean jackson2YamlPresent ;
52
56
53
57
private static final boolean gsonPresent ;
@@ -67,6 +71,7 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv
67
71
ClassUtils .isPresent ("com.fasterxml.jackson.core.JsonGenerator" , classLoader );
68
72
jackson2XmlPresent = ClassUtils .isPresent ("com.fasterxml.jackson.dataformat.xml.XmlMapper" , classLoader );
69
73
jackson2SmilePresent = ClassUtils .isPresent ("com.fasterxml.jackson.dataformat.smile.SmileFactory" , classLoader );
74
+ jackson2CborPresent = ClassUtils .isPresent ("com.fasterxml.jackson.dataformat.cbor.CBORFactory" , classLoader );
70
75
jackson2YamlPresent = ClassUtils .isPresent ("com.fasterxml.jackson.dataformat.yaml.YAMLFactory" , classLoader );
71
76
gsonPresent = ClassUtils .isPresent ("com.google.gson.Gson" , classLoader );
72
77
jsonbPresent = ClassUtils .isPresent ("jakarta.json.bind.Jsonb" , classLoader );
@@ -103,6 +108,10 @@ else if (jsonbPresent) {
103
108
addPartConverter (new MappingJackson2SmileHttpMessageConverter ());
104
109
}
105
110
111
+ if (jackson2CborPresent ) {
112
+ addPartConverter (new MappingJackson2CborHttpMessageConverter ());
113
+ }
114
+
106
115
if (jackson2YamlPresent ) {
107
116
addPartConverter (new MappingJackson2YamlHttpMessageConverter ());
108
117
}
0 commit comments