Skip to content

Commit f741724

Browse files
artembilangaryrussell
authored andcommitted
INT-4561: deprecate Boon JSON processor support
JIRA: https://jira.spring.io/browse/INT-4561 * Remove appropriate tests * reflect the change in Docs
1 parent 4f34d92 commit f741724

File tree

9 files changed

+22
-121
lines changed

9 files changed

+22
-121
lines changed

spring-integration-core/src/main/java/org/springframework/integration/support/json/BoonJsonObjectMapper.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,7 +47,10 @@
4747
*
4848
* @author Artem Bilan
4949
* @since 4.1
50+
*
51+
* @deprecated since 5.2. Will be removed in the next version.
5052
*/
53+
@Deprecated
5154
public class BoonJsonObjectMapper extends JsonObjectMapperAdapter<Map<String, Object>, Object>
5255
implements BeanClassLoaderAware {
5356

spring-integration-core/src/main/java/org/springframework/integration/support/json/JsonObjectMapperProvider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@
3131
* @since 3.0
3232
*
3333
* @see Jackson2JsonObjectMapper
34-
* @see BoonJsonObjectMapper
3534
*/
3635
public final class JsonObjectMapperProvider {
3736

@@ -49,12 +48,13 @@ private JsonObjectMapperProvider() {
4948
* @return the mapper.
5049
* @throws IllegalStateException if an implementation is not available.
5150
*/
51+
@SuppressWarnings("deprecation")
5252
public static JsonObjectMapper<?, ?> newInstance() {
5353
if (JacksonPresent.isJackson2Present()) {
5454
return new Jackson2JsonObjectMapper();
5555
}
5656
else if (boonPresent) {
57-
return new BoonJsonObjectMapper();
57+
return new org.springframework.integration.support.json.BoonJsonObjectMapper();
5858
}
5959
else {
6060
throw new IllegalStateException("Neither jackson-databind.jar, nor boon.jar is present in the classpath.");

spring-integration-core/src/test/java/org/springframework/integration/json/JsonToObjectTransformerTests.java

+5-19
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.junit.Test;
2222

23-
import org.springframework.integration.support.json.BoonJsonObjectMapper;
2423
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
2524
import org.springframework.messaging.Message;
2625
import org.springframework.messaging.support.GenericMessage;
@@ -37,9 +36,10 @@
3736
public class JsonToObjectTransformerTests {
3837

3938
@Test
40-
public void objectPayload() throws Exception {
39+
public void objectPayload() {
4140
JsonToObjectTransformer transformer = new JsonToObjectTransformer(TestPerson.class);
42-
// Since DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is disabled by default (see Jackson2JsonObjectMapper)
41+
// Since DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES is disabled by default
42+
// (see Jackson2JsonObjectMapper)
4343
// the extra "foo" property is ignored.
4444
String jsonString = "{\"firstName\":\"John\",\"lastName\":\"Doe\",\"age\":42," +
4545
"\"address\":{\"number\":123,\"street\":\"Main Street\"}, \"foo\":\"bar\"}";
@@ -52,28 +52,14 @@ public void objectPayload() throws Exception {
5252
}
5353

5454
@Test
55-
public void objectPayloadWithCustomMapper() throws Exception {
55+
public void objectPayloadWithCustomMapper() {
5656
ObjectMapper customMapper = new ObjectMapper();
5757
customMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, Boolean.TRUE);
5858
customMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, Boolean.TRUE);
5959
JsonToObjectTransformer transformer =
6060
new JsonToObjectTransformer(TestPerson.class, new Jackson2JsonObjectMapper(customMapper));
6161
String jsonString = "{firstName:'John', lastName:'Doe', age:42, address:{number:123, street:'Main Street'}}";
62-
Message<?> message = transformer.transform(new GenericMessage<String>(jsonString));
63-
TestPerson person = (TestPerson) message.getPayload();
64-
assertThat(person.getFirstName()).isEqualTo("John");
65-
assertThat(person.getLastName()).isEqualTo("Doe");
66-
assertThat(person.getAge()).isEqualTo(42);
67-
assertThat(person.getAddress().toString()).isEqualTo("123 Main Street");
68-
}
69-
70-
71-
@Test
72-
public void testBoonJsonObjectMapper() throws Exception {
73-
JsonToObjectTransformer transformer = new JsonToObjectTransformer(TestPerson.class, new BoonJsonObjectMapper());
74-
String jsonString = "{\"firstName\":\"John\",\"lastName\":\"Doe\",\"age\":42," +
75-
"\"address\":{\"number\":123,\"street\":\"Main Street\"}}";
76-
Message<?> message = transformer.transform(new GenericMessage<String>(jsonString));
62+
Message<?> message = transformer.transform(new GenericMessage<>(jsonString));
7763
TestPerson person = (TestPerson) message.getPayload();
7864
assertThat(person.getFirstName()).isEqualTo("John");
7965
assertThat(person.getLastName()).isEqualTo("Doe");

spring-integration-core/src/test/java/org/springframework/integration/json/JsonTransformersSymmetricalTests.java

+1-21
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.junit.Test;
2525

26-
import org.springframework.integration.support.json.BoonJsonObjectMapper;
2726
import org.springframework.messaging.Message;
2827
import org.springframework.messaging.support.GenericMessage;
2928

@@ -40,7 +39,7 @@ public void testInt2809ObjectToJson_JsonToObject() {
4039
TestPerson person = new TestPerson("John", "Doe", 42);
4140
person.setAddress(new TestAddress(123, "Main Street"));
4241

43-
List<TestPerson> payload = new ArrayList<TestPerson>();
42+
List<TestPerson> payload = new ArrayList<>();
4443
payload.add(person);
4544

4645
ObjectToJsonTransformer objectToJsonTransformer = new ObjectToJsonTransformer();
@@ -52,23 +51,4 @@ public void testInt2809ObjectToJson_JsonToObject() {
5251
assertThat(((List<?>) result).get(0)).isEqualTo(person);
5352
}
5453

55-
@Test
56-
public void testBoonObjectToJson_JsonToObject() {
57-
58-
TestPerson person = new TestPerson("John", "Doe", 42);
59-
person.setAddress(new TestAddress(123, "Main Street"));
60-
61-
List<TestPerson> payload = new ArrayList<TestPerson>();
62-
payload.add(person);
63-
64-
ObjectToJsonTransformer objectToJsonTransformer = new ObjectToJsonTransformer(new BoonJsonObjectMapper());
65-
Message<?> jsonMessage = objectToJsonTransformer.transform(new GenericMessage<Object>(payload));
66-
67-
JsonToObjectTransformer jsonToObjectTransformer = new JsonToObjectTransformer(new BoonJsonObjectMapper());
68-
Object result = jsonToObjectTransformer.transform(jsonMessage).getPayload();
69-
assertThat(result).isInstanceOf(List.class);
70-
assertThat(((List<?>) result).get(0)).isEqualTo(person);
71-
}
72-
73-
7454
}

spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerParserTests-context.xml

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222

2323
<object-to-json-transformer id="jsonNodeTransformer" input-channel="jsonNodeInput" result-type="NODE"/>
2424

25-
<object-to-json-transformer input-channel="boonJsonNodeInput" result-type="NODE"
26-
object-mapper="boonJsonObjectMapper"/>
27-
28-
<beans:bean id="boonJsonObjectMapper" class="org.springframework.integration.support.json.BoonJsonObjectMapper"/>
29-
3025
<beans:bean id="customJsonObjectMapper" class="org.springframework.integration.json.ObjectToJsonTransformerParserTests$CustomJsonObjectMapper"/>
3126

3227
</beans:beans>

spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerParserTests.java

+1-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21-
import java.util.Map;
2221
import java.util.regex.Matcher;
2322
import java.util.regex.Pattern;
2423

@@ -31,7 +30,6 @@
3130
import org.springframework.expression.spel.standard.SpelExpressionParser;
3231
import org.springframework.expression.spel.support.StandardEvaluationContext;
3332
import org.springframework.integration.channel.QueueChannel;
34-
import org.springframework.integration.mapping.support.JsonHeaders;
3533
import org.springframework.integration.support.DefaultMessageBuilderFactory;
3634
import org.springframework.integration.support.MessageBuilder;
3735
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
@@ -68,9 +66,6 @@ public class ObjectToJsonTransformerParserTests {
6866
@Autowired
6967
private MessageChannel jsonNodeInput;
7068

71-
@Autowired
72-
private MessageChannel boonJsonNodeInput;
73-
7469
@Autowired
7570
private DefaultMessageBuilderFactory defaultMessageBuilderFactory;
7671

@@ -179,29 +174,10 @@ public void testNodeResultType() {
179174
assertThat(expression.getValue(evaluationContext, payload, Boolean.class)).isTrue();
180175
}
181176

182-
@Test
183-
public void testBoonNodeResultType() {
184-
TestPerson person = new TestPerson();
185-
person.setFirstName("John");
186-
person.setLastName("Doe");
187-
person.setAge(42);
188-
QueueChannel replyChannel = new QueueChannel();
189-
Message<TestPerson> message = MessageBuilder.withPayload(person).setReplyChannel(replyChannel).build();
190-
this.boonJsonNodeInput.send(message);
191-
Message<?> reply = replyChannel.receive(0);
192-
assertThat(reply).isNotNull();
193-
Object payload = reply.getPayload();
194-
assertThat(payload).isInstanceOf(Map.class);
195-
assertThat(reply.getHeaders().get(JsonHeaders.TYPE_ID)).isEqualTo(TestPerson.class);
196-
197-
Expression expression = new SpelExpressionParser().parseExpression("[firstName] == 'John' and [age] == 42");
198-
assertThat(expression.getValue(new StandardEvaluationContext(), payload, Boolean.class)).isTrue();
199-
}
200-
201177
static class CustomJsonObjectMapper extends JsonObjectMapperAdapter<Object, Object> {
202178

203179
@Override
204-
public String toJson(Object value) throws Exception {
180+
public String toJson(Object value) {
205181
return "{" + value.toString() + "}";
206182
}
207183

spring-integration-core/src/test/java/org/springframework/integration/json/ObjectToJsonTransformerTests.java

-40
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@
2626

2727
import org.junit.Test;
2828

29-
import org.springframework.context.expression.MapAccessor;
30-
import org.springframework.expression.Expression;
31-
import org.springframework.expression.spel.standard.SpelExpressionParser;
32-
import org.springframework.expression.spel.support.StandardEvaluationContext;
3329
import org.springframework.integration.mapping.support.JsonHeaders;
3430
import org.springframework.integration.support.MessageBuilder;
35-
import org.springframework.integration.support.json.BoonJsonObjectMapper;
3631
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
3732
import org.springframework.messaging.Message;
3833
import org.springframework.messaging.MessageHeaders;
@@ -196,41 +191,6 @@ public void collectionOrMapWithNullFirstElement() {
196191
assertThat(out.getHeaders().get(JsonHeaders.KEY_TYPE_ID)).isEqualTo(String.class);
197192
}
198193

199-
@Test
200-
public void testBoonJsonObjectMapper() {
201-
ObjectToJsonTransformer transformer = new ObjectToJsonTransformer(new BoonJsonObjectMapper());
202-
TestPerson person = new TestPerson("John", "Doe", 42);
203-
person.setAddress(new TestAddress(123, "Main Street"));
204-
String result = (String) transformer.transform(new GenericMessage<>(person)).getPayload();
205-
assertThat(result.contains("\"firstName\":\"John\"")).isTrue();
206-
assertThat(result.contains("\"lastName\":\"Doe\"")).isTrue();
207-
assertThat(result.contains("\"age\":42")).isTrue();
208-
Pattern addressPattern = Pattern.compile("(\"address\":\\{.*?\\})");
209-
Matcher matcher = addressPattern.matcher(result);
210-
assertThat(matcher.find()).isTrue();
211-
String addressResult = matcher.group(1);
212-
assertThat(addressResult.contains("\"number\":123")).isTrue();
213-
assertThat(addressResult.contains("\"street\":\"Main Street\"")).isTrue();
214-
}
215-
216-
@Test
217-
public void testBoonJsonObjectMapper_toNode() {
218-
ObjectToJsonTransformer transformer = new ObjectToJsonTransformer(new BoonJsonObjectMapper(),
219-
ObjectToJsonTransformer.ResultType.NODE);
220-
TestPerson person = new TestPerson("John", "Doe", 42);
221-
person.setAddress(new TestAddress(123, "Main Street"));
222-
Object payload = transformer.transform(new GenericMessage<>(person)).getPayload();
223-
assertThat(payload).isInstanceOf(Map.class);
224-
225-
SpelExpressionParser parser = new SpelExpressionParser();
226-
Expression expression = parser.parseExpression("firstName + ': ' + address.street");
227-
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
228-
evaluationContext.addPropertyAccessor(new MapAccessor());
229-
String value = expression.getValue(evaluationContext, payload, String.class);
230-
231-
assertThat(value).isEqualTo("John: Main Street");
232-
}
233-
234194
@Test
235195
public void testJsonStringAndJsonNode() {
236196
ObjectToJsonTransformer transformer = new ObjectToJsonTransformer(ObjectToJsonTransformer.ResultType.NODE);

src/reference/asciidoc/file.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ The default is `false`.
10151015
When `true`, `apply-sequence` is `false` by default.
10161016
See also `markers-json` (the next attribute).
10171017
<4> When `markers` is true, set this to `true` to have the `FileMarker` objects be converted to a JSON string.
1018-
Requires a supported JSON processor library (Jackson or Boon) on the classpath.
1018+
Requires a supported JSON processor library (e.g. Jackson) on the classpath.
10191019
<5> Set to `false` to disable the inclusion of `sequenceSize` and `sequenceNumber` headers in messages.
10201020
The default is `true`, unless `markers` is `true`.
10211021
When `true` and `markers` is `true`, the markers are included in the sequencing.
@@ -1049,7 +1049,7 @@ public FileSplitter(boolean iterator, boolean markers, boolean markersJson)
10491049
----
10501050
====
10511051

1052-
When `markersJson` is true, the markers are represented as a JSON string, as long as a suitable JSON processor library (such as Jackson or Boon) is on the classpath.
1052+
When `markersJson` is true, the markers are represented as a JSON string, as long as a suitable JSON processor library (e.g Jackson) is on the classpath.
10531053

10541054
Version 5.0 introduced the `firstLineAsHeader` option to specify that the first line of content is a header (such as column names in a CSV file).
10551055
The argument passed to this property is the header name under which the first line is carried as a header in the messages emitted for the remaining lines.

src/reference/asciidoc/transformer.adoc

+6-5
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,16 @@ You can provide your own custom `JsonObjectMapper` implementation with appropria
343343
====
344344
Beginning with version 3.0, the `object-mapper` attribute references an instance of a new strategy interface: `JsonObjectMapper`.
345345
This abstraction lets multiple implementations of JSON mappers be used.
346-
Implementations that wrap https://github.com/RichardHightower/boon[Boon] and https://github.com/FasterXML[Jackson 2] are provided, with the version being detected on the classpath.
347-
These classes are `BoonJsonObjectMapper` and `Jackson2JsonObjectMapper`, respectively.
346+
Implementation that wraps https://github.com/FasterXML[Jackson 2] is provided, with the version being detected on the classpath.
347+
The class is `Jackson2JsonObjectMapper`, respectively.
348348
349-
Note, `BoonJsonObjectMapper` was added in version 4.1.
349+
NOTE: The `BoonJsonObjectMapper` is deprecated in 5.2 since the library is out of support.
350350
====
351351

352352
[IMPORTANT]
353353
====
354354
If you have requirements to use both Jackson and Boon in the same application, keep in mind that, before version 3.0, the JSON transformers used only Jackson 1.x.
355-
From 4.1 on, the framework selects Jackson 2 by default, preferring it to the Boon implementation if both are on the classpath.
355+
From 4.1 on, the framework selects Jackson 2 by default.
356356
Jackson 1.x is no longer supported by the framework internally.
357357
However, you can still use it within your code by including the necessary library.
358358
To avoid unexpected issues with JSON mapping features when you use annotations, you may need to apply annotations from both Jackson and Boon on domain classes, as the following example shows:
@@ -373,6 +373,8 @@ public class Thing1 {
373373
----
374374
====
375375

376+
NOTE: The Boon support has been deprecated since version 5.2.
377+
376378
You may wish to consider using a `FactoryBean` or a factory method to create the `JsonObjectMapper` with the required characteristics.
377379
The following example shows how to use such a factory:
378380

@@ -444,7 +446,6 @@ The result node tree representation depends on the implementation of the provide
444446
By default, the `ObjectToJsonTransformer` uses a `Jackson2JsonObjectMapper` and delegates the conversion of the object to the node tree to the `ObjectMapper#valueToTree` method.
445447
The node JSON representation provides efficiency for using the `JsonPropertyAccessor` when the downstream message flow uses SpEL expressions with access to the properties of the JSON data.
446448
See <<spel-property-accessors>> for more information.
447-
When using Boon, the `NODE` representation is a `Map<String, Object>`
448449

449450
Beginning with version 5.1, the `resultType` can be configured as `BYTES` to produce a message with the `byte[]` payload for convenience when working with downstream handlers which operate with this data type.
450451

0 commit comments

Comments
 (0)