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 at007 *008 * https://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * 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 and014 * limitations under the License.015 */016017package org.springframework.beans.factory.config;018019import org.apache.commons.logging.Log;020import org.apache.commons.logging.LogFactory;021022import org.springframework.beans.BeanWrapper;023import org.springframework.beans.BeansException;024import org.springframework.beans.PropertyAccessorFactory;025import org.springframework.beans.factory.BeanFactory;026import org.springframework.beans.factory.BeanFactoryAware;027import org.springframework.beans.factory.BeanFactoryUtils;028import org.springframework.beans.factory.BeanNameAware;029import org.springframework.beans.factory.FactoryBean;030import org.springframework.util.StringUtils;031032/**033 * {@link FactoryBean} that evaluates a property path on a given target object.034 *035 * <p>The target object can be specified directly or via a bean name.036 *037 * <p>Usage examples:038 *039 * <pre class="code"><!-- target bean to be referenced by name -->040 * <bean id="tb" class="org.springframework.beans.TestBean" singleton="false">041 * <property name="age" value="10"/>042 * <property name="spouse">043 * <bean class="org.springframework.beans.TestBean">044 * <property name="age" value="11"/>045 * </bean>046 * </property>047 * </bean>048 *049 * <!-- will result in 12, which is the value of property 'age' of the inner bean -->050 * <bean id="propertyPath1" class="org.springframework.beans.factory.config.PropertyPathFactoryBean">051 * <property name="targetObject">052 * <bean class="org.springframework.beans.TestBean">053 * <property name="age" value="12"/>054 * </bean>055 * </property>056 * <property name="propertyPath" value="age"/>057 * </bean>058 *059 * <!-- will result in 11, which is the value of property 'spouse.age' of bean 'tb' -->060 * <bean id="propertyPath2" class="org.springframework.beans.factory.config.PropertyPathFactoryBean">061 * <property name="targetBeanName" value="tb"/>062 * <property name="propertyPath" value="spouse.age"/>063 * </bean>064 *065 * <!-- will result in 10, which is the value of property 'age' of bean 'tb' -->066 * <bean id="tb.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/></pre>067 *068 * <p>If you are using Spring 2.0 and XML Schema support in your configuration file(s),069 * you can also use the following style of configuration for property path acc