Class BeanDefinitionValueResolver

java.lang.Object
org.springframework.beans.factory.support.BeanDefinitionValueResolver

public class BeanDefinitionValueResolver extends Object
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
See Also:
  • Constructor Details

    • BeanDefinitionValueResolver

      public BeanDefinitionValueResolver(AbstractAutowireCapableBeanFactory beanFactory, String beanName, BeanDefinition beanDefinition, TypeConverter typeConverter)
      Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition, using the given TypeConverter.
      Parameters:
      beanFactory - the BeanFactory to resolve against
      beanName - the name of the bean that we work on
      beanDefinition - the BeanDefinition of the bean that we work on
      typeConverter - 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 default TypeConverter.
      Parameters:
      beanFactory - the BeanFactory to resolve against
      beanName - the name of the bean that we work on
      beanDefinition - the BeanDefinition of the bean that we work on
  • Method Details

    • resolveValueIfNecessary

      @Nullable public Object resolveValueIfNecessary(Object argName, @Nullable Object value)
      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 for
      value - the value object to resolve
      Returns:
      the resolved object
    • evaluate

      @Nullable protected Object evaluate(TypedStringValue value)
      Evaluate the given value as an expression, if necessary.
      Parameters:
      value - the candidate value (may be an expression)
      Returns:
      the resolved value
    • evaluate

      @Nullable protected Object evaluate(@Nullable Object value)
      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: