@Retention(value=RUNTIME) @Target(value=METHOD) @Documented @Conditional(value=org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition.class) public @interface ConditionalOnEnabledEndpoint
Conditional
that checks whether an endpoint is enabled or not. Matches
according to the defaultEnablement
and types
flag that the
Endpoint
may be restricted to.
When an endpoint uses DefaultEnablement.DISABLED
, it will only be enabled if
endpoint.<name>.enabled
, endpoint.<name>.jmx.enabled
or
endpoint.<name>.web.enabled
is true
.
When an endpoint uses DefaultEnablement.ENABLED
, it will be enabled unless
endpoint.<name>.enabled
, endpoint.<name>.jmx.enabled
or
endpoint.<name>.web.enabled
is false
.
When an endpoint uses DefaultEnablement.NEUTRAL
, it will be enabled if
endpoint.default.enabled
, endpoint.default.jmx.enabled
or
endpoint.default.web.enabled
is true
and
endpoint.<name>.enabled
, endpoint.<name>.jmx.enabled
or
endpoint.<name>.web.enabled
has not been set to false
.
If any properties are set, they are evaluated from most to least specific, e.g.
considering a web endpoint with id foo
:
endpoints.default.enabled
is false
but
endpoints.<name>.enabled
is true
, the condition will match.
This condition must be placed on a @Bean
method producing an endpoint as its id
and other attributes are inferred from the Endpoint
annotation set on the
return type of the factory method. Consider the following valid example:
@Configuration public class MyAutoConfiguration { @ConditionalOnEnabledEndpoint @Bean public MyEndpoint myEndpoint() { ... } @Endpoint(id = "my", defaultEnablement = DefaultEnablement.DISABLED) static class MyEndpoint { ... } }
In the sample above the condition will be evaluated with the attributes specified on
MyEndpoint
. In particular, in the absence of any property in the environment,
the condition will not match as this endpoint is disabled by default.
Endpoint
Copyright © 2017 Pivotal Software, Inc.. All rights reserved.