001/*
002 * Copyright 2002-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 *      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
019/**
020 * Interface to be implemented by beans that need to react once all their properties
021 * have been set by a {@link BeanFactory}: e.g. to perform custom initialization,
022 * or merely to check that all mandatory properties have been set.
023 *
024 * <p>An alternative to implementing {@code InitializingBean} is specifying a custom
025 * init method, for example in an XML bean definition. For a list of all bean
026 * lifecycle methods, see the {@link BeanFactory BeanFactory javadocs}.
027 *
028 * @author Rod Johnson
029 * @author Juergen Hoeller
030 * @see DisposableBean
031 * @see org.springframework.beans.factory.config.BeanDefinition#getPropertyValues()
032 * @see org.springframework.beans.factory.support.AbstractBeanDefinition#getInitMethodName()
033 */
034public interface InitializingBean {
035
036        /**
037         * Invoked by the containing {@code BeanFactory} after it has set all bean properties
038         * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc.
039         * <p>This method allows the bean instance to perform validation of its overall
040         * configuration and final initialization when all bean properties have been set.
041         * @throws Exception in the event of misconfiguration (such as failure to set an
042         * essential property) or if initialization fails for any other reason
043         */
044        void afterPropertiesSet() throws Exception;
045
046}