@Override public ExpressionEvalMap build() { if (ExpressionEvalMapBuilder.this.evaluationCallback != null) { return new ExpressionEvalMap(ExpressionEvalMapBuilder.this.expressions, ExpressionEvalMapBuilder.this.evaluationCallback); } else { return new ExpressionEvalMap(ExpressionEvalMapBuilder.this.expressions, new ComponentsEvaluationCallback(ExpressionEvalMapBuilder.this.context, ExpressionEvalMapBuilder.this.root, ExpressionEvalMapBuilder.this.returnType)); } }
/** * Create a handler that will send requests to the provided URI. * * @param uri The URI. */ public HttpRequestExecutingMessageHandler(URI uri) { this(new ValueExpression<URI>(uri)); }
@Override public void afterPropertiesSet() throws Exception { if (this.evaluationContext == null) { this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory); } }
private Map<String, Object> evaluateHeaders() { return ExpressionEvalMap.from(this.headerExpressions) .usingEvaluationContext(getEvaluationContext()) .build(); }
@Override public ExpressionEvalMapComponentsBuilder usingEvaluationContext(EvaluationContext context) { return ExpressionEvalMapBuilder.this.usingEvaluationContext(context); }
@Test public void expressionUpdate() throws Exception { ReloadableResourceBundleExpressionSource source = new ReloadableResourceBundleExpressionSource(); source.setBasename(basename); source.setCacheSeconds(0); DynamicExpression expression = new DynamicExpression(key, source); assertEquals("Hello World!", expression.getValue()); writeExpressionStringToFile("toUpperCase()"); assertEquals("FOO", expression.getValue("foo")); }
@Override public <T> T getValue(Class<T> desiredResultType) throws EvaluationException { return getValue(this.defaultContext, desiredResultType); }
/** * Used to create a context with no BeanFactory, usually in tests. * @return The evaluation context. * @since 4.3.15 */ public static SimpleEvaluationContext createSimpleEvaluationContext() { return (SimpleEvaluationContext) doCreateContext(null, true); }
@Override public <T> T getValue(Object rootObject, Class<T> desiredResultType) throws EvaluationException { return getValue(desiredResultType); }
@Override public void setValue(Object rootObject, Object value) throws EvaluationException { setValue(null, rootObject, value); }
private EvaluationContext getEvaluationContext() { if (this.evaluationContext == null) { this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory); } return this.evaluationContext; }
/** * Specify a directory path where remote files will be transferred to. * @param localDirectory the localDirectory to set */ public void setLocalDirectory(File localDirectory) { if (localDirectory != null) { this.localDirectoryExpression = new ValueExpression<>(localDirectory); } }
private Map<String, Object> evaluateHeaders(Method method, StandardEvaluationContext context) { Map<String, Expression> headerExpressionMap = this.metadataSource.getExpressionsForHeaders(method); if (headerExpressionMap != null) { return ExpressionEvalMap.from(headerExpressionMap) .usingEvaluationContext(context) .build(); } return null; }
/** * Used to create a context with no BeanFactory, usually in tests. * @return The evaluation context. */ public static StandardEvaluationContext createStandardEvaluationContext() { return (StandardEvaluationContext) doCreateContext(null, false); }
@Override public void afterPropertiesSet() throws Exception { if (this.evaluationContext == null) { this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory); } }
/** * Set the default timeout value for receiving reply messages. If not explicitly * configured with an annotation, or on a method element, this value will be used. * * @param defaultReplyTimeout the timeout value in milliseconds */ public void setDefaultReplyTimeout(Long defaultReplyTimeout) { this.defaultReplyTimeout = new ValueExpression<>(defaultReplyTimeout); }
@Override public void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; this.payloadExpressionEvaluationContext = ExpressionUtils.createStandardEvaluationContext(beanFactory); }
/** * Set the default timeout value for sending request messages. If not explicitly * configured with an annotation, or on a method element, this value will be used. * * @param defaultRequestTimeout the timeout value in milliseconds */ public void setDefaultRequestTimeout(Long defaultRequestTimeout) { this.defaultRequestTimeout = new ValueExpression<>(defaultRequestTimeout); }
/** * Set the value to set in the {@code x-delay} header when using the * RabbitMQ delayed message exchange plugin. By default, the {@link AmqpHeaders#DELAY} * header (if present) is mapped; setting the delay here overrides that value. * @param delay the delay. * @since 4.3.5 */ public void setDelay(int delay) { this.delayExpression = new ValueExpression<>(delay); }
/** * Create a handler that will send requests to the provided URI. * @param uri The URI. */ public WebFluxRequestExecutingMessageHandler(URI uri) { this(new ValueExpression<>(uri)); }