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.env;
018
019import org.springframework.boot.SpringApplication;
020import org.springframework.core.env.ConfigurableEnvironment;
021import org.springframework.core.env.Environment;
022
023/**
024 * Allows for customization of the application's {@link Environment} prior to the
025 * application context being refreshed.
026 * <p>
027 * EnvironmentPostProcessor implementations have to be registered in
028 * {@code META-INF/spring.factories}, using the fully qualified name of this class as the
029 * key.
030 * <p>
031 * {@code EnvironmentPostProcessor} processors are encouraged to detect whether Spring's
032 * {@link org.springframework.core.Ordered Ordered} interface has been implemented or if
033 * the {@link org.springframework.core.annotation.Order @Order} annotation is present and
034 * to sort instances accordingly if so prior to invocation.
035 *
036 * @author Andy Wilkinson
037 * @author Stephane Nicoll
038 * @since 1.3.0
039 */
040@FunctionalInterface
041public interface EnvironmentPostProcessor {
042
043        /**
044         * Post-process the given {@code environment}.
045         * @param environment the environment to post-process
046         * @param application the application to which the environment belongs
047         */
048        void postProcessEnvironment(ConfigurableEnvironment environment,
049                        SpringApplication application);
050
051}