001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure;
018
019import org.springframework.beans.factory.BeanClassLoaderAware;
020import org.springframework.beans.factory.BeanFactoryAware;
021import org.springframework.context.EnvironmentAware;
022import org.springframework.context.ResourceLoaderAware;
023
024/**
025 * Filter that can be registered in {@code spring.factories} to limit the
026 * auto-configuration classes considered. This interface is designed to allow fast removal
027 * of auto-configuration classes before their bytecode is even read.
028 * <p>
029 * An {@link AutoConfigurationImportFilter} may implement any of the following
030 * {@link org.springframework.beans.factory.Aware Aware} interfaces, and their respective
031 * methods will be called prior to {@link #match}:
032 * <ul>
033 * <li>{@link EnvironmentAware}</li>
034 * <li>{@link BeanFactoryAware}</li>
035 * <li>{@link BeanClassLoaderAware}</li>
036 * <li>{@link ResourceLoaderAware}</li>
037 * </ul>
038 *
039 * @author Phillip Webb
040 * @since 1.5.0
041 */
042@FunctionalInterface
043public interface AutoConfigurationImportFilter {
044
045        /**
046         * Apply the filter to the given auto-configuration class candidates.
047         * @param autoConfigurationClasses the auto-configuration classes being considered.
048         * This array may contain {@code null} elements. Implementations should not change the
049         * values in this array.
050         * @param autoConfigurationMetadata access to the meta-data generated by the
051         * auto-configure annotation processor
052         * @return a boolean array indicating which of the auto-configuration classes should
053         * be imported. The returned array must be the same size as the incoming
054         * {@code autoConfigurationClasses} parameter. Entries containing {@code false} will
055         * not be imported.
056         */
057        boolean[] match(String[] autoConfigurationClasses,
058                        AutoConfigurationMetadata autoConfigurationMetadata);
059
060}