本文整理汇总了Java中org.springframework.beans.factory.config.BeanExpressionResolver.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java BeanExpressionResolver.evaluate方法的具体用法?Java BeanExpressionResolver.evaluate怎么用?Java BeanExpressionResolver.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.factory.config.BeanExpressionResolver
的用法示例。
在下文中一共展示了BeanExpressionResolver.evaluate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveValue
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
private Object resolveValue(Method method) {
Value val = AnnotationUtils.findAnnotation(method, Value.class);
if (val != null) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Resolving @Value annotation on %s with key %s",
method.getName(), val.value()));
}
ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) getBeanFactory();
String strValue = beanFactory.resolveEmbeddedValue(val.value());
BeanExpressionResolver resolver = beanFactory.getBeanExpressionResolver();
Object unconvertedResult = resolver.evaluate(strValue, new BeanExpressionContext(beanFactory, null));
TypeConverter converter = beanFactory.getTypeConverter();
return converter.convertIfNecessary(unconvertedResult, method.getReturnType());
}
String message = "Method %s on interface %s must be annotated with @Value for auto-properties to work!";
throw new AutoPropertiesException(String.format(message, method.getName(), method.getDeclaringClass().getName()));
}
示例2: buildExportProperties
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
private Map<String, Object> buildExportProperties() {
Map<String, Object> props = new HashMap<>();
if (!ObjectUtils.isEmpty(this.properties)) {
Map<String, String> target = bindProperties();
BeanExpressionResolver beanExpressionResolver = ((ConfigurableApplicationContext) applicationContext)
.getBeanFactory().getBeanExpressionResolver();
BeanExpressionContext expressionContext = new BeanExpressionContext(
((ConfigurableApplicationContext) applicationContext).getBeanFactory(), null);
for (Entry<String, String> entry : target.entrySet()) {
if (isMatch(entry.getKey(), this.properties, null)) {
String stringValue = ObjectUtils.nullSafeToString(entry.getValue());
Object exportedValue = null;
if (stringValue != null) {
exportedValue = stringValue.startsWith("#{")
? beanExpressionResolver.evaluate(
environment.resolvePlaceholders(stringValue), expressionContext)
: environment.resolvePlaceholders(stringValue);
}
props.put(entry.getKey(), exportedValue);
}
}
}
return props;
}
示例3: resolveName
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
private String[] resolveName(String name) {
if (!(getApplicationContext() instanceof ConfigurableApplicationContext)) {
return wrapInStringArray(name);
}
ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) getApplicationContext();
ConfigurableBeanFactory configurableBeanFactory = applicationContext.getBeanFactory();
String placeholdersResolved = configurableBeanFactory.resolveEmbeddedValue(name);
BeanExpressionResolver exprResolver = configurableBeanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return wrapInStringArray(name);
}
Object result = exprResolver.evaluate(placeholdersResolved, new BeanExpressionContext(configurableBeanFactory, null));
if (result instanceof String[]) {
return (String[]) result;
} else if (result != null) {
return wrapInStringArray(result);
} else {
return wrapInStringArray(name);
}
}
示例4: resolveDefaultValue
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
/**
* Resolves the given default value into an argument value.
*/
private Object resolveDefaultValue(String defaultValue) {
if (this.configurableBeanFactory == null) {
return defaultValue;
}
String placeholdersResolved = this.configurableBeanFactory.resolveEmbeddedValue(defaultValue);
BeanExpressionResolver exprResolver = this.configurableBeanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return defaultValue;
}
return exprResolver.evaluate(placeholdersResolved, this.expressionContext);
}
示例5: resolveDefaultValue
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
@Override
protected Object resolveDefaultValue(String value) {
if (beanFactory == null) {
return value;
}
String placeholdersResolved = beanFactory.resolveEmbeddedValue(value);
BeanExpressionResolver exprResolver = beanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return value;
}
return exprResolver.evaluate(placeholdersResolved, expressionContext);
}
示例6: resolveDefaultValue
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
@Override
protected Object resolveDefaultValue(String value) {
if (beanFactory == null) {
return value;
}
String placeholdersResolved = beanFactory
.resolveEmbeddedValue(value);
BeanExpressionResolver exprResolver = beanFactory
.getBeanExpressionResolver();
if (exprResolver == null) {
return value;
}
return exprResolver.evaluate(placeholdersResolved,
expressionContext);
}
示例7: resolveName
import org.springframework.beans.factory.config.BeanExpressionResolver; //导入方法依赖的package包/类
private String resolveName(String name) {
if (!(this.beanFactory instanceof ConfigurableBeanFactory)) {
return name;
}
ConfigurableBeanFactory configurableBeanFactory = (ConfigurableBeanFactory) this.beanFactory;
String placeholdersResolved = configurableBeanFactory.resolveEmbeddedValue(name);
BeanExpressionResolver exprResolver = configurableBeanFactory.getBeanExpressionResolver();
if (exprResolver == null) {
return name;
}
Object result = exprResolver.evaluate(placeholdersResolved, new BeanExpressionContext(configurableBeanFactory, null));
return result != null ? result.toString() : name;
}