@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)); }
@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 context, AnnotatedTypeMetadata metadata) { boolean isRequired = (boolean) metadata .getAnnotationAttributes(annotationClass.getName()) .get("value"); String expression = isRequired ? wrapIfNecessary(requiredExpression) : wrapIfNecessary(notRequiredExpression); String rawExpression = expression; expression = context.getEnvironment().resolvePlaceholders(expression); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); BeanExpressionResolver resolver = (beanFactory != null) ? beanFactory.getBeanExpressionResolver() : null; BeanExpressionContext expressionContext = (beanFactory != null) ? new BeanExpressionContext(beanFactory, null) : null; if (resolver == null) { resolver = new StandardBeanExpressionResolver(); } boolean result = (Boolean) resolver.evaluate(expression, expressionContext); return new ConditionOutcome(result, ConditionMessage .forCondition(annotationClass, "(" + rawExpression + ")") .resultedIn(result)); }