Java Code Examples for org.springframework.expression.spel.support.StandardEvaluationContext#setPropertyAccessors()
The following examples show how to use
org.springframework.expression.spel.support.StandardEvaluationContext#setPropertyAccessors() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyAccessTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testAddingRemovingAccessors() { StandardEvaluationContext ctx = new StandardEvaluationContext(); // reflective property accessor is the only one by default List<PropertyAccessor> propertyAccessors = ctx.getPropertyAccessors(); assertEquals(1,propertyAccessors.size()); StringyPropertyAccessor spa = new StringyPropertyAccessor(); ctx.addPropertyAccessor(spa); assertEquals(2,ctx.getPropertyAccessors().size()); List<PropertyAccessor> copy = new ArrayList<>(); copy.addAll(ctx.getPropertyAccessors()); assertTrue(ctx.removePropertyAccessor(spa)); assertFalse(ctx.removePropertyAccessor(spa)); assertEquals(1,ctx.getPropertyAccessors().size()); ctx.setPropertyAccessors(copy); assertEquals(2,ctx.getPropertyAccessors().size()); }
Example 2
Source File: PropertyAccessTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testAddingRemovingAccessors() { StandardEvaluationContext ctx = new StandardEvaluationContext(); // reflective property accessor is the only one by default List<PropertyAccessor> propertyAccessors = ctx.getPropertyAccessors(); assertEquals(1,propertyAccessors.size()); StringyPropertyAccessor spa = new StringyPropertyAccessor(); ctx.addPropertyAccessor(spa); assertEquals(2,ctx.getPropertyAccessors().size()); List<PropertyAccessor> copy = new ArrayList<>(); copy.addAll(ctx.getPropertyAccessors()); assertTrue(ctx.removePropertyAccessor(spa)); assertFalse(ctx.removePropertyAccessor(spa)); assertEquals(1,ctx.getPropertyAccessors().size()); ctx.setPropertyAccessors(copy); assertEquals(2,ctx.getPropertyAccessors().size()); }
Example 3
Source File: PropertyAccessTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testAddingRemovingAccessors() { StandardEvaluationContext ctx = new StandardEvaluationContext(); // reflective property accessor is the only one by default List<PropertyAccessor> propertyAccessors = ctx.getPropertyAccessors(); assertEquals(1,propertyAccessors.size()); StringyPropertyAccessor spa = new StringyPropertyAccessor(); ctx.addPropertyAccessor(spa); assertEquals(2,ctx.getPropertyAccessors().size()); List<PropertyAccessor> copy = new ArrayList<PropertyAccessor>(); copy.addAll(ctx.getPropertyAccessors()); assertTrue(ctx.removePropertyAccessor(spa)); assertFalse(ctx.removePropertyAccessor(spa)); assertEquals(1,ctx.getPropertyAccessors().size()); ctx.setPropertyAccessors(copy); assertEquals(2,ctx.getPropertyAccessors().size()); }
Example 4
Source File: ExpressionsSupport.java From kork with Apache License 2.0 | 5 votes |
private StandardEvaluationContext createEvaluationContext( Object rootObject, boolean allowUnknownKeys) { ReturnTypeRestrictor returnTypeRestrictor = new ReturnTypeRestrictor(allowedReturnTypes); StandardEvaluationContext evaluationContext = new StandardEvaluationContext(rootObject); evaluationContext.setTypeLocator(new AllowListTypeLocator()); evaluationContext.setMethodResolvers( Collections.singletonList(new FilteredMethodResolver(returnTypeRestrictor))); evaluationContext.setPropertyAccessors( Arrays.asList( new MapPropertyAccessor(allowUnknownKeys), new FilteredPropertyAccessor(returnTypeRestrictor))); return evaluationContext; }