Class BeanDefinitionValueResolver
java.lang.Object
org.springframework.beans.factory.support.BeanDefinitionValueResolver
Helper class for use in bean factory implementations,
resolving values contained in bean definition objects
into the actual values applied to the target bean instance.
Operates on an AbstractBeanFactory
and a plain
BeanDefinition
object.
Used by AbstractAutowireCapableBeanFactory
.
- Since:
- 1.2
- Author:
- Juergen Hoeller, Sam Brannen, Stephane Nicoll
- See Also:
-
Constructor Summary
ConstructorDescriptionBeanDefinitionValueResolver
(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition) Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition using a defaultTypeConverter
.BeanDefinitionValueResolver
(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition, TypeConverter typeConverter) Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition, using the givenTypeConverter
. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
Evaluate the given value as an expression, if necessary.protected Object
evaluate
(TypedStringValue value) Evaluate the given value as an expression, if necessary.<T> T
resolveInnerBean
(String innerBeanName, BeanDefinition innerBd, BiFunction<String, RootBeanDefinition, T> resolver) Resolve an inner bean definition and invoke the specifiedresolver
on its merged bean definition.protected Class<?>
Resolve the target type in the given TypedStringValue.resolveValueIfNecessary
(Object argName, Object value) Given a PropertyValue, return a value, resolving any references to other beans in the factory if necessary.
-
Constructor Details
-
BeanDefinitionValueResolver
public BeanDefinitionValueResolver(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition, TypeConverter typeConverter) Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition, using the givenTypeConverter
.- Parameters:
beanFactory
- the BeanFactory to resolve againstbeanName
- the name of the bean that we work onbeanDefinition
- the BeanDefinition of the bean that we work ontypeConverter
- the TypeConverter to use for resolving TypedStringValues
-
BeanDefinitionValueResolver
public BeanDefinitionValueResolver(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition) Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition using a defaultTypeConverter
.- Parameters:
beanFactory
- the BeanFactory to resolve againstbeanName
- the name of the bean that we work onbeanDefinition
- the BeanDefinition of the bean that we work on
-
-
Method Details
-
resolveValueIfNecessary
Given a PropertyValue, return a value, resolving any references to other beans in the factory if necessary. The value could be:- A BeanDefinition, which leads to the creation of a corresponding new bean instance. Singleton flags and names of such "inner beans" are always ignored: Inner beans are anonymous prototypes.
- A RuntimeBeanReference, which must be resolved.
- A ManagedList. This is a special collection that may contain RuntimeBeanReferences or Collections that will need to be resolved.
- A ManagedSet. May also contain RuntimeBeanReferences or Collections that will need to be resolved.
- A ManagedMap. In this case the value may be a RuntimeBeanReference or Collection that will need to be resolved.
- An ordinary object or
null
, in which case it's left alone.- Parameters:
argName
- the name of the argument that the value is defined forvalue
- the value object to resolve- Returns:
- the resolved object
-
resolveInnerBean
public <T> T resolveInnerBean(@Nullable String innerBeanName, BeanDefinition innerBd, BiFunction<String, RootBeanDefinition, T> resolver) Resolve an inner bean definition and invoke the specifiedresolver
on its merged bean definition.- Type Parameters:
T
- the type of the resolution- Parameters:
innerBeanName
- the inner bean name (ornull
to assign one)innerBd
- the inner raw bean definitionresolver
- the function to invoke to resolve- Returns:
- a resolved inner bean, as a result of applying the
resolver
-
evaluate
Evaluate the given value as an expression, if necessary.- Parameters:
value
- the candidate value (may be an expression)- Returns:
- the resolved value
-
evaluate
Evaluate the given value as an expression, if necessary.- Parameters:
value
- the original value (may be an expression)- Returns:
- the resolved value if necessary, or the original value
-
resolveTargetType
@Nullable protected Class<?> resolveTargetType(TypedStringValue value) throws ClassNotFoundException Resolve the target type in the given TypedStringValue.- Parameters:
value
- the TypedStringValue to resolve- Returns:
- the resolved target type (or
null
if none specified) - Throws:
ClassNotFoundException
- if the specified type cannot be resolved- See Also:
-