private List<PropertyAccessor> initPropertyAccessors() { List<PropertyAccessor> accessors = this.propertyAccessors; if (accessors == null) { accessors = new ArrayList<>(5); accessors.add(new ReflectivePropertyAccessor()); this.propertyAccessors = accessors; } return accessors; }
private List<PropertyAccessor> initPropertyAccessors() { List<PropertyAccessor> accessors = this.propertyAccessors; if (accessors == null) { accessors = new ArrayList<>(5); accessors.add(new ReflectivePropertyAccessor()); this.propertyAccessors = accessors; } return accessors; }
@Test public void SPR10162_onlyBridgeMethod() throws Exception { ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor(); StandardEvaluationContext context = new StandardEvaluationContext(); Object target = new OnlyBridgeMethod(); TypedValue value = accessor.read(context, target, "property"); assertEquals(Integer.class, value.getTypeDescriptor().getType()); }
@Test public void SPR9994_bridgeMethods() throws Exception { ReflectivePropertyAccessor accessor = new ReflectivePropertyAccessor(); StandardEvaluationContext context = new StandardEvaluationContext(); Object target = new GenericImplementation(); TypedValue value = accessor.read(context, target, "property"); assertEquals(Integer.class, value.getTypeDescriptor().getType()); }
@Test public void propertyAccessOnNullTarget_SPR5663() throws AccessException { PropertyAccessor accessor = new ReflectivePropertyAccessor(); EvaluationContext context = TestScenarioCreator.getTestEvaluationContext(); assertFalse(accessor.canRead(context, null, "abc")); assertFalse(accessor.canWrite(context, null, "abc")); try { accessor.read(context, null, "abc"); fail("Should have failed with an IllegalStateException"); } catch (IllegalStateException ex) { // expected } try { accessor.write(context, null, "abc", "foo"); fail("Should have failed with an IllegalStateException"); } catch (IllegalStateException ex) { // expected } }
@Test public void testOptimalReflectivePropertyAccessor() throws Exception { ReflectivePropertyAccessor rpa = new ReflectivePropertyAccessor(); Tester t = new Tester(); t.setProperty("hello");
@Test public void testReflectivePropertyAccessor() throws Exception { ReflectivePropertyAccessor rpa = new ReflectivePropertyAccessor(); Tester t = new Tester(); t.setProperty("hello");
private List<PropertyAccessor> initPropertyAccessors() { List<PropertyAccessor> accessors = this.propertyAccessors; if (accessors == null) { accessors = new ArrayList<>(5); accessors.add(new ReflectivePropertyAccessor()); this.propertyAccessors = accessors; } return accessors; }
public ConsumerBeanAutoConfiguration() { this.expressionParser = new SpelExpressionParser(); this.expressionPropertyAccessors = new ArrayList<PropertyAccessor>(); this.expressionPropertyAccessors.add(new EnvironmentAccessor()); this.expressionPropertyAccessors.add(new BeanFactoryAccessor()); this.expressionPropertyAccessors.add(new ReflectivePropertyAccessor()); this.expressionPropertyAccessors.add(new DirectFieldAccessPropertyAccessor()); }
@Override public StandardEvaluationContext getEvaluationContext(Object rootObject) { StandardEvaluationContext ec = new StandardEvaluationContext(); if (beanFactory != null) { ec.setBeanResolver(new BeanFactoryResolver(beanFactory)); } ExtensionAwarePropertyAccessor accessor = new ExtensionAwarePropertyAccessor(extensions.get()); ec.addPropertyAccessor(accessor); ec.addPropertyAccessor(new ReflectivePropertyAccessor()); ec.addMethodResolver(accessor); if (rootObject != null) { ec.setRootObject(rootObject); } return ec; }
@Override public String process(String value, PortletRequest request) { Map<String, Object> context = getContext(request); StandardEvaluationContext sec = new StandardEvaluationContext(context); sec.addPropertyAccessor(new MapAccessor()); sec.addPropertyAccessor(new ReflectivePropertyAccessor()); sec.addPropertyAccessor(new DefaultPropertyAccessor( PARSER_CONTEXT.getExpressionPrefix(), PARSER_CONTEXT.getExpressionSuffix())); if (beanResolver != null) { sec.setBeanResolver(beanResolver); } SpelExpressionParser parser = new SpelExpressionParser(); try { String processed = parser .parseExpression(value, PARSER_CONTEXT) .getValue(sec, String.class); return processed; } catch (SpelEvaluationException e) { throw new EvaluationException("Failed to process string '" + value + "'. See nested error message and check your SpEL tokens in your string", e); } }
/** * Gets spring expression parser. * * @return the spring expression parser */ public SpringELExpressionParser getSpringExpressionParser() { val configuration = new SpelParserConfiguration(); val spelExpressionParser = new SpelExpressionParser(configuration); val parser = new SpringELExpressionParser(spelExpressionParser, this.flowBuilderServices.getConversionService()); parser.addPropertyAccessor(new ActionPropertyAccessor()); parser.addPropertyAccessor(new BeanFactoryPropertyAccessor()); parser.addPropertyAccessor(new FlowVariablePropertyAccessor()); parser.addPropertyAccessor(new MapAdaptablePropertyAccessor()); parser.addPropertyAccessor(new MessageSourcePropertyAccessor()); parser.addPropertyAccessor(new ScopeSearchingPropertyAccessor()); parser.addPropertyAccessor(new BeanExpressionContextAccessor()); parser.addPropertyAccessor(new MapAccessor()); parser.addPropertyAccessor(new MapAdaptablePropertyAccessor()); parser.addPropertyAccessor(new EnvironmentAccessor()); parser.addPropertyAccessor(new ReflectivePropertyAccessor()); return parser; }
/** * Gets spring expression parser. * * @return the spring expression parser */ protected SpringELExpressionParser getSpringExpressionParser() { final SpelParserConfiguration configuration = new SpelParserConfiguration(); final SpelExpressionParser spelExpressionParser = new SpelExpressionParser(configuration); final SpringELExpressionParser parser = new SpringELExpressionParser(spelExpressionParser, this.flowBuilderServices.getConversionService()); parser.addPropertyAccessor(new ActionPropertyAccessor()); parser.addPropertyAccessor(new BeanFactoryPropertyAccessor()); parser.addPropertyAccessor(new FlowVariablePropertyAccessor()); parser.addPropertyAccessor(new MapAdaptablePropertyAccessor()); parser.addPropertyAccessor(new MessageSourcePropertyAccessor()); parser.addPropertyAccessor(new ScopeSearchingPropertyAccessor()); parser.addPropertyAccessor(new BeanExpressionContextAccessor()); parser.addPropertyAccessor(new MapAccessor()); parser.addPropertyAccessor(new MapAdaptablePropertyAccessor()); parser.addPropertyAccessor(new EnvironmentAccessor()); parser.addPropertyAccessor(new ReflectivePropertyAccessor()); return parser; }