use of org.springframework.beans.factory.config.BeanExpressionResolver in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method expressionInStringArray.
@Test
void expressionInStringArray() {
BeanExpressionResolver beanExpressionResolver = mock(BeanExpressionResolver.class);
given(beanExpressionResolver.evaluate(eq("#{foo}"), any(BeanExpressionContext.class))).willReturn("classpath:/org/springframework/beans/factory/xml/util.properties");
lbf.setBeanExpressionResolver(beanExpressionResolver);
RootBeanDefinition rbd = new RootBeanDefinition(PropertiesFactoryBean.class);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("locations", new String[] { "#{foo}" });
rbd.setPropertyValues(pvs);
lbf.registerBeanDefinition("myProperties", rbd);
Properties properties = (Properties) lbf.getBean("myProperties");
assertThat(properties.getProperty("foo")).isEqualTo("bar");
}
use of org.springframework.beans.factory.config.BeanExpressionResolver in project spring-framework by spring-projects.
the class AbstractNamedValueMethodArgumentResolver method resolveEmbeddedValuesAndExpressions.
/**
* Resolve the given annotation-specified value,
* potentially containing placeholders and expressions.
*/
@Nullable
private Object resolveEmbeddedValuesAndExpressions(String value) {
if (this.configurableBeanFactory == null || this.expressionContext == null) {
return value;
}
String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(value);
BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return value;
}
return exprResolver.evaluate(placeholdersResolved, this.expressionContext);
}
use of org.springframework.beans.factory.config.BeanExpressionResolver in project spring-framework by spring-projects.
the class AbstractNamedValueArgumentResolver method resolveEmbeddedValuesAndExpressions.
/**
* Resolve the given annotation-specified value,
* potentially containing placeholders and expressions.
*/
@Nullable
private Object resolveEmbeddedValuesAndExpressions(String value) {
if (this.configurableBeanFactory == null || this.expressionContext == null) {
return value;
}
String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(value);
BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return value;
}
return exprResolver.evaluate(placeholdersResolved, this.expressionContext);
}
Aggregations