@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 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) { 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")); }
AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("DevTools DataSource Condition"); String[] dataSourceBeanNames = context.getBeanFactory() .getBeanNamesForType(DataSource.class);
@Override public ConditionOutcome getMatchOutcome(ConditionContext aContext, AnnotatedTypeMetadata aMetadata) { String property = aContext.getEnvironment().getProperty("piper.coordinator.enabled"); boolean result = Boolean.valueOf(property); return new ConditionOutcome(result,ConditionMessage.forCondition(ConditionalOnCoordinator.class, "(" + getClass().getName() + ")").resultedIn(result)); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext aContext, AnnotatedTypeMetadata aMetadata) { String property = aContext.getEnvironment().getProperty("piper.worker.enabled"); boolean result = Boolean.valueOf(property); return new ConditionOutcome(result,ConditionMessage.forCondition(ConditionalOnWorker.class, "(" + getClass().getName() + ")").resultedIn(result)); }
protected ConditionOutcome getDefaultEndpointsOutcome(ConditionContext context) { boolean match = Boolean.valueOf(context.getEnvironment() .getProperty(this.prefix + "defaults.enabled", "true")); return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType).because( this.prefix + "defaults.enabled is considered " + match)); }
@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) { ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); ConditionMessage.Builder message = ConditionMessage .forCondition("LogbackLoggingCondition"); if (loggerFactory instanceof LoggerContext) { return ConditionOutcome.match( message.because("ILoggerFactory is a Logback LoggerContext")); } return ConditionOutcome .noMatch(message.because("ILoggerFactory is an instance of " + loggerFactory.getClass().getCanonicalName())); }
protected ConditionOutcome getEndpointOutcome(ConditionContext context, String endpointName) { Environment environment = context.getEnvironment(); String enabledProperty = this.prefix + endpointName + ".enabled"; if (environment.containsProperty(enabledProperty)) { boolean match = environment.getProperty(enabledProperty, Boolean.class, true); return new ConditionOutcome(match, ConditionMessage.forCondition(this.annotationType).because( this.prefix + endpointName + ".enabled is " + match)); } return null; }
@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("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 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) { 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")); }
@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")); }
@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")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String[] commands = context.getBeanFactory().getBeanNamesForAnnotation(Command.class); ConditionMessage.Builder message = ConditionMessage.forCondition("@Command Condition"); if (commands.length == 0) { return ConditionOutcome.noMatch(message.didNotFind("@Command beans").atAll()); } else { return ConditionOutcome.match(message.found("@Command beans").items((Object[]) commands)); } }
@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()); } }