Skip to content

Commit 5703fb1

Browse files
committed
Polish
1 parent f36b051 commit 5703fb1

File tree

24 files changed

+88
-84
lines changed

24 files changed

+88
-84
lines changed

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.
@@ -240,18 +240,22 @@ public void configureHttpMessageConverters() {
240240
for (RequestMappingHandlerAdapter handlerAdapter : this.handlerAdapters) {
241241
for (HttpMessageConverter<?> messageConverter : handlerAdapter
242242
.getMessageConverters()) {
243-
if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
244-
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
245-
messageConverter.getSupportedMediaTypes());
246-
supportedMediaTypes
247-
.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON);
248-
((AbstractHttpMessageConverter<?>) messageConverter)
249-
.setSupportedMediaTypes(supportedMediaTypes);
250-
}
243+
configureHttpMessageConverter(messageConverter);
251244
}
252245
}
253246
}
254247

248+
private void configureHttpMessageConverter(
249+
HttpMessageConverter<?> messageConverter) {
250+
if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
251+
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
252+
messageConverter.getSupportedMediaTypes());
253+
supportedMediaTypes.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON);
254+
((AbstractHttpMessageConverter<?>) messageConverter)
255+
.setSupportedMediaTypes(supportedMediaTypes);
256+
}
257+
}
258+
255259
@Override
256260
public boolean supports(MethodParameter returnType,
257261
Class<? extends HttpMessageConverter<?>> converterType) {

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
/**
4646
* Alias for {@link RequestMapping#value}.
47-
*
4847
* @return the value
4948
*/
5049
@AliasFor(annotation = RequestMapping.class)

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorMediaTypes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints.
2323
*
2424
* @author Andy Wilkinson
25+
* @since 1.5.0
2526
*/
2627
public final class ActuatorMediaTypes {
2728

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorPostMapping.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
/**
5050
* Alias for {@link RequestMapping#value}.
51-
*
5251
* @return the value
5352
*/
5453
@AliasFor(annotation = RequestMapping.class)

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2016 the original author or authors.
2+
* Copyright 2012-2017 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.

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaHttpMessageConverterConfiguration.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2017 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.
@@ -17,9 +17,8 @@
1717
package org.springframework.boot.autoconfigure.hateoas;
1818

1919
import java.util.ArrayList;
20+
import java.util.Collection;
2021
import java.util.List;
21-
import java.util.Map;
22-
import java.util.Map.Entry;
2322

2423
import javax.annotation.PostConstruct;
2524

@@ -63,28 +62,32 @@ private static class HalMessageConverterSupportedMediaTypesCustomizer
6362
private volatile BeanFactory beanFactory;
6463

6564
@PostConstruct
66-
public void customizedSupportedMediaTypes() {
65+
public void configureHttpMessageConverters() {
6766
if (this.beanFactory instanceof ListableBeanFactory) {
68-
Map<String, RequestMappingHandlerAdapter> handlerAdapters = ((ListableBeanFactory) this.beanFactory)
69-
.getBeansOfType(RequestMappingHandlerAdapter.class);
70-
for (Entry<String, RequestMappingHandlerAdapter> entry : handlerAdapters
71-
.entrySet()) {
72-
RequestMappingHandlerAdapter handlerAdapter = entry.getValue();
73-
for (HttpMessageConverter<?> converter : handlerAdapter
74-
.getMessageConverters()) {
75-
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
76-
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
77-
converter.getSupportedMediaTypes());
78-
if (!supportedMediaTypes
79-
.contains(MediaType.APPLICATION_JSON)) {
80-
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
81-
}
82-
((AbstractHttpMessageConverter<?>) converter)
83-
.setSupportedMediaTypes(supportedMediaTypes);
84-
}
85-
}
67+
configureHttpMessageConverters(((ListableBeanFactory) this.beanFactory)
68+
.getBeansOfType(RequestMappingHandlerAdapter.class).values());
69+
}
70+
}
71+
72+
private void configureHttpMessageConverters(
73+
Collection<RequestMappingHandlerAdapter> handlerAdapters) {
74+
for (RequestMappingHandlerAdapter handlerAdapter : handlerAdapters) {
75+
for (HttpMessageConverter<?> messageConverter : handlerAdapter
76+
.getMessageConverters()) {
77+
configureHttpMessageConverter(messageConverter);
78+
}
79+
}
80+
}
8681

82+
private void configureHttpMessageConverter(HttpMessageConverter<?> converter) {
83+
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
84+
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
85+
converter.getSupportedMediaTypes());
86+
if (!supportedMediaTypes.contains(MediaType.APPLICATION_JSON)) {
87+
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
8788
}
89+
((AbstractHttpMessageConverter<?>) converter)
90+
.setSupportedMediaTypes(supportedMediaTypes);
8891
}
8992
}
9093

0 commit comments

Comments
 (0)