@Retention(value=RUNTIME) @Target(value={METHOD,TYPE}) @Documented @Conditional(value=org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnExposedEndpointCondition.class) public @interface ConditionalOnExposedEndpoint
Conditional that checks whether an endpoint is exposed or not. Matches
according to the endpoint exposure configuration Environment properties. This
is designed as a companion annotation to ConditionalOnEnabledEndpoint.
For a given Endpoint, the condition will match if:
"management.endpoints.web.exposure.*" expose this endpoint"management.endpoints.jmx.exposure.*" expose this
endpointCloudPlatform.CLOUD_FOUNDRY@Bean method, the endpoint defaults to the return type of the
factory method:
@Configuration
public class MyConfiguration {
@ConditionalOnExposedEndpoint
@Bean
public MyEndpoint myEndpoint() {
...
}
}
It is also possible to use the same mechanism for extensions:
@Configuration
public class MyConfiguration {
@ConditionalOnExposedEndpoint
@Bean
public MyEndpointWebExtension myEndpointWebExtension() {
...
}
}
In the sample above, MyEndpointWebExtension will be created if the endpoint is
enabled as defined by the rules above. MyEndpointWebExtension must be a regular
extension that refers to an endpoint, something like:
@EndpointWebExtension(endpoint = MyEndpoint.class)
public class MyEndpointWebExtension {
}
Alternatively, the target endpoint can be manually specified for components that should only be created when a given endpoint is enabled:
@Configuration
public class MyConfiguration {
@ConditionalOnExposedEndpoint(endpoint = MyEndpoint.class)
@Bean
public MyComponent myComponent() {
...
}
}Endpoint,
ConditionalOnEnabledEndpointpublic abstract Class<?> endpoint
@Bean method is either an Endpoint or an EndpointExtension.Copyright © 2019 Pivotal Software, Inc.. All rights reserved.