Search in sources :

Example 1 with EndpointExposure

use of org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure in project spring-boot by spring-projects.

the class OnAvailableEndpointCondition method getMatchOutcome.

private ConditionOutcome getMatchOutcome(Environment environment, MergedAnnotation<ConditionalOnAvailableEndpoint> conditionAnnotation, MergedAnnotation<Endpoint> endpointAnnotation) {
    ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnAvailableEndpoint.class);
    EndpointId endpointId = EndpointId.of(environment, endpointAnnotation.getString("id"));
    ConditionOutcome enablementOutcome = getEnablementOutcome(environment, endpointAnnotation, endpointId, message);
    if (!enablementOutcome.isMatch()) {
        return enablementOutcome;
    }
    Set<EndpointExposure> exposuresToCheck = getExposuresToCheck(conditionAnnotation);
    Set<ExposureFilter> exposureFilters = getExposureFilters(environment);
    for (ExposureFilter exposureFilter : exposureFilters) {
        if (exposuresToCheck.contains(exposureFilter.getExposure()) && exposureFilter.isExposed(endpointId)) {
            return ConditionOutcome.match(message.because("marked as exposed by a 'management.endpoints." + exposureFilter.getExposure().name().toLowerCase() + ".exposure' property"));
        }
    }
    return ConditionOutcome.noMatch(message.because("no 'management.endpoints' property marked it as exposed"));
}
Also used : ConditionMessage(org.springframework.boot.autoconfigure.condition.ConditionMessage) EndpointId(org.springframework.boot.actuate.endpoint.EndpointId) EndpointExposure(org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Aggregations

EndpointExposure (org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure)1 EndpointId (org.springframework.boot.actuate.endpoint.EndpointId)1 ConditionMessage (org.springframework.boot.autoconfigure.condition.ConditionMessage)1 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)1