Search in sources :

Example 1 with ConditionMessage

use of org.springframework.boot.autoconfigure.condition.ConditionMessage in project spring-boot by spring-projects.

the class OnEnabledEndpointCondition method determineEndpointOutcome.

private ConditionOutcome determineEndpointOutcome(String endpointName, boolean enabledByDefault, ConditionContext context) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "endpoints." + endpointName + ".");
    if (resolver.containsProperty("enabled") || !enabledByDefault) {
        boolean match = resolver.getProperty("enabled", Boolean.class, enabledByDefault);
        ConditionMessage message = ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class, "(" + endpointName + ")").because(match ? "enabled" : "disabled");
        return new ConditionOutcome(match, message);
    }
    return null;
}
Also used : ConditionMessage(org.springframework.boot.autoconfigure.condition.ConditionMessage) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Example 2 with ConditionMessage

use of org.springframework.boot.autoconfigure.condition.ConditionMessage in project spring-boot by spring-projects.

the class OnEnabledEndpointCondition method determineAllEndpointsOutcome.

private ConditionOutcome determineAllEndpointsOutcome(ConditionContext context) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), "endpoints.");
    boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
    ConditionMessage message = ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class).because("All endpoints are " + (match ? "enabled" : "disabled") + " by default");
    return new ConditionOutcome(match, message);
}
Also used : ConditionMessage(org.springframework.boot.autoconfigure.condition.ConditionMessage) RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Aggregations

ConditionMessage (org.springframework.boot.autoconfigure.condition.ConditionMessage)2 ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)2 RelaxedPropertyResolver (org.springframework.boot.bind.RelaxedPropertyResolver)2