Example usage for org.springframework.context.annotation ConditionContext getBeanFactory

List of usage examples for org.springframework.context.annotation ConditionContext getBeanFactory

Introduction

In this page you can find the example usage for org.springframework.context.annotation ConditionContext getBeanFactory.

Prototype

@Nullable
ConfigurableListableBeanFactory getBeanFactory();

Source Link

Document

Return the ConfigurableListableBeanFactory that will hold the bean definition should the condition match, or null if the bean factory is not available (or not downcastable to ConfigurableListableBeanFactory ).

Usage

From source file:org.springframework.web.servlet.config.annotation.BeanTypeNotPresentCondition.java

public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    ListableBeanFactory factory = context.getBeanFactory();
    String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, this.beanType, false, false);
    if (ObjectUtils.isEmpty(names)) {
        logger.debug("No bean of type [" + this.beanType + "]. Conditional configuration applies.");
        return true;
    } else {//from www  . j  a  va  2  s . c  o m
        logger.debug("Found bean of type [" + this.beanType + "]. Conditional configuration does not apply.");
        return false;
    }
}