@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata annotatedTypeMetadata) { ClientProperties clientProperties = getClientProperties(context); if (!clientProperties.isEnabled()) { return ConditionOutcome.noMatch( "Spring Boot Client is disabled, because 'spring.boot.admin.client.enabled' is false."); } if (clientProperties.getUrl().length == 0) { return ConditionOutcome.noMatch( "Spring Boot Client is disabled, because 'spring.boot.admin.client.url' is empty."); } return ConditionOutcome.match(); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Assert.isInstanceOf(DefaultListableBeanFactory.class, context.getBeanFactory()); DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) context .getBeanFactory(); int foundSenders = listableBeanFactory .getBeanNamesForType(Sender.class).length; // Previously we supported 1 Sender bean at a time // which could be overridden by another auto-configuration. // Now we support both the overridden bean and our default zipkinSender bean. // Since this config is adapting the old config we're searching for exactly 1 // `Sender` bean before `ZipkinAutoConfiguration` kicks in. if (foundSenders != 1) { return ConditionOutcome.noMatch( "None or multiple Sender beans found - no reason to apply backwards compatibility"); } int foundReporters = listableBeanFactory .getBeanNamesForType(Reporter.class).length; // Check if we need to provide a Reporter bean for the overridden Sender bean if (foundReporters > 0) { return ConditionOutcome.noMatch( "The old config setup already defines its own Reporter bean"); } return ConditionOutcome.match(); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); List<String> types = CompositeUtils.getCompositeTypeList(context.getEnvironment()); // get EnvironmentRepository types from registered factories List<Class<? extends EnvironmentRepository>> repositoryTypes = new ArrayList<>(); for (String type : types) { String factoryName = CompositeUtils.getFactoryName(type, beanFactory); Type[] actualTypeArguments = CompositeUtils.getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName); Class<? extends EnvironmentRepository> repositoryType = (Class<? extends EnvironmentRepository>) actualTypeArguments[0]; repositoryTypes.add(repositoryType); } boolean required = metadata.isAnnotated(ConditionalOnSearchPathLocator.class.getName()); boolean foundSearchPathLocator = repositoryTypes.stream().anyMatch(SearchPathLocator.class::isAssignableFrom); if (required && !foundSearchPathLocator) { return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnSearchPathLocator.class).notAvailable(SearchPathLocator.class.getTypeName())); } if (!required && foundSearchPathLocator) { return ConditionOutcome.noMatch(ConditionMessage.forCondition(ConditionalOnMissingSearchPathLocator.class).available(SearchPathLocator.class.getTypeName())); } return ConditionOutcome.match(); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { ConfigTree ct = new ConfigTree((ConfigurableEnvironment) conditionContext.getEnvironment(), "jetcache."); if (match(ct, "local.") || match(ct, "remote.")) { return ConditionOutcome.match(); } else { return ConditionOutcome.noMatch("no match for " + cacheTypes[0]); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata md) { String sourceClass = ""; if (md instanceof ClassMetadata) { sourceClass = ((ClassMetadata) md).getClassName(); } ConditionMessage.Builder message = ConditionMessage.forCondition("ZipkinSender", sourceClass); String property = context.getEnvironment() .getProperty("spring.zipkin.sender.type"); if (StringUtils.isEmpty(property)) { return ConditionOutcome.match(message.because("automatic sender type")); } String senderType = getType(((AnnotationMetadata) md).getClassName()); if (property.equalsIgnoreCase(senderType)) { return ConditionOutcome.match(message.because(property + " sender type")); } return ConditionOutcome.noMatch(message.because(property + " sender type")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Map<String, Object> beanAttributes = metadata.getAnnotationAttributes(Bean.class.getName()); String beanName = ((String[]) beanAttributes.get("name"))[0]; if(StringUtils.isEmpty(beanName)) { throw new IllegalStateException("OnMissingBeanCondition can't detect bean name!"); } boolean missingBean = !context.getBeanFactory().containsBean(context.getEnvironment().resolveRequiredPlaceholders(beanName)); return missingBean ? ConditionOutcome.match(beanName + " not found") : ConditionOutcome.noMatch(beanName + " found"); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); if (hasProperty(environment, "encrypt.key-store.location")) { if (hasProperty(environment, "encrypt.key-store.password")) { return ConditionOutcome.match("Keystore found in Environment"); } return ConditionOutcome .noMatch("Keystore found but no password in Environment"); } else if (hasProperty(environment, "encrypt.key")) { return ConditionOutcome.match("Key found in Environment"); } return ConditionOutcome.noMatch("Keystore nor key found in Environment"); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("Initialized Restarter Condition"); Restarter restarter = getRestarter(); if (restarter == null) { return ConditionOutcome.noMatch(message.because("unavailable")); } if (restarter.getInitialUrls() == null) { return ConditionOutcome.noMatch(message.because("initialized without URLs")); } return ConditionOutcome.match(message.because("available and initialized")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); String toolsBasePackages = environment.getProperty(VELOCITY_TOOLS_BASE_PACKAGES_PROPERTY_NAME); if (!StringUtils.hasText(toolsBasePackages)) { return ConditionOutcome.noMatch("Velocity Tools scanning is disabled , since its base packages is empty !"); } return ConditionOutcome.match(); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); String toolsBasePackages = environment.getProperty(VELOCITY_TOOLS_BASE_PACKAGES_PROPERTY_NAME); if (!StringUtils.hasText(toolsBasePackages)) { return ConditionOutcome.noMatch("Velocity Tools scanning is disabled , since its base packages is empty !"); } return ConditionOutcome.match(); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { org.apache.logging.log4j.spi.LoggerContext loggerContext = LogManager .getContext(false); if (loggerContext instanceof LoggerContext) { return ConditionOutcome.match( "LoggerContext was an instance of org.apache.logging.log4j.spi.LoggerContext"); } return ConditionOutcome.noMatch( "Logger context was not an instance of org.apache.logging.log4j.spi.LoggerContext"); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { return needsAdditionalConfiguration(context) ? ConditionOutcome.match("camunda version needs additional configuration for history level auto") : ConditionOutcome.noMatch("camunda version supports history level auto"); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("Logging System"); String loggingSystem = System.getProperty(LoggingSystem.SYSTEM_PROPERTY); if (LoggingSystem.NONE.equals(loggingSystem)) { return ConditionOutcome.noMatch(message.because("system property " + LoggingSystem.SYSTEM_PROPERTY + " is set to none")); } return ConditionOutcome.match(message.because("enabled")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { return (DatabaseDescriptor.isDaemonInitialized() && DatabaseDescriptor.getRpcAddress() != null) ? ConditionOutcome.match() : ConditionOutcome.noMatch("Cassandra Daemon is not initialized."); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage.forCondition("Okta Api Token Condition"); String tokenValue = context.getEnvironment().getProperty("okta.client.token"); if (StringUtils.hasText(tokenValue)) { return ConditionOutcome.match(message.foundExactly("provided API token")); } return ConditionOutcome.noMatch(message.didNotFind("provided API token").atAll()); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) { final ConditionMessage.Builder message = ConditionMessage.forCondition(this.single); final Environment environment = conditionContext.getEnvironment(); return HierarchicalPropertiesEvaluator.evaluate(environment, this.group, this.single) ? ConditionOutcome.match(message.because("enabled")) : ConditionOutcome.noMatch(message.because("not enabled")); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage.forCondition("JmmsDataSource"); if (anyMatches(context, metadata, this.anyPropertyCondition)) { return ConditionOutcome.noMatch(message.foundExactly("supported data source")); }else { return ConditionOutcome.match(message.foundExactly("jmms data source")); } } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata annotatedTypeMetadata) { Binder binder = Binder.get(context.getEnvironment()); Map<String, Object> sslProperties = binder.bind("camel.ssl.config", Bindable.mapOf(String.class, Object.class)).orElse(Collections.emptyMap()); ConditionMessage.Builder message = ConditionMessage.forCondition("camel.ssl.config"); if (sslProperties.size() > 0) { return ConditionOutcome.match(message.because("enabled")); } return ConditionOutcome.noMatch(message.because("not enabled")); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { if (processor.matches(context, metadata)) { return ConditionOutcome.match("Processor is bound"); } if (sink.matches(context, metadata) && source.matches(context, metadata)) { return ConditionOutcome.match("Both Source and Sink are bound"); } return ConditionOutcome.noMatch("Both Source and Sink are not bound"); } }