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">&lt;!-- target bean to be referenced by name --&gt;040 * &lt;bean id="tb" class="org.springframework.beans.TestBean" singleton="false"&gt;041 * &lt;property name="age" value="10"/&gt;042 * &lt;property name="spouse"&gt;043 * &lt;bean class="org.springframework.beans.TestBean"&gt;044 * &lt;property name="age" value="11"/&gt;045 * &lt;/bean&gt;046 * &lt;/property&gt;047 * &lt;/bean&gt;048 *049 * &lt;!-- will result in 12, which is the value of property 'age' of the inner bean --&gt;050 * &lt;bean id="propertyPath1" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"&gt;051 * &lt;property name="targetObject"&gt;052 * &lt;bean class="org.springframework.beans.TestBean"&gt;053 * &lt;property name="age" value="12"/&gt;054 * &lt;/bean&gt;055 * &lt;/property&gt;056 * &lt;property name="propertyPath" value="age"/&gt;057 * &lt;/bean&gt;058 *059 * &lt;!-- will result in 11, which is the value of property 'spouse.age' of bean 'tb' --&gt;060 * &lt;bean id="propertyPath2" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"&gt;061 * &lt;property name="targetBeanName" value="tb"/&gt;062 * &lt;property name="propertyPath" value="spouse.age"/&gt;063 * &lt;/bean&gt;064 *065 * &lt;!-- will result in 10, which is the value of property 'age' of bean 'tb' --&gt;066 * &lt;bean id="tb.age" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/&gt;</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