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.config;
018
019import java.beans.PropertyDescriptor;
020import java.lang.reflect.Constructor;
021
022import org.springframework.beans.BeansException;
023import org.springframework.beans.PropertyValues;
024import org.springframework.lang.Nullable;
025
026/**
027 * Adapter that implements all methods on {@link SmartInstantiationAwareBeanPostProcessor}
028 * as no-ops, which will not change normal processing of each bean instantiated
029 * by the container. Subclasses may override merely those methods that they are
030 * actually interested in.
031 *
032 * <p>Note that this base class is only recommendable if you actually require
033 * {@link InstantiationAwareBeanPostProcessor} functionality. If all you need
034 * is plain {@link BeanPostProcessor} functionality, prefer a straight
035 * implementation of that (simpler) interface.
036 *
037 * @author Rod Johnson
038 * @author Juergen Hoeller
039 * @since 2.0
040 */
041public abstract class InstantiationAwareBeanPostProcessorAdapter implements SmartInstantiationAwareBeanPostProcessor {
042
043        @Override
044        @Nullable
045        public Class<?> predictBeanType(Class<?> beanClass, String beanName) throws BeansException {
046                return null;
047        }
048
049        @Override
050        @Nullable
051        public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
052                return null;
053        }
054
055        @Override
056        public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {
057                return bean;
058        }
059
060        @Override
061        @Nullable
062        public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
063                return null;
064        }
065
066        @Override
067        public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
068                return true;
069        }
070
071        @Override
072        public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName)
073                        throws BeansException {
074
075                return null;
076        }
077
078        @Deprecated
079        @Override
080        public PropertyValues postProcessPropertyValues(
081                        PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
082
083                return pvs;
084        }
085
086        @Override
087        public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
088                return bean;
089        }
090
091        @Override
092        public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
093                return bean;
094        }
095
096}