当前位置: 首页>>代码示例>>Java>>正文


Java SpelExpression.getValue方法代码示例

本文整理汇总了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");
	}
}
 
开发者ID:profullstack,项目名称:spring-seed,代码行数:21,代码来源:ExpirableCacheAspect.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:SpelReproTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:EvaluationTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:SpelReproTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:SpelReproTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:SpelReproTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:SpelReproTests.java

示例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);
}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:12,代码来源:SpelPropertyComparator.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:50,代码来源:SpelReproTests.java


注:本文中的org.springframework.expression.spel.standard.SpelExpression.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。