本文整理汇总了Java中org.springframework.expression.spel.standard.SpelExpression.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java SpelExpression.getValue方法的具体用法?Java SpelExpression.getValue怎么用?Java SpelExpression.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.expression.spel.standard.SpelExpression
的用法示例。
在下文中一共展示了SpelExpression.getValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateKey
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
/**
* generate the key based on SPel expression.
*/
protected Object generateKey(String key, ProceedingJoinPoint pjp) throws ExpirableCacheException {
try {
Object target = pjp.getTarget();
Method method = ((MethodSignature) pjp.getSignature()).getMethod();
Object[] allArgs = pjp.getArgs();
if (StringUtils.hasText(key)) {
CacheExpressionDataObject cacheExpressionDataObject = new CacheExpressionDataObject(method, allArgs, target, target.getClass());
EvaluationContext evaluationContext = new StandardEvaluationContext(cacheExpressionDataObject);
SpelExpression spelExpression = getExpression(key, method);
spelExpression.setEvaluationContext(evaluationContext);
return spelExpression.getValue();
}
return keyGenerator.generate(target, method, allArgs);
} catch (Throwable t) {
throw new ExpirableCacheException("### generate key failed");
}
}
示例2: projectionTypeDescriptors_2
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void projectionTypeDescriptors_2() throws Exception {
StandardEvaluationContext ctx = new StandardEvaluationContext(new C());
SpelExpressionParser parser = new SpelExpressionParser();
String el1 = "as.![#this.equals('abc')]";
SpelExpression exp = parser.parseRaw(el1);
Object[] value = (Object[]) exp.getValue(ctx);
// value is array containing [true,false]
assertEquals(Boolean.class, value[0].getClass());
TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx);
assertEquals(Boolean.class, evaluated.getElementTypeDescriptor().getType());
}
示例3: testConstructorInvocation06
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void testConstructorInvocation06() throws Exception {
// repeated evaluation to drive use of cached executor
SpelExpression expr = (SpelExpression) parser.parseExpression("new String('wibble')");
String newString = expr.getValue(String.class);
assertEquals("wibble", newString);
newString = expr.getValue(String.class);
assertEquals("wibble", newString);
// not writable
assertFalse(expr.isWritable(new StandardEvaluationContext()));
// ast
assertEquals("new String('wibble')", expr.toStringAST());
}
示例4: projectionTypeDescriptors_1
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void projectionTypeDescriptors_1() throws Exception {
StandardEvaluationContext ctx = new StandardEvaluationContext(new C());
SpelExpressionParser parser = new SpelExpressionParser();
String el1 = "ls.![#this.equals('abc')]";
SpelExpression exp = parser.parseRaw(el1);
List<?> value = (List<?>) exp.getValue(ctx);
// value is list containing [true,false]
assertEquals(Boolean.class, value.get(0).getClass());
TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx);
assertEquals(null, evaluated.getElementTypeDescriptor());
}
示例5: projectionTypeDescriptors_3
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void projectionTypeDescriptors_3() throws Exception {
StandardEvaluationContext ctx = new StandardEvaluationContext(new C());
SpelExpressionParser parser = new SpelExpressionParser();
String el1 = "ms.![key.equals('abc')]";
SpelExpression exp = parser.parseRaw(el1);
List<?> value = (List<?>) exp.getValue(ctx);
// value is list containing [true,false]
assertEquals(Boolean.class, value.get(0).getClass());
TypeDescriptor evaluated = exp.getValueTypeDescriptor(ctx);
assertEquals(null, evaluated.getElementTypeDescriptor());
}
示例6: greaterThanWithNulls_SPR7840
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void greaterThanWithNulls_SPR7840() throws Exception {
List<D> list = new ArrayList<D>();
list.add(new D("aaa"));
list.add(new D("bbb"));
list.add(new D(null));
list.add(new D("ccc"));
list.add(new D(null));
list.add(new D("zzz"));
StandardEvaluationContext ctx = new StandardEvaluationContext(list);
SpelExpressionParser parser = new SpelExpressionParser();
String el1 = "#root.?[a < 'hhh']";
SpelExpression exp = parser.parseRaw(el1);
Object value = exp.getValue(ctx);
assertEquals("[D(aaa), D(bbb), D(null), D(ccc), D(null)]", value.toString());
String el2 = "#root.?[a > 'hhh']";
SpelExpression exp2 = parser.parseRaw(el2);
Object value2 = exp2.getValue(ctx);
assertEquals("[D(zzz)]", value2.toString());
// trim out the nulls first
String el3 = "#root.?[a!=null].?[a < 'hhh']";
SpelExpression exp3 = parser.parseRaw(el3);
Object value3 = exp3.getValue(ctx);
assertEquals("[D(aaa), D(bbb), D(ccc)]", value3.toString());
}
示例7: reservedWordProperties_9862
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void reservedWordProperties_9862() throws Exception {
StandardEvaluationContext ctx = new StandardEvaluationContext();
SpelExpressionParser parser = new SpelExpressionParser();
SpelExpression expression = parser.parseRaw("T(org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver).CONST");
Object value = expression.getValue(ctx);
assertEquals(value, Reserver.CONST);
}
示例8: compare
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public int compare(T arg1, T arg2) {
SpelExpression expressionToUse = getExpression();
expressionToUse.getEvaluationContext().setVariable("arg1", arg1);
expressionToUse.getEvaluationContext().setVariable("arg2", arg2);
return expressionToUse.getValue(Integer.class) * (asc ? 1 : -1);
}
示例9: reservedWords_8228
import org.springframework.expression.spel.standard.SpelExpression; //导入方法依赖的package包/类
@Test
public void reservedWords_8228() throws Exception {
// "DIV","EQ","GE","GT","LE","LT","MOD","NE","NOT"
@SuppressWarnings("unused")
class Reserver {
public Reserver getReserver() {
return this;
}
public String NE = "abc";
public String ne = "def";
public int DIV = 1;
public int div = 3;
public Map<String, String> m = new HashMap<String, String>();
Reserver() {
m.put("NE", "xyz");
}
}
StandardEvaluationContext ctx = new StandardEvaluationContext(new Reserver());
SpelExpressionParser parser = new SpelExpressionParser();
String ex = "getReserver().NE";
SpelExpression exp = parser.parseRaw(ex);
String value = (String) exp.getValue(ctx);
assertEquals("abc", value);
ex = "getReserver().ne";
exp = parser.parseRaw(ex);
value = (String) exp.getValue(ctx);
assertEquals("def", value);
ex = "getReserver().m[NE]";
exp = parser.parseRaw(ex);
value = (String) exp.getValue(ctx);
assertEquals("xyz", value);
ex = "getReserver().DIV";
exp = parser.parseRaw(ex);
assertEquals(1, exp.getValue(ctx));
ex = "getReserver().div";
exp = parser.parseRaw(ex);
assertEquals(3, exp.getValue(ctx));
exp = parser.parseRaw("NE");
assertEquals("abc", exp.getValue(ctx));
}