|
17 | 17 | package org.springframework.boot.actuate.autoconfigure.cloudfoundry;
|
18 | 18 |
|
19 | 19 | import java.util.Collection;
|
20 |
| -import java.util.Map; |
21 | 20 |
|
22 | 21 | import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
| 22 | +import org.springframework.boot.actuate.endpoint.EndpointInfo; |
23 | 23 | import org.springframework.boot.actuate.endpoint.reflect.OperationMethodInvokerAdvisor;
|
24 | 24 | import org.springframework.boot.actuate.endpoint.reflect.ParameterMapper;
|
25 | 25 | import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
|
30 | 30 | import org.springframework.context.ApplicationContext;
|
31 | 31 |
|
32 | 32 | /**
|
33 |
| - * {@link WebAnnotationEndpointDiscoverer} for Cloud Foundry that uses Cloud Foundry specific |
34 |
| - * extensions for the {@link HealthEndpoint}. |
| 33 | + * {@link WebAnnotationEndpointDiscoverer} for Cloud Foundry that uses Cloud Foundry |
| 34 | + * specific extensions for the {@link HealthEndpoint}. |
35 | 35 | *
|
36 | 36 | * @author Madhura Bhave
|
37 | 37 | */
|
38 |
| -public class CloudFoundryWebAnnotationEndpointDiscoverer extends WebAnnotationEndpointDiscoverer { |
39 |
| - |
40 |
| - private final ApplicationContext applicationContext; |
| 38 | +public class CloudFoundryWebAnnotationEndpointDiscoverer |
| 39 | + extends WebAnnotationEndpointDiscoverer { |
41 | 40 |
|
42 | 41 | private final Class<?> requiredExtensionType;
|
43 | 42 |
|
44 |
| - public CloudFoundryWebAnnotationEndpointDiscoverer(ApplicationContext applicationContext, ParameterMapper parameterMapper, |
45 |
| - EndpointMediaTypes endpointMediaTypes, EndpointPathResolver endpointPathResolver, |
46 |
| - Collection<? extends OperationMethodInvokerAdvisor> invokerAdvisors, Collection<? extends EndpointFilter<WebOperation>> filters, Class<?> requiredExtensionType) { |
47 |
| - super(applicationContext, parameterMapper, endpointMediaTypes, endpointPathResolver, invokerAdvisors, filters); |
48 |
| - this.applicationContext = applicationContext; |
| 43 | + public CloudFoundryWebAnnotationEndpointDiscoverer( |
| 44 | + ApplicationContext applicationContext, ParameterMapper parameterMapper, |
| 45 | + EndpointMediaTypes endpointMediaTypes, |
| 46 | + EndpointPathResolver endpointPathResolver, |
| 47 | + Collection<? extends OperationMethodInvokerAdvisor> invokerAdvisors, |
| 48 | + Collection<? extends EndpointFilter<WebOperation>> filters, |
| 49 | + Class<?> requiredExtensionType) { |
| 50 | + super(applicationContext, parameterMapper, endpointMediaTypes, |
| 51 | + endpointPathResolver, invokerAdvisors, filters); |
49 | 52 | this.requiredExtensionType = requiredExtensionType;
|
50 | 53 | }
|
51 | 54 |
|
52 | 55 | @Override
|
53 |
| - protected void addExtension(Map<Class<?>, DiscoveredEndpoint> endpoints, Map<Class<?>, DiscoveredExtension> extensions, String beanName) { |
54 |
| - Class<?> extensionType = this.applicationContext.getType(beanName); |
55 |
| - Class<?> endpointType = getEndpointType(extensionType); |
56 |
| - if (HealthEndpoint.class.equals(endpointType) && !this.requiredExtensionType.equals(extensionType)) { |
57 |
| - return; |
| 56 | + protected boolean isExtensionExposed(Class<?> endpointType, Class<?> extensionType, |
| 57 | + EndpointInfo<WebOperation> endpointInfo) { |
| 58 | + if (HealthEndpoint.class.equals(endpointType) |
| 59 | + && !this.requiredExtensionType.equals(extensionType)) { |
| 60 | + return false; |
58 | 61 | }
|
59 |
| - super.addExtension(endpoints, extensions, beanName); |
| 62 | + return super.isExtensionExposed(endpointType, extensionType, endpointInfo); |
60 | 63 | }
|
61 | 64 |
|
62 | 65 | }
|
63 |
| - |
|
0 commit comments