1616
1717package org .springframework .boot .actuate .autoconfigure ;
1818
19+ import java .util .Collections ;
1920import java .util .List ;
2021import java .util .Set ;
2122
22- import org .springframework .beans .factory .annotation . Autowired ;
23+ import org .springframework .beans .factory .ObjectProvider ;
2324import org .springframework .boot .actuate .condition .ConditionalOnEnabledEndpoint ;
2425import org .springframework .boot .actuate .endpoint .Endpoint ;
2526import org .springframework .boot .actuate .endpoint .EnvironmentEndpoint ;
6768 EndpointCorsProperties .class })
6869public class EndpointWebMvcManagementContextConfiguration {
6970
70- @ Autowired
71- private HealthMvcEndpointProperties healthMvcEndpointProperties ;
71+ private final HealthMvcEndpointProperties healthMvcEndpointProperties ;
7272
73- @ Autowired
74- private ManagementServerProperties managementServerProperties ;
73+ private final ManagementServerProperties managementServerProperties ;
7574
76- @ Autowired
77- private EndpointCorsProperties corsProperties ;
75+ private final EndpointCorsProperties corsProperties ;
7876
79- @ Autowired (required = false )
80- private List <EndpointHandlerMappingCustomizer > mappingCustomizers ;
77+ private final List <EndpointHandlerMappingCustomizer > mappingCustomizers ;
78+
79+ public EndpointWebMvcManagementContextConfiguration (
80+ HealthMvcEndpointProperties healthMvcEndpointProperties ,
81+ ManagementServerProperties managementServerProperties ,
82+ EndpointCorsProperties corsProperties ,
83+ ObjectProvider <List <EndpointHandlerMappingCustomizer >> mappingCustomizersProvider ) {
84+ this .healthMvcEndpointProperties = healthMvcEndpointProperties ;
85+ this .managementServerProperties = managementServerProperties ;
86+ this .corsProperties = corsProperties ;
87+ List <EndpointHandlerMappingCustomizer > providedCustomizers = mappingCustomizersProvider
88+ .getIfAvailable ();
89+ this .mappingCustomizers = providedCustomizers == null
90+ ? Collections .<EndpointHandlerMappingCustomizer >emptyList ()
91+ : providedCustomizers ;
92+ }
8193
8294 @ Bean
8395 @ ConditionalOnMissingBean
@@ -87,10 +99,8 @@ public EndpointHandlerMapping endpointHandlerMapping() {
8799 EndpointHandlerMapping mapping = new EndpointHandlerMapping (endpoints ,
88100 corsConfiguration );
89101 mapping .setPrefix (this .managementServerProperties .getContextPath ());
90- if (this .mappingCustomizers != null ) {
91- for (EndpointHandlerMappingCustomizer customizer : this .mappingCustomizers ) {
92- customizer .customize (mapping );
93- }
102+ for (EndpointHandlerMappingCustomizer customizer : this .mappingCustomizers ) {
103+ customizer .customize (mapping );
94104 }
95105 return mapping ;
96106 }
0 commit comments