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