Java 类org.springframework.context.annotation.ConditionContext 实例源码

项目: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");
    }
}
项目:spring-boot-autoconfigure    文件:OnBeansCondition.java   
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata, Class<?> annotationType) {
    this.annotationType = annotationType;
    MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(annotationType.getName(), true);
    collect(attributes, "name", this.names);
    collect(attributes, "value", this.types);
    collect(attributes, "type", this.types);
    collect(attributes, "annotation", this.annotations);
    collect(attributes, "ignored", this.ignoredTypes);
    collect(attributes, "ignoredType", this.ignoredTypes);
    this.strategy = (SearchStrategy) metadata.getAnnotationAttributes(annotationType.getName()).get("search");
    BeanTypeDeductionException deductionException = null;
    try {
        if (this.types.isEmpty() && this.names.isEmpty()) {
            addDeducedBeanType(context, metadata, this.types);
        }
    } catch (BeanTypeDeductionException ex) {
        deductionException = ex;
    }
    validate(deductionException);
}
项目: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));
}
项目:juiser    文件:JuiserSpringSecurityCondition.java   
private boolean isSpringSecurityEnabled(ConditionContext ctx) {

        boolean enabled = true;

        Environment env = ctx.getEnvironment();

        for (String propName : props) {
            if (env.containsProperty(propName)) {
                if (!Boolean.parseBoolean(env.getProperty(propName))) {
                    enabled = false;
                    break;
                }
            }
        }

        if (enabled) {
            enabled = ClassUtils.isPresent(SPRING_SEC_CLASS_NAME, ctx.getClassLoader());
        }

        return enabled;
    }
项目:spring-boot-concourse    文件:OnWebApplicationCondition.java   
private ConditionOutcome isWebApplication(ConditionContext context,
        AnnotatedTypeMetadata metadata) {

    if (!ClassUtils.isPresent(WEB_CONTEXT_CLASS, context.getClassLoader())) {
        return ConditionOutcome.noMatch("web application classes not found");
    }

    if (context.getBeanFactory() != null) {
        String[] scopes = context.getBeanFactory().getRegisteredScopeNames();
        if (ObjectUtils.containsElement(scopes, "session")) {
            return ConditionOutcome.match("found web application 'session' scope");
        }
    }

    if (context.getEnvironment() instanceof StandardServletEnvironment) {
        return ConditionOutcome
                .match("found web application StandardServletEnvironment");
    }

    if (context.getResourceLoader() instanceof WebApplicationContext) {
        return ConditionOutcome.match("found web application WebApplicationContext");
    }

    return ConditionOutcome.noMatch("not a web application");
}
项目:spring-boot-concourse    文件:OnWebApplicationCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    boolean webApplicationRequired = metadata
            .isAnnotated(ConditionalOnWebApplication.class.getName());
    ConditionOutcome webApplication = isWebApplication(context, metadata);

    if (webApplicationRequired && !webApplication.isMatch()) {
        return ConditionOutcome.noMatch(webApplication.getMessage());
    }

    if (!webApplicationRequired && webApplication.isMatch()) {
        return ConditionOutcome.noMatch(webApplication.getMessage());
    }

    return ConditionOutcome.match(webApplication.getMessage());
}
项目:lodsve-framework    文件:OnDevelopmentConditional.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    if (!metadata.isAnnotated(ConditionalOnDevelopment.class.getName())) {
        return ConditionOutcome.match(StringUtils.EMPTY);
    }

    Boolean isDevMode = Env.getBoolean("application.devMode", null);
    if (null == isDevMode) {
        isDevMode = Env.getBoolean("application.dev-mode", null);
    }

    isDevMode = null == isDevMode ? false : isDevMode;

    if (!isDevMode) {
        return ConditionOutcome.noMatch("this is not dev-mode!");
    }

    return ConditionOutcome.match("this is dev-mode!");
}
项目:spring-boot-concourse    文件:OnBeanCondition.java   
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata,
        Class<?> annotationType) {
    this.annotationType = annotationType;
    MultiValueMap<String, Object> attributes = metadata
            .getAllAnnotationAttributes(annotationType.getName(), true);
    collect(attributes, "name", this.names);
    collect(attributes, "value", this.types);
    collect(attributes, "type", this.types);
    collect(attributes, "annotation", this.annotations);
    collect(attributes, "ignored", this.ignoredTypes);
    collect(attributes, "ignoredType", this.ignoredTypes);
    this.strategy = (SearchStrategy) metadata
            .getAnnotationAttributes(annotationType.getName()).get("search");
    BeanTypeDeductionException deductionException = null;
    try {
        if (this.types.isEmpty() && this.names.isEmpty()) {
            addDeducedBeanType(context, metadata, this.types);
        }
    }
    catch (BeanTypeDeductionException ex) {
        deductionException = ex;
    }
    validate(deductionException);
}
项目: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    文件: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    文件:OnBeanCondition.java   
private void addDeducedBeanTypeForBeanMethod(ConditionContext context,
        AnnotatedTypeMetadata metadata, final List<String> beanTypes,
        final MethodMetadata methodMetadata) {
    try {
        // We should be safe to load at this point since we are in the
        // REGISTER_BEAN phase
        Class<?> configClass = ClassUtils.forName(
                methodMetadata.getDeclaringClassName(), context.getClassLoader());
        ReflectionUtils.doWithMethods(configClass, new MethodCallback() {
            @Override
            public void doWith(Method method)
                    throws IllegalArgumentException, IllegalAccessException {
                if (methodMetadata.getMethodName().equals(method.getName())) {
                    beanTypes.add(method.getReturnType().getName());
                }
            }
        });
    }
    catch (Throwable ex) {
        throw new BeanTypeDeductionException(
                methodMetadata.getDeclaringClassName(),
                methodMetadata.getMethodName(), ex);
    }
}
项目: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");
}
项目: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");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnBeanCondition.java   
BeanSearchSpec(ConditionContext context, AnnotatedTypeMetadata metadata,
        Class<?> annotationType) {
    this.annotationType = annotationType;
    MultiValueMap<String, Object> attributes = metadata
            .getAllAnnotationAttributes(annotationType.getName(), true);
    collect(attributes, "name", this.names);
    collect(attributes, "value", this.types);
    collect(attributes, "type", this.types);
    collect(attributes, "annotation", this.annotations);
    collect(attributes, "ignored", this.ignoredTypes);
    collect(attributes, "ignoredType", this.ignoredTypes);
    this.strategy = (SearchStrategy) metadata
            .getAnnotationAttributes(annotationType.getName()).get("search");
    BeanTypeDeductionException deductionException = null;
    try {
        if (this.types.isEmpty() && this.names.isEmpty()) {
            addDeducedBeanType(context, metadata, this.types);
        }
    }
    catch (BeanTypeDeductionException ex) {
        deductionException = ex;
    }
    validate(deductionException);
}
项目: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    文件: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    文件: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.");
}
项目: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    文件:OAuth2ResourceServerConfiguration.java   
public static boolean matches(ConditionContext context) {
    Class<AuthorizationServerEndpointsConfigurationBeanCondition> type = AuthorizationServerEndpointsConfigurationBeanCondition.class;
    Conditional conditional = AnnotationUtils.findAnnotation(type,
            Conditional.class);
    StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(type);
    for (Class<? extends Condition> conditionType : conditional.value()) {
        Condition condition = BeanUtils.instantiateClass(conditionType);
        if (condition.matches(context, metadata)) {
            return true;
        }
    }
    return false;
}
项目: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"));
}
项目:cornerstone    文件:NoneFilterRegistrationCondition.java   
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
    try {
        Class.forName("org.springframework.boot.context.embedded.FilterRegistrationBean");
        return false;
    }catch (Throwable e){
        try{
            Class.forName("org.springframework.boot.web.servlet.FilterRegistrationBean");
            return true;
        }catch (Throwable e1){
            return false;
        }
    }
}
项目:cornerstone    文件:FilterRegistrationCondition.java   
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
    try {
        Class.forName("org.springframework.boot.context.embedded.FilterRegistrationBean");
        return true;
    }catch (Throwable e){
        return false;
    }
}
项目: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;
  }
项目:centraldogma    文件:CentralDogmaConfiguration.java   
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
    final String[] beanNames =
            BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, ClientFactory.class);

    for (String beanName : beanNames) {
        if (hasQualifier(beanFactory, beanName)) {
            return false;
        }
    }

    return true;
}
项目: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"));
}
项目:syndesis    文件:HttpComponentAutoConfiguration.java   
private boolean isEnabled(
    org.springframework.context.annotation.ConditionContext context,
    java.lang.String prefix, boolean defaultValue) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
        context.getEnvironment(), prefix);
    return resolver.getProperty("enabled", Boolean.class, defaultValue);
}