001/* 002 * Copyright 2002-2016 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 * https://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.context.annotation; 018 019/** 020 * A {@link Condition} that offers more fine-grained control when used with 021 * {@code @Configuration}. Allows certain {@link Condition}s to adapt when they match 022 * based on the configuration phase. For example, a condition that checks if a bean 023 * has already been registered might choose to only be evaluated during the 024 * {@link ConfigurationPhase#REGISTER_BEAN REGISTER_BEAN} {@link ConfigurationPhase}. 025 * 026 * @author Phillip Webb 027 * @since 4.0 028 * @see Configuration 029 */ 030public interface ConfigurationCondition extends Condition { 031 032 /** 033 * Return the {@link ConfigurationPhase} in which the condition should be evaluated. 034 */ 035 ConfigurationPhase getConfigurationPhase(); 036 037 038 /** 039 * The various configuration phases where the condition could be evaluated. 040 */ 041 enum ConfigurationPhase { 042 043 /** 044 * The {@link Condition} should be evaluated as a {@code @Configuration} 045 * class is being parsed. 046 * <p>If the condition does not match at this point, the {@code @Configuration} 047 * class will not be added. 048 */ 049 PARSE_CONFIGURATION, 050 051 /** 052 * The {@link Condition} should be evaluated when adding a regular 053 * (non {@code @Configuration}) bean. The condition will not prevent 054 * {@code @Configuration} classes from being added. 055 * <p>At the time that the condition is evaluated, all {@code @Configuration}s 056 * will have been parsed. 057 */ 058 REGISTER_BEAN 059 } 060 061}