001/*
002 * Copyright 2002-2013 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;
018
019import java.beans.BeanInfo;
020import java.beans.IntrospectionException;
021
022/**
023 * Strategy interface for creating {@link BeanInfo} instances for Spring beans.
024 * Can be used to plug in custom bean property resolution strategies (e.g. for other
025 * languages on the JVM) or more efficient {@link BeanInfo} retrieval algorithms.
026 *
027 * <p>BeanInfoFactories are instantiated by the {@link CachedIntrospectionResults},
028 * by using the {@link org.springframework.core.io.support.SpringFactoriesLoader}
029 * utility class.
030 *
031 * When a {@link BeanInfo} is to be created, the {@code CachedIntrospectionResults}
032 * will iterate through the discovered factories, calling {@link #getBeanInfo(Class)}
033 * on each one. If {@code null} is returned, the next factory will be queried.
034 * If none of the factories support the class, a standard {@link BeanInfo} will be
035 * created as a default.
036 *
037 * <p>Note that the {@link org.springframework.core.io.support.SpringFactoriesLoader}
038 * sorts the {@code BeanInfoFactory} instances by
039 * {@link org.springframework.core.annotation.Order @Order}, so that ones with a
040 * higher precedence come first.
041 *
042 * @author Arjen Poutsma
043 * @since 3.2
044 * @see CachedIntrospectionResults
045 * @see org.springframework.core.io.support.SpringFactoriesLoader
046 */
047public interface BeanInfoFactory {
048
049        /**
050         * Return the bean info for the given class, if supported.
051         * @param beanClass the bean class
052         * @return the BeanInfo, or {@code null} if the given class is not supported
053         * @throws IntrospectionException in case of exceptions
054         */
055        BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException;
056
057}