|
| 1 | +/* |
| 2 | + * Copyright 2012-2017 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.boot.actuate.autoconfigure.cloudfoundry; |
| 18 | + |
| 19 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryReactiveHealthEndpointWebExtension; |
| 20 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveCloudFoundryActuatorAutoConfiguration; |
| 21 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundryActuatorAutoConfiguration; |
| 22 | +import org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundryHealthEndpointWebExtension; |
| 23 | +import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; |
| 24 | +import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; |
| 25 | +import org.springframework.boot.actuate.health.HealthEndpoint; |
| 26 | +import org.springframework.boot.actuate.health.HealthStatusHttpMapper; |
| 27 | +import org.springframework.boot.actuate.health.ReactiveHealthIndicator; |
| 28 | +import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
| 29 | +import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
| 30 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
| 31 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
| 32 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; |
| 33 | +import org.springframework.context.annotation.Bean; |
| 34 | +import org.springframework.context.annotation.Configuration; |
| 35 | + |
| 36 | +/** |
| 37 | + * Configuration for Cloud Foundry Health endpoint extensions. |
| 38 | + * |
| 39 | + * @author Madhura Bhave |
| 40 | + */ |
| 41 | +@Configuration |
| 42 | +@AutoConfigureBefore({ ReactiveCloudFoundryActuatorAutoConfiguration.class, CloudFoundryActuatorAutoConfiguration.class }) |
| 43 | +@AutoConfigureAfter(HealthEndpointAutoConfiguration.class) |
| 44 | +public class CloudFoundryHealthWebEndpointManagementContextConfiguration { |
| 45 | + |
| 46 | + @Configuration |
| 47 | + @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) |
| 48 | + static class ServletWebHealthConfiguration { |
| 49 | + |
| 50 | + @Bean |
| 51 | + @ConditionalOnMissingBean |
| 52 | + @ConditionalOnEnabledEndpoint |
| 53 | + @ConditionalOnBean(HealthEndpoint.class) |
| 54 | + public CloudFoundryHealthEndpointWebExtension cloudFoundryHealthEndpointWebExtension( |
| 55 | + HealthEndpoint healthEndpoint, HealthStatusHttpMapper healthStatusHttpMapper) { |
| 56 | + HealthEndpoint delegate = new HealthEndpoint(healthEndpoint.getHealthIndicator(), true); |
| 57 | + return new CloudFoundryHealthEndpointWebExtension(delegate, healthStatusHttpMapper); |
| 58 | + } |
| 59 | + |
| 60 | + } |
| 61 | + |
| 62 | + @Configuration |
| 63 | + @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE) |
| 64 | + static class ReactiveWebHealthConfiguration { |
| 65 | + |
| 66 | + @Bean |
| 67 | + @ConditionalOnMissingBean |
| 68 | + @ConditionalOnEnabledEndpoint |
| 69 | + @ConditionalOnBean(HealthEndpoint.class) |
| 70 | + public CloudFoundryReactiveHealthEndpointWebExtension cloudFoundryReactiveHealthEndpointWebExtension( |
| 71 | + ReactiveHealthIndicator reactiveHealthIndicator, |
| 72 | + HealthStatusHttpMapper healthStatusHttpMapper) { |
| 73 | + return new CloudFoundryReactiveHealthEndpointWebExtension(reactiveHealthIndicator, |
| 74 | + healthStatusHttpMapper); |
| 75 | + } |
| 76 | + |
| 77 | + } |
| 78 | + |
| 79 | +} |
0 commit comments