Example usage for org.springframework.context.annotation ClassPathScanningCandidateComponentProvider setEnvironment

List of usage examples for org.springframework.context.annotation ClassPathScanningCandidateComponentProvider setEnvironment

Introduction

In this page you can find the example usage for org.springframework.context.annotation ClassPathScanningCandidateComponentProvider setEnvironment.

Prototype

public void setEnvironment(Environment environment) 

Source Link

Document

Set the Environment to use when resolving placeholders and evaluating Conditional @Conditional -annotated component classes.

Usage

From source file:org.agilemicroservices.autoconfigure.orm.RepositoryConfigurationDelegate.java

/**
 * Scans {@code repository.support} packages for implementations of {@link RepositoryFactorySupport}. Finding more
 * than a single type is considered a multi-store configuration scenario which will trigger stricter repository
 * scanning.//  w  ww  .  jav a  2s  .c  o  m
 *
 * @return
 */
private boolean multipleStoresDetected() {

    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false);
    scanner.setEnvironment(environment);
    scanner.setResourceLoader(resourceLoader);
    scanner.addIncludeFilter(new LenientAssignableTypeFilter(RepositoryFactorySupport.class));

    if (scanner.findCandidateComponents(MODULE_DETECTION_PACKAGE).size() > 1) {

        LOGGER.debug(MULTIPLE_MODULES);
        return true;
    }

    return false;
}