
infra.beans.factory.config.PropertyPathFactoryBean Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2017 - 2024 the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [https://www.gnu.org/licenses/]
*/
package infra.beans.factory.config;
import infra.beans.BeanWrapper;
import infra.beans.BeansException;
import infra.beans.factory.BeanFactory;
import infra.beans.factory.BeanFactoryAware;
import infra.beans.factory.BeanFactoryUtils;
import infra.beans.factory.BeanNameAware;
import infra.beans.factory.FactoryBean;
import infra.lang.Assert;
import infra.lang.Nullable;
import infra.logging.Logger;
import infra.logging.LoggerFactory;
import infra.util.StringUtils;
/**
* {@link FactoryBean} that evaluates a property path on a given target object.
*
* The target object can be specified directly or via a bean name.
*
*
Usage examples:
*
*
<!-- target bean to be referenced by name -->
* <bean id="tb" class="infra.beans.factory.TestBean" singleton="false">
* <property name="age" value="10"/>
* <property name="spouse">
* <bean class="infra.beans.factory.TestBean">
* <property name="age" value="11"/>
* </bean>
* </property>
* </bean>
*
* <!-- will result in 12, which is the value of property 'age' of the inner bean -->
* <bean id="propertyPath1" class="infra.beans.factory.config.PropertyPathFactoryBean">
* <property name="targetObject">
* <bean class="infra.beans.factory.TestBean">
* <property name="age" value="12"/>
* </bean>
* </property>
* <property name="propertyPath" value="age"/>
* </bean>
*
* <!-- will result in 11, which is the value of property 'spouse.age' of bean 'tb' -->
* <bean id="propertyPath2" class="infra.beans.factory.config.PropertyPathFactoryBean">
* <property name="targetBeanName" value="tb"/>
* <property name="propertyPath" value="spouse.age"/>
* </bean>
*
* <!-- will result in 10, which is the value of property 'age' of bean 'tb' -->
* <bean id="tb.age" class="infra.beans.factory.config.PropertyPathFactoryBean"/>
*
* @author Juergen Hoeller
* @author Harry Yang
* @see #setTargetObject
* @see #setTargetBeanName
* @see #setPropertyPath
* @since 4.0 2021/11/30 15:08
*/
public class PropertyPathFactoryBean implements FactoryBean
© 2015 - 2025 Weber Informatics LLC | Privacy Policy