Merge branch '1.5.x'

This commit is contained in:
Andy Wilkinson 2016-12-05 10:48:49 +00:00
commit d0b1cad00f
2 changed files with 30 additions and 17 deletions

View File

@ -16,10 +16,11 @@
package org.springframework.boot.actuate.autoconfigure; package org.springframework.boot.actuate.autoconfigure;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint; import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.endpoint.EnvironmentEndpoint; import org.springframework.boot.actuate.endpoint.EnvironmentEndpoint;
@ -67,17 +68,28 @@ import org.springframework.web.cors.CorsConfiguration;
EndpointCorsProperties.class }) EndpointCorsProperties.class })
public class EndpointWebMvcManagementContextConfiguration { public class EndpointWebMvcManagementContextConfiguration {
@Autowired private final HealthMvcEndpointProperties healthMvcEndpointProperties;
private HealthMvcEndpointProperties healthMvcEndpointProperties;
@Autowired private final ManagementServerProperties managementServerProperties;
private ManagementServerProperties managementServerProperties;
@Autowired private final EndpointCorsProperties corsProperties;
private EndpointCorsProperties corsProperties;
@Autowired(required = false) private final List<EndpointHandlerMappingCustomizer> mappingCustomizers;
private List<EndpointHandlerMappingCustomizer> mappingCustomizers;
public EndpointWebMvcManagementContextConfiguration(
HealthMvcEndpointProperties healthMvcEndpointProperties,
ManagementServerProperties managementServerProperties,
EndpointCorsProperties corsProperties,
ObjectProvider<List<EndpointHandlerMappingCustomizer>> mappingCustomizersProvider) {
this.healthMvcEndpointProperties = healthMvcEndpointProperties;
this.managementServerProperties = managementServerProperties;
this.corsProperties = corsProperties;
List<EndpointHandlerMappingCustomizer> providedCustomizers = mappingCustomizersProvider
.getIfAvailable();
this.mappingCustomizers = providedCustomizers == null
? Collections.<EndpointHandlerMappingCustomizer>emptyList()
: providedCustomizers;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@ -87,10 +99,8 @@ public class EndpointWebMvcManagementContextConfiguration {
EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints, EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints,
corsConfiguration); corsConfiguration);
mapping.setPrefix(this.managementServerProperties.getContextPath()); mapping.setPrefix(this.managementServerProperties.getContextPath());
if (this.mappingCustomizers != null) { for (EndpointHandlerMappingCustomizer customizer : this.mappingCustomizers) {
for (EndpointHandlerMappingCustomizer customizer : this.mappingCustomizers) { customizer.customize(mapping);
customizer.customize(mapping);
}
} }
return mapping; return mapping;
} }

View File

@ -21,7 +21,7 @@ import javax.management.MBeanServer;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@ -66,13 +66,16 @@ public class IntegrationAutoConfiguration {
protected static class IntegrationJmxConfiguration protected static class IntegrationJmxConfiguration
implements EnvironmentAware, BeanFactoryAware { implements EnvironmentAware, BeanFactoryAware {
private final IntegrationManagementConfigurer configurer;
private BeanFactory beanFactory; private BeanFactory beanFactory;
private RelaxedPropertyResolver propertyResolver; private RelaxedPropertyResolver propertyResolver;
@Autowired(required = false) protected IntegrationJmxConfiguration(
@Qualifier(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME) @Qualifier(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME) ObjectProvider<IntegrationManagementConfigurer> configurerProvider) {
private IntegrationManagementConfigurer configurer; this.configurer = configurerProvider.getIfAvailable();
}
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) throws BeansException {