use of io.micronaut.context.condition.Failure in project micronaut-core by micronaut-projects.
the class AbstractBeanContextConditional method isEnabled.
@Override
public boolean isEnabled(@NonNull BeanContext context, @Nullable BeanResolutionContext resolutionContext) {
AnnotationMetadata annotationMetadata = getAnnotationMetadata();
Condition condition = annotationMetadata.hasStereotype(Requires.class) ? new RequiresCondition(annotationMetadata) : null;
DefaultConditionContext<AbstractBeanContextConditional> conditionContext = new DefaultConditionContext<>((DefaultBeanContext) context, this, resolutionContext);
boolean enabled = condition == null || condition.matches(conditionContext);
if (LOG.isDebugEnabled() && !enabled) {
if (this instanceof BeanConfiguration) {
LOG.debug(this + " will not be loaded due to failing conditions:");
} else {
LOG.debug("Bean [" + this + "] will not be loaded due to failing conditions:");
}
for (Failure failure : conditionContext.getFailures()) {
LOG.debug("* {}", failure.getMessage());
}
}
return enabled;
}
Aggregations