-
Notifications
You must be signed in to change notification settings - Fork 41k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support isolated actuator ObjectMapper
Add `OperationResponseBody` tagging interface that can be used to trigger the use of an isolated ObjectMapper specifically for actuator responses. The isolated mapper is provided by an `EndpointObjectMapper` bean which is auto-configured unless specifically disabled by the user. WebMVC, WebFlux and Jersey integrations have been updated to provide a link between the `OperationResponseBody` type and the endpoint `ObjectMapper`. See gh-20291
- Loading branch information
Showing
18 changed files
with
622 additions
and
4 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...amework/boot/actuate/autoconfigure/endpoint/jackson/JacksonEndpointAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2012-2022 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.boot.actuate.autoconfigure.endpoint.jackson; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import org.springframework.boot.actuate.endpoint.jackson.EndpointObjectMapper; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; | ||
|
||
/** | ||
* {@link EnableAutoConfiguration Auto-configuration} for Endpoint Jackson support. | ||
* | ||
* @author Phillip Webb | ||
* @since 3.0.0 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@AutoConfigureAfter(JacksonAutoConfiguration.class) | ||
public class JacksonEndpointAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnProperty(name = "management.endpoints.jackson.isolated-object-mapper", matchIfMissing = true) | ||
@ConditionalOnClass({ ObjectMapper.class, Jackson2ObjectMapperBuilder.class }) | ||
public EndpointObjectMapper endpointObjectMapper() { | ||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); | ||
return () -> objectMapper; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...in/java/org/springframework/boot/actuate/autoconfigure/endpoint/jackson/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2012-2022 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. | ||
*/ | ||
|
||
/** | ||
* Actuator Jackson auto-configuration. | ||
*/ | ||
package org.springframework.boot.actuate.autoconfigure.endpoint.jackson; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.