Annotation Type ConditionalOnEnabledEndpoint


  • @Retention(RUNTIME)
    @Target(METHOD)
    @Documented
    @Conditional(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 endpoints specific Environment property, falling back to management.endpoints.enabled-by-default or failing that Endpoint.enableByDefault().

    When placed on a @Bean method, the endpoint defaults to the return type of the factory method:

     @Configuration
     public class MyConfiguration {
    
         @ConditionalOnEnableEndpoint
         @Bean
         public MyEndpoint myEndpoint() {
             ...
         }
    
     }

    It is also possible to use the same mechanism for extensions:

     @Configuration
     public class MyConfiguration {
    
         @ConditionalOnEnableEndpoint
         @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 {
    
         @ConditionalOnEnableEndpoint(endpoint = MyEndpoint.class)
         @Bean
         public MyComponent myComponent() {
             ...
         }
    
     }
    Since:
    2.0.0
    See Also:
    Endpoint
    • Optional Element Summary

      Optional Elements 
      Modifier and TypeOptional ElementDescription
      Class<?>endpoint
      The endpoint type that should be checked.
    • Element Detail

      • endpoint

        Class<?> endpoint
        The endpoint type that should be checked. Inferred when the return type of the @Bean method is either an Endpoint or an EndpointExtension.
        Returns:
        the endpoint type to check
        Since:
        2.0.6
        Default:
        java.lang.Void.class