Search in sources :

Example 6 with ConditionOutcome

use of org.springframework.boot.autoconfigure.condition.ConditionOutcome 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 7 with ConditionOutcome

use of org.springframework.boot.autoconfigure.condition.ConditionOutcome 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)

Example 8 with ConditionOutcome

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

the class NoSuchBeanDefinitionFailureAnalyzer method collectExcludedAutoConfiguration.

private void collectExcludedAutoConfiguration(NoSuchBeanDefinitionException cause, List<AutoConfigurationResult> results) {
    for (String excludedClass : this.report.getExclusions()) {
        Source source = new Source(excludedClass);
        BeanMethods methods = new BeanMethods(source, cause);
        for (MethodMetadata method : methods) {
            String message = String.format("auto-configuration '%s' was excluded", ClassUtils.getShortName(excludedClass));
            results.add(new AutoConfigurationResult(method, new ConditionOutcome(false, message), false));
        }
    }
}
Also used : MethodMetadata(org.springframework.core.type.MethodMetadata) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Example 9 with ConditionOutcome

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

the class OnEnabledEndpointElementCondition method getDefaultEndpointsOutcome.

protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(), this.prefix + "defaults.");
    boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
    return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType).because(this.prefix + "defaults.enabled is considered " + match));
}
Also used : RelaxedPropertyResolver(org.springframework.boot.bind.RelaxedPropertyResolver) ConditionOutcome(org.springframework.boot.autoconfigure.condition.ConditionOutcome)

Aggregations

ConditionOutcome (org.springframework.boot.autoconfigure.condition.ConditionOutcome)9 RelaxedPropertyResolver (org.springframework.boot.bind.RelaxedPropertyResolver)3 Test (org.junit.Test)2 ConditionMessage (org.springframework.boot.autoconfigure.condition.ConditionMessage)2 AnnotationAttributes (org.springframework.core.annotation.AnnotationAttributes)2 ServerSocket (java.net.ServerSocket)1 ConditionContext (org.springframework.context.annotation.ConditionContext)1 MethodMetadata (org.springframework.core.type.MethodMetadata)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1