List<Expression> expressions = new ArrayList<>(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0;
List<Expression> expressions = new ArrayList<>(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0;
@Test public void testTemplateParserContext() { TemplateParserContext tpc = new TemplateParserContext("abc","def"); assertEquals("abc", tpc.getExpressionPrefix()); assertEquals("def", tpc.getExpressionSuffix()); assertTrue(tpc.isTemplate()); tpc = new TemplateParserContext(); assertEquals("#{", tpc.getExpressionPrefix()); assertEquals("}", tpc.getExpressionSuffix()); assertTrue(tpc.isTemplate()); ParserContext pc = ParserContext.TEMPLATE_EXPRESSION; assertEquals("#{", pc.getExpressionPrefix()); assertEquals("}", pc.getExpressionSuffix()); assertTrue(pc.isTemplate()); }
/** * Set the topic to which to send any result from the method invocation. * May be a SpEL expression {@code !{...}} evaluated at runtime. * @param replyTopicParam the topic or expression. * @since 2.0 */ public void setReplyTopic(String replyTopicParam) { String replyTopic = replyTopicParam; if (!StringUtils.hasText(replyTopic)) { replyTopic = PARSER_CONTEXT.getExpressionPrefix() + "source.headers['" + KafkaHeaders.REPLY_TOPIC + "']" + PARSER_CONTEXT.getExpressionSuffix(); } if (replyTopic.contains(PARSER_CONTEXT.getExpressionPrefix())) { this.replyTopicExpression = PARSER.parseExpression(replyTopic, PARSER_CONTEXT); } else { this.replyTopicExpression = new LiteralExpression(replyTopic); } }
private boolean isExpression(String val) { return val != null && val.contains(PARSER_CONTEXT.getExpressionPrefix()) && val.contains(PARSER_CONTEXT.getExpressionSuffix()); } }
private boolean isExpression(String val) { return val != null && val.contains(PARSER_CONTEXT.getExpressionPrefix()) && val.contains(PARSER_CONTEXT.getExpressionSuffix()); } }
List<Expression> expressions = new ArrayList<>(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0;
@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); } }