001/* 002 * Copyright 2002-2012 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.beans.factory.config; 018 019import org.springframework.beans.BeansException; 020 021/** 022 * Allows for custom modification of an application context's bean definitions, 023 * adapting the bean property values of the context's underlying bean factory. 024 * 025 * <p>Application contexts can auto-detect BeanFactoryPostProcessor beans in 026 * their bean definitions and apply them before any other beans get created. 027 * 028 * <p>Useful for custom config files targeted at system administrators that 029 * override bean properties configured in the application context. 030 * 031 * <p>See PropertyResourceConfigurer and its concrete implementations 032 * for out-of-the-box solutions that address such configuration needs. 033 * 034 * <p>A BeanFactoryPostProcessor may interact with and modify bean 035 * definitions, but never bean instances. Doing so may cause premature bean 036 * instantiation, violating the container and causing unintended side-effects. 037 * If bean instance interaction is required, consider implementing 038 * {@link BeanPostProcessor} instead. 039 * 040 * @author Juergen Hoeller 041 * @since 06.07.2003 042 * @see BeanPostProcessor 043 * @see PropertyResourceConfigurer 044 */ 045public interface BeanFactoryPostProcessor { 046 047 /** 048 * Modify the application context's internal bean factory after its standard 049 * initialization. All bean definitions will have been loaded, but no beans 050 * will have been instantiated yet. This allows for overriding or adding 051 * properties even to eager-initializing beans. 052 * @param beanFactory the bean factory used by the application context 053 * @throws org.springframework.beans.BeansException in case of errors 054 */ 055 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException; 056 057}