@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) { 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())); }
@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())); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { Environment environment = context.getEnvironment(); AnnotationAttributes attributes = getEndpointAttributes(context, metadata); EndpointId id = EndpointId.of(attributes.getString("id")); String key = "management.endpoint." + id.toLowerCaseString() + ".enabled"; Boolean userDefinedEnabled = environment.getProperty(key, Boolean.class); if (userDefinedEnabled != null) { return new ConditionOutcome(userDefinedEnabled, ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class) .because("found property " + key + " with value " + userDefinedEnabled)); } Boolean userDefinedDefault = isEnabledByDefault(environment); if (userDefinedDefault != null) { return new ConditionOutcome(userDefinedDefault, ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class) .because("no property " + key + " found so using user defined default from " + ENABLED_BY_DEFAULT_KEY)); } boolean endpointDefault = attributes.getBoolean("enableByDefault"); return new ConditionOutcome(endpointDefault, ConditionMessage.forCondition(ConditionalOnEnabledEndpoint.class).because( "no property " + key + " found so using endpoint default")); }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("DynamoDB"); Environment environment = context.getEnvironment(); Binder binder = Binder.get(environment); DynamoProperties dynamoProperties = binder.bind("spring.data.dynamodb", DynamoProperties.class) .orElseGet(DynamoProperties::new); String accessKey = dynamoProperties.getAccessKey(); String secretKey = dynamoProperties.getSecretKey(); if (StringUtils.hasLength(accessKey) && StringUtils.hasLength(secretKey)) { return ConditionOutcome.match( message.available("found accessKey and secretKey property")); } return ConditionOutcome.noMatch( message.because("not found accessKey and secretKey property")); } }
@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("Management Port"); if (!isWebApplicationContext(context)) { return ConditionOutcome .noMatch(message.because("non web application context")); } Map<String, Object> attributes = metadata .getAnnotationAttributes(ConditionalOnManagementPort.class.getName()); ManagementPortType requiredType = (ManagementPortType) attributes.get("value"); ManagementPortType actualType = ManagementPortType.get(context.getEnvironment()); if (actualType == requiredType) { return ConditionOutcome.match(message.because( "actual port type (" + actualType + ") matched required type")); } return ConditionOutcome.noMatch(message.because("actual port type (" + actualType + ") did not match required type (" + requiredType + ")")); }
@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.equals(senderType)) { return ConditionOutcome.match(message.because(property + " sender type")); } return ConditionOutcome.noMatch(message.because(property + " sender type")); } }
@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) { 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 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")); }
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; }
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 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 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("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")); }