Java 类org.springframework.boot.autoconfigure.condition.ConditionOutcome 实例源码

项目:spring-security-oauth2-boot    文件:ResourceServerTokenServicesConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("OAuth JWT Condition");
    Environment environment = context.getEnvironment();
    String keyValue = environment
            .getProperty("security.oauth2.resource.jwt.key-value");
    String keyUri = environment
            .getProperty("security.oauth2.resource.jwt.key-uri");
    if (StringUtils.hasText(keyValue) || StringUtils.hasText(keyUri)) {
        return ConditionOutcome
                .match(message.foundExactly("provided public key"));
    }
    return ConditionOutcome
            .noMatch(message.didNotFind("provided public key").atAll());
}
项目:spring-security-oauth2-boot    文件:EnableOAuth2SsoCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    String[] enablers = context.getBeanFactory()
            .getBeanNamesForAnnotation(EnableOAuth2Sso.class);
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("@EnableOAuth2Sso Condition");
    for (String name : enablers) {
        if (context.getBeanFactory().isTypeMatch(name,
                WebSecurityConfigurerAdapter.class)) {
            return ConditionOutcome.match(message
                    .found("@EnableOAuth2Sso annotation on WebSecurityConfigurerAdapter")
                    .items(name));
        }
    }
    return ConditionOutcome.noMatch(message.didNotFind(
            "@EnableOAuth2Sso annotation " + "on any WebSecurityConfigurerAdapter")
            .atAll());
}
项目:spring-cloud-vault-connector    文件:VaultConnectorBootstrapConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {

    CloudFactory cloudFactory = new CloudFactory();
    try {
        Cloud cloud = cloudFactory.getCloud();
        List<ServiceInfo> serviceInfos = cloud.getServiceInfos();

        for (ServiceInfo serviceInfo : serviceInfos) {
            if (serviceInfo instanceof VaultServiceInfo) {
                return ConditionOutcome.match(String.format(
                        "Found Vault service %s", serviceInfo.getId()));
            }
        }

        return ConditionOutcome.noMatch("No Vault service found");
    }
    catch (CloudException e) {
        return ConditionOutcome.noMatch("Not running in a Cloud");
    }
}
项目:holon-jaxrs    文件:SwaggerApiAutoDetectCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    final RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
            "holon.swagger.");

    if (!resolver.getProperty("holon.swagger.enabled", boolean.class, true)) {
        return ConditionOutcome.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition")
                .because("holon.swagger.enabled is false"));
    }

    if (resolver.containsProperty("resourcePackage")) {
        return ConditionOutcome.noMatch(
                ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("resourcePackage"));
    }
    Map<String, Object> ag = resolver.getSubProperties("apiGroups");
    if (ag != null && ag.size() > 0) {
        return ConditionOutcome
                .noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("apiGroups"));
    }
    return ConditionOutcome.match();
}
项目:spring-boot-multidatasource    文件:DataSourceAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("EmbeddedDataSource");
    if (anyMatches(context, metadata, this.pooledCondition)) {
        return ConditionOutcome
                .noMatch(message.foundExactly("supported pooled data source"));
    }
    EmbeddedDatabaseType type = EmbeddedDatabaseConnection
            .get(context.getClassLoader()).getType();
    if (type == null) {
        return ConditionOutcome
                .noMatch(message.didNotFind("embedded database").atAll());
    }
    return ConditionOutcome.match(message.found("embedded database").items(type));
}
项目:spring-boot-multidatasource    文件:DataSourceAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("DataSourceAvailable");
    if (hasBean(context, DataSource.class)
            || hasBean(context, XADataSource.class)) {
        return ConditionOutcome
                .match(message.foundExactly("existing data source bean"));
    }
    if (anyMatches(context, metadata, this.pooledCondition,
            this.embeddedCondition)) {
        return ConditionOutcome.match(message
                .foundExactly("existing auto-configured data source bean"));
    }
    return ConditionOutcome
            .noMatch(message.didNotFind("any existing data source bean").atAll());
}
项目:holon-core    文件:OnPropertyPrefixCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnPropertyPrefix.class.getName());
    if (attributes.containsKey("value")) {
        String prefix = (String) attributes.get("value");
        if (prefix != null && !prefix.trim().equals("")) {
            final String propertyPrefix = !prefix.endsWith(".") ? prefix + "." : prefix;
            ConfigPropertyProvider configPropertyProvider = EnvironmentConfigPropertyProvider
                    .create(context.getEnvironment());
            Set<String> names = configPropertyProvider.getPropertyNames()
                    .filter((n) -> n.startsWith(propertyPrefix)).collect(Collectors.toSet());
            if (!names.isEmpty()) {
                return ConditionOutcome.match();
            }
            return ConditionOutcome.noMatch(
                    ConditionMessage.forCondition(ConditionalOnPropertyPrefix.class).notAvailable(propertyPrefix));
        }
    }
    return ConditionOutcome.match();
}
项目:loc-framework    文件:PrefixPropertyCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  String prefix = (String) attribute(metadata, "prefix");
  Class<?> value = (Class<?>) attribute(metadata, "value");
  ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
  try {
    new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
        .bind(prefix, Bindable.of(value))
        .orElseThrow(
            () -> new FatalBeanException("Could not bind DataSourceSettings properties"));
    return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
  } catch (Exception e) {
    //ignore
  }
  return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcManagementContextConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    String config = environment.resolvePlaceholders("${logging.file:}");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome.match("Found logging.file: " + config);
    }
    config = environment.resolvePlaceholders("${logging.path:}");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome.match("Found logging.path: " + config);
    }
    config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
            .getProperty("external-file");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome
                .match("Found endpoints.logfile.external-file: " + config);
    }
    return ConditionOutcome.noMatch("Found no log file configuration");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AutoConfigurationReportEndpointTests.java   
@PostConstruct
public void setupAutoConfigurationReport() {
    ConditionEvaluationReport report = ConditionEvaluationReport
            .get(this.context.getBeanFactory());
    report.recordConditionEvaluation("a", mock(Condition.class),
            mock(ConditionOutcome.class));
    report.recordExclusions(Arrays.asList("com.foo.Bar"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnEnabledResourceChainCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConfigurableEnvironment environment = (ConfigurableEnvironment) context
            .getEnvironment();
    ResourceProperties properties = new ResourceProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
    binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
    Boolean match = properties.getChain().getEnabled();
    if (match == null) {
        boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
                getClass().getClassLoader());
        return new ConditionOutcome(webJarsLocatorPresent,
                "Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
                        + (webJarsLocatorPresent ? "present" : "absent"));
    }
    return new ConditionOutcome(match,
            "Resource chain is " + (match ? "enabled" : "disabled"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DispatcherServletAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
    List<String> dispatchServletBeans = Arrays.asList(beanFactory
            .getBeanNamesForType(DispatcherServlet.class, false, false));
    if (dispatchServletBeans.contains(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
        return ConditionOutcome.noMatch("found DispatcherServlet named "
                + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    }
    if (beanFactory.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
        return ConditionOutcome.noMatch("found non-DispatcherServlet named "
                + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    }
    if (dispatchServletBeans.isEmpty()) {
        return ConditionOutcome.match("no DispatcherServlet found");
    }
    return ConditionOutcome
            .match("one or more DispatcherServlets found and none is named "
                    + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceServerTokenServicesConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
            "security.oauth2.resource.");
    Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
            Boolean.class);
    if (preferTokenInfo == null) {
        preferTokenInfo = environment
                .resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
                .equals("true");
    }
    String tokenInfoUri = resolver.getProperty("token-info-uri");
    String userInfoUri = resolver.getProperty("user-info-uri");
    if (!StringUtils.hasLength(userInfoUri)) {
        return ConditionOutcome.match("No user info provided");
    }
    if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
        return ConditionOutcome.match(
                "Token info endpoint " + "is preferred and user info provided");
    }
    return ConditionOutcome.noMatch("Token info endpoint is not provided");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OAuth2ResourceServerConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
            "security.oauth2.resource.");
    if (hasOAuthClientId(environment)) {
        return ConditionOutcome.match("found client id");
    }
    if (!resolver.getSubProperties("jwt").isEmpty()) {
        return ConditionOutcome.match("found JWT resource configuration");
    }
    if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
        return ConditionOutcome
                .match("found UserInfo " + "URI resource configuration");
    }
    if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
        if (AuthorizationServerEndpointsConfigurationBeanCondition
                .matches(context)) {
            return ConditionOutcome.match(
                    "found authorization " + "server endpoints configuration");
        }
    }
    return ConditionOutcome.noMatch("found neither client id nor "
            + "JWT resource nor authorization server");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SessionCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.session.");
    StoreType sessionStoreType = SessionStoreMappings
            .getType(((AnnotationMetadata) metadata).getClassName());
    if (!resolver.containsProperty("store-type")) {
        if (sessionStoreType == StoreType.REDIS && redisPresent) {
            return ConditionOutcome
                    .match("Session store type default to redis (deprecated)");
        }
        return ConditionOutcome.noMatch("Session store type not set");
    }
    String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
    if (value.equals(sessionStoreType.name())) {
        return ConditionOutcome.match("Session store type " + sessionStoreType);
    }
    return ConditionOutcome.noMatch("Session store type " + value);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CacheCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.cache.");
    if (!resolver.containsProperty("type")) {
        return ConditionOutcome.match("Automatic cache type");
    }
    CacheType cacheType = CacheConfigurations
            .getType(((AnnotationMetadata) metadata).getClassName());
    String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
    if (value.equals(cacheType.name())) {
        return ConditionOutcome.match("Cache type " + cacheType);
    }
    return ConditionOutcome.noMatch("Cache type " + value);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JCacheCacheConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.cache.jcache.");
    if (resolver.containsProperty("provider")) {
        return ConditionOutcome.match("JCache provider specified");
    }
    Iterator<CachingProvider> providers = Caching.getCachingProviders()
            .iterator();
    if (!providers.hasNext()) {
        return ConditionOutcome.noMatch("No JSR-107 compliant providers");
    }
    providers.next();
    if (providers.hasNext()) {
        return ConditionOutcome.noMatch(
                "Multiple default JSR-107 compliant " + "providers found");

    }
    return ConditionOutcome.match("Default JSR-107 compliant provider found.");
}
项目:Zipkin    文件:ZipkinMessageListener.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    if ("true".equals(environment
            .resolvePlaceholders("${spring.sleuth.stream.enabled:}"))) {
        return ConditionOutcome
                .noMatch("Found spring.sleuth.stream.enabled=true");
    }
    if (environment instanceof ConfigurableEnvironment) {
        ConfigurableEnvironment configurable = (ConfigurableEnvironment) environment;
        configurable.getPropertySources()
                .addLast(
                        new MapPropertySource("spring.sleuth.stream",
                                Collections.<String, Object>singletonMap(
                                        "spring.sleuth.stream.enabled",
                                        "false")));
    }
    return ConditionOutcome.match("Not found: spring.sleuth.stream.enabled");
}
项目:spring-boot-concourse    文件:EndpointWebMvcManagementContextConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    String config = environment.resolvePlaceholders("${logging.file:}");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome.match("Found logging.file: " + config);
    }
    config = environment.resolvePlaceholders("${logging.path:}");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome.match("Found logging.path: " + config);
    }
    config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
            .getProperty("external-file");
    if (StringUtils.hasText(config)) {
        return ConditionOutcome
                .match("Found endpoints.logfile.external-file: " + config);
    }
    return ConditionOutcome.noMatch("Found no log file configuration");
}
项目:spring-boot-concourse    文件:OnEnabledResourceChainCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConfigurableEnvironment environment = (ConfigurableEnvironment) context
            .getEnvironment();
    ResourceProperties properties = new ResourceProperties();
    RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
    binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
    Boolean match = properties.getChain().getEnabled();
    if (match == null) {
        boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
                getClass().getClassLoader());
        return new ConditionOutcome(webJarsLocatorPresent,
                "Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
                        + (webJarsLocatorPresent ? "present" : "absent"));
    }
    return new ConditionOutcome(match,
            "Resource chain is " + (match ? "enabled" : "disabled"));
}
项目:spring-boot-concourse    文件:DispatcherServletAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
    List<String> dispatchServletBeans = Arrays.asList(beanFactory
            .getBeanNamesForType(DispatcherServlet.class, false, false));
    if (dispatchServletBeans.contains(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
        return ConditionOutcome.noMatch("found DispatcherServlet named "
                + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    }
    if (beanFactory.containsBean(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)) {
        return ConditionOutcome.noMatch("found non-DispatcherServlet named "
                + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
    }
    if (dispatchServletBeans.isEmpty()) {
        return ConditionOutcome.match("no DispatcherServlet found");
    }
    return ConditionOutcome
            .match("one or more DispatcherServlets found and none is named "
                    + DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);
}
项目:spring-boot-concourse    文件:ResourceServerTokenServicesConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
            "security.oauth2.resource.");
    Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
            Boolean.class);
    if (preferTokenInfo == null) {
        preferTokenInfo = environment
                .resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
                .equals("true");
    }
    String tokenInfoUri = resolver.getProperty("token-info-uri");
    String userInfoUri = resolver.getProperty("user-info-uri");
    if (!StringUtils.hasLength(userInfoUri)) {
        return ConditionOutcome.match("No user info provided");
    }
    if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
        return ConditionOutcome.match(
                "Token info endpoint " + "is preferred and user info provided");
    }
    return ConditionOutcome.noMatch("Token info endpoint is not provided");
}
项目:spring-boot-concourse    文件:OAuth2ResourceServerConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    Environment environment = context.getEnvironment();
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
            "security.oauth2.resource.");
    if (hasOAuthClientId(environment)) {
        return ConditionOutcome.match("found client id");
    }
    if (!resolver.getSubProperties("jwt").isEmpty()) {
        return ConditionOutcome.match("found JWT resource configuration");
    }
    if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
        return ConditionOutcome
                .match("found UserInfo " + "URI resource configuration");
    }
    if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
        if (AuthorizationServerEndpointsConfigurationBeanCondition
                .matches(context)) {
            return ConditionOutcome.match(
                    "found authorization " + "server endpoints configuration");
        }
    }
    return ConditionOutcome.noMatch("found neither client id nor "
            + "JWT resource nor authorization server");
}
项目:spring-boot-concourse    文件:SessionCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.session.");
    StoreType sessionStoreType = SessionStoreMappings
            .getType(((AnnotationMetadata) metadata).getClassName());
    if (!resolver.containsProperty("store-type")) {
        if (sessionStoreType == StoreType.REDIS && redisPresent) {
            return ConditionOutcome
                    .match("Session store type default to redis (deprecated)");
        }
        return ConditionOutcome.noMatch("Session store type not set");
    }
    String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
    if (value.equals(sessionStoreType.name())) {
        return ConditionOutcome.match("Session store type " + sessionStoreType);
    }
    return ConditionOutcome.noMatch("Session store type " + value);
}
项目:spring-boot-concourse    文件:CacheCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.cache.");
    if (!resolver.containsProperty("type")) {
        return ConditionOutcome.match("Automatic cache type");
    }
    CacheType cacheType = CacheConfigurations
            .getType(((AnnotationMetadata) metadata).getClassName());
    String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
    if (value.equals(cacheType.name())) {
        return ConditionOutcome.match("Cache type " + cacheType);
    }
    return ConditionOutcome.noMatch("Cache type " + value);
}
项目:spring-boot-concourse    文件:JCacheCacheConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.cache.jcache.");
    if (resolver.containsProperty("provider")) {
        return ConditionOutcome.match("JCache provider specified");
    }
    Iterator<CachingProvider> providers = Caching.getCachingProviders()
            .iterator();
    if (!providers.hasNext()) {
        return ConditionOutcome.noMatch("No JSR-107 compliant providers");
    }
    providers.next();
    if (providers.hasNext()) {
        return ConditionOutcome.noMatch(
                "Multiple default JSR-107 compliant " + "providers found");

    }
    return ConditionOutcome.match("Default JSR-107 compliant provider found.");
}
项目:azure-application-insights-spring-boot-starter    文件:OnOperationSystemCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnOperatingSystem.class.getName());
    OperatingSystem operatingSystem = (OperatingSystem) attributes.get("value");
    ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnOperatingSystem.class);
    String name = operatingSystem.name();
    if (operatingSystem == OperatingSystem.WINDOWS && SystemInformation.INSTANCE.isWindows()) {
        return ConditionOutcome.match(message.foundExactly(name));
    }
    if (operatingSystem == OperatingSystem.UNIX && SystemInformation.INSTANCE.isUnix()) {
        return ConditionOutcome.match(message.foundExactly(name));
    }
    return ConditionOutcome.noMatch(message.didNotFind(name).atAll());
}
项目:spring-security-oauth2-boot    文件:ResourceServerTokenServicesConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("OAuth TokenInfo Condition");
    Environment environment = context.getEnvironment();
    Boolean preferTokenInfo = environment.getProperty(
            "security.oauth2.resource.prefer-token-info", Boolean.class);
    if (preferTokenInfo == null) {
        preferTokenInfo = environment
                .resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
                .equals("true");
    }
    String tokenInfoUri = environment
            .getProperty("security.oauth2.resource.token-info-uri");
    String userInfoUri = environment
            .getProperty("security.oauth2.resource.user-info-uri");
    if (!StringUtils.hasLength(userInfoUri)
            && !StringUtils.hasLength(tokenInfoUri)) {
        return ConditionOutcome
                .match(message.didNotFind("user-info-uri property").atAll());
    }
    if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
        return ConditionOutcome
                .match(message.foundExactly("preferred token-info-uri property"));
    }
    return ConditionOutcome.noMatch(message.didNotFind("token info").atAll());
}
项目:spring-security-oauth2-boot    文件:ResourceServerTokenServicesConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("OAuth JWK Condition");
    Environment environment = context.getEnvironment();
    String keyUri = environment
            .getProperty("security.oauth2.resource.jwk.key-set-uri");
    if (StringUtils.hasText(keyUri)) {
        return ConditionOutcome
                .match(message.foundExactly("provided jwk key set URI"));
    }
    return ConditionOutcome
            .noMatch(message.didNotFind("key jwk set URI not provided").atAll());
}
项目:spring-security-oauth2-boot    文件:OAuth2RestOperationsConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    String clientId = context.getEnvironment()
            .getProperty("security.oauth2.client.client-id");
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("OAuth Client ID");
    if (StringUtils.hasLength(clientId)) {
        return ConditionOutcome.match(message
                .foundExactly("security.oauth2.client.client-id property"));
    }
    return ConditionOutcome.noMatch(message
            .didNotFind("security.oauth2.client.client-id property").atAll());
}
项目:cereebro    文件:OnEnabledDetectorCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledDetector.class.getName()));
    final String name = attributes.getString("value");
    final String prefix = attributes.getString("prefix");
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
            prefix + "." + name + ".");
    Boolean enabled = resolver.getProperty("enabled", Boolean.class, true);
    return new ConditionOutcome(enabled, ConditionMessage.forCondition(ConditionalOnEnabledDetector.class, name)
            .because(enabled ? "enabled" : "disabled"));
}
项目:spring-boot-data-source-decorator    文件:FlexyPoolConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage.forCondition("FlexyPoolConfigurationAvailable");
    String propertiesFilePath = System.getProperty(PropertyLoader.PROPERTIES_FILE_PATH);
    if (propertiesFilePath != null && ClassLoaderUtils.getResource(propertiesFilePath) != null) {
        return ConditionOutcome.match(message.found("FlexyPool configuration file").items(propertiesFilePath));
    }
    if (ClassLoaderUtils.getResource(PropertyLoader.PROPERTIES_FILE_NAME) != null) {
        return ConditionOutcome.match(message.found("FlexyPool configuration file").items(PropertyLoader.PROPERTIES_FILE_NAME));
    }
    return ConditionOutcome.noMatch(message.didNotFind("FlexyPool configuration file").atAll());
}
项目:zipkin-collector-eventhub    文件:EventHubSetCondition.java   
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata a) {

    String eventHubProperty = context.getEnvironment().getProperty(PROPERTY_NAME);
    ConditionOutcome outcome = eventHubProperty == null || eventHubProperty.isEmpty() ?
        ConditionOutcome.noMatch(PROPERTY_NAME + " isn't set") :
        ConditionOutcome.match();

    return outcome;
  }
项目:zipkin-azure    文件:ZipkinEventHubCollectorAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata a) {

  String eventHubProperty = context.getEnvironment().getProperty(PROPERTY_NAME);
  ConditionOutcome outcome = eventHubProperty == null || eventHubProperty.isEmpty() ?
      ConditionOutcome.noMatch(PROPERTY_NAME + " isn't set") :
      ConditionOutcome.match();

  return outcome;
}
项目:syndesis    文件:HttpComponentAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(
    ConditionContext conditionContext,
    AnnotatedTypeMetadata annotatedTypeMetadata) {
    boolean groupEnabled = isEnabled(conditionContext,
        "camel.component.", true);
    ConditionMessage.Builder message = ConditionMessage
        .forCondition("camel.component.syndesis-http");
    if (isEnabled(conditionContext, "camel.component.syndesis-http.",
        groupEnabled)) {
        return ConditionOutcome.match(message.because("enabled"));
    }
    return ConditionOutcome.noMatch(message.because("not enabled"));
}
项目:connectors    文件:HttpComponentAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(
    ConditionContext conditionContext,
    AnnotatedTypeMetadata annotatedTypeMetadata) {
    boolean groupEnabled = isEnabled(conditionContext,
        "camel.component.", true);
    ConditionMessage.Builder message = ConditionMessage
        .forCondition("camel.component.syndesis-http");
    if (isEnabled(conditionContext, "camel.component.syndesis-http.",
        groupEnabled)) {
        return ConditionOutcome.match(message.because("enabled"));
    }
    return ConditionOutcome.noMatch(message.because("not enabled"));
}
项目:quickfixj-spring-boot-starter    文件:QuickFixJConfigResourceCondition.java   
@Override
protected ConditionOutcome getResourceOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    if (System.getProperty(configSystemProperty) != null) {
        return ConditionOutcome.match(startConditionMessage()
                .because("System property '" + configSystemProperty + "' is set."));
    }
    return super.getResourceOutcome(context, metadata);
}
项目:quickfixj-spring-boot-starter    文件:QuickFixJConfigResourceConditionTest.java   
@Test
public void testGetResourceOutcomeForSystemProperty() {
    System.setProperty("anyProperty", "anyValue");
    QuickFixJConfigResourceCondition resourceCondition =
            new ClientConfigAvailableCondition("anyProperty");

    ConditionOutcome conditionOutcome =
            resourceCondition.getResourceOutcome(mock(ConditionContext.class), mock(AnnotatedTypeMetadata.class));
    assertThat(conditionOutcome).isNotNull();
    assertThat(conditionOutcome.getMessage()).contains("ResourceCondition (QuickFixJ) System property 'anyProperty' is set.");
}
项目:quickfixj-spring-boot-starter    文件:QuickFixJConfigResourceConditionTest.java   
@Test
public void testGetResourceOutcomeForSystemPropertyNotSet() {
    QuickFixJConfigResourceCondition resourceCondition =
            new ClientConfigAvailableCondition("any");

    ConditionContext context = mock(ConditionContext.class);
    AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
    ConditionOutcome conditionOutcome =
            resourceCondition.getResourceOutcome(context, metadata);
    assertThat(conditionOutcome).isNotNull();
    assertThat(conditionOutcome.getMessage()).contains("ResourceCondition (QuickFixJ) did not find resource");
}
项目:spring-boot-multidatasource    文件:DataSourceAutoConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    ConditionMessage.Builder message = ConditionMessage
            .forCondition("PooledDataSource");
    if (getDataSourceClassLoader(context) != null) {
        return ConditionOutcome
                .match(message.foundExactly("supported DataSource"));
    }
    return ConditionOutcome
            .noMatch(message.didNotFind("supported DataSource").atAll());
}