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;
018
019import org.springframework.beans.BeansException;
020
021/**
022 * Interface to be implemented by beans that wish to be aware of their
023 * owning {@link BeanFactory}.
024 *
025 * <p>For example, beans can look up collaborating beans via the factory
026 * (Dependency Lookup). Note that most beans will choose to receive references
027 * to collaborating beans via corresponding bean properties or constructor
028 * arguments (Dependency Injection).
029 *
030 * <p>For a list of all bean lifecycle methods, see the
031 * {@link BeanFactory BeanFactory javadocs}.
032 *
033 * @author Rod Johnson
034 * @author Chris Beams
035 * @since 11.03.2003
036 * @see BeanNameAware
037 * @see BeanClassLoaderAware
038 * @see InitializingBean
039 * @see org.springframework.context.ApplicationContextAware
040 */
041public interface BeanFactoryAware extends Aware {
042
043        /**
044         * Callback that supplies the owning factory to a bean instance.
045         * <p>Invoked after the population of normal bean properties
046         * but before an initialization callback such as
047         * {@link InitializingBean#afterPropertiesSet()} or a custom init-method.
048         * @param beanFactory owning BeanFactory (never {@code null}).
049         * The bean can immediately call methods on the factory.
050         * @throws BeansException in case of initialization errors
051         * @see BeanInitializationException
052         */
053        void setBeanFactory(BeanFactory beanFactory) throws BeansException;
054
055}