/** * Create a header value processor for the given Expression and the * expected type of the expression evaluation result. The expectedType * may be null if unknown. * * @param expression the {@link Expression} to evaluate. * @param expectedType the type for return value of {@code expression} evaluation result. */ public ExpressionEvaluatingHeaderValueMessageProcessor(Expression expression, Class<T> expectedType) { this.targetProcessor = new ExpressionEvaluatingMessageProcessor<T>(expression, expectedType); }
/** * Set the SpEL Expression to be used for determining the reply Destination instance * or reply destination name. Either this or one of 'replyDestination' or * 'replyDestinationName' is required. * * @param replyDestinationExpression The reply destination expression. */ public void setReplyDestinationExpression(Expression replyDestinationExpression) { Assert.notNull(replyDestinationExpression, "'replyDestinationExpression' must not be null"); this.replyDestinationExpressionProcessor = new ExpressionEvaluatingMessageProcessor<Object>(replyDestinationExpression); }
/** * Set the retained expression; default "headers['mqtt_retained']". * Only applies if a message converter is not provided. * @param retainedExpression the expression. * @see #setConverter(MessageConverter) * @since 5.0 */ public void setRetainedExpressionString(String retainedExpression) { Assert.hasText(retainedExpression, "'qosExpression' must not be null or empty"); this.retainedProcessor = new ExpressionEvaluatingMessageProcessor<>(retainedExpression); }
/** * Set the file name expression to determine the full path to the remote file when retrieving * a file using the {@link #get(Message, InputStreamCallback)} method, with the message * being the root object of the evaluation. * @param fileNameExpression the file name expression. */ public void setFileNameExpression(Expression fileNameExpression) { Assert.notNull(fileNameExpression, "fileNameExpression must not be null"); this.fileNameProcessor = new ExpressionEvaluatingMessageProcessor<>(fileNameExpression, String.class); }
public ExpressionEvaluatingSelector(String expressionString) { super(new ExpressionEvaluatingMessageProcessor<Boolean>(expressionParser.parseExpression(expressionString), Boolean.class)); this.expressionString = expressionString; }
/** * Set the retained expression; default "headers['mqtt_retained']". * Only applies if a message converter is not provided. * @param retainedExpression the expression. * @see #setConverter(MessageConverter) * @since 5.0 */ public void setRetainedExpression(Expression retainedExpression) { Assert.notNull(retainedExpression, "'qosExpression' cannot be null"); this.retainedProcessor = new ExpressionEvaluatingMessageProcessor<>(retainedExpression); }
/** * Create a header value processor for the given expression string and * the expected type of the expression evaluation result. The * expectedType may be null if unknown. * * @param expressionString the {@link java.lang.String} expression presentation to evaluate. * @param expectedType the type for return value of {@code expression} evaluation result. */ public ExpressionEvaluatingHeaderValueMessageProcessor(String expressionString, Class<T> expectedType) { Expression expression = expressionParser.parseExpression(expressionString); this.targetProcessor = new ExpressionEvaluatingMessageProcessor<T>(expression, expectedType); }
/** * Set a temporary remote directory expression; used when transferring files to the remote * system. After a successful transfer the file is renamed using the * {@link #setRemoteDirectoryExpression(Expression) remoteDirectoryExpression}. * @param temporaryRemoteDirectoryExpression the temporary remote directory expression. */ public void setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression) { Assert.notNull(temporaryRemoteDirectoryExpression, "temporaryRemoteDirectoryExpression must not be null"); this.temporaryDirectoryExpressionProcessor = new ExpressionEvaluatingMessageProcessor<>(temporaryRemoteDirectoryExpression, String.class); }
/** * Set the qos expression; default "headers['mqtt_qos']". * Only applies if a message converter is not provided. * @param qosExpression the expression. * @see #setConverter(MessageConverter) * @since 5.0 */ public void setQosExpression(Expression qosExpression) { Assert.notNull(qosExpression, "'qosExpression' cannot be null"); this.qosProcessor = new ExpressionEvaluatingMessageProcessor<>(qosExpression); }
/** * Set the qos expression; default "headers['mqtt_qos']". * Only applies if a message converter is not provided. * @param qosExpression the expression. * @see #setConverter(MessageConverter) * @since 5.0 */ public void setQosExpressionString(String qosExpression) { Assert.hasText(qosExpression, "'qosExpression' must not be null or empty"); this.qosProcessor = new ExpressionEvaluatingMessageProcessor<>(qosExpression); }
public ExpressionEvaluatingCorrelationStrategy(String expressionString) { Assert.hasText(expressionString, "expressionString must not be empty"); Expression expression = expressionParser.parseExpression(expressionString); this.processor = new ExpressionEvaluatingMessageProcessor<Object>(expression, Object.class); }
public ExpressionEvaluatingMessageHandler(Expression expression) { Assert.notNull(expression, "'expression' must not be null"); this.processor = new ExpressionEvaluatingMessageProcessor<Void>(expression, Void.class); setPrimaryExpression(expression); }
/** * Construct an instance with the supplied {@link Expression}. * @param expression the expression. */ public ExpressionEvaluatingRouter(Expression expression) { super(new ExpressionEvaluatingMessageProcessor<Object>(expression)); setPrimaryExpression(expression); }
public void setDestinationExpression(Expression destinationExpression) { Assert.isTrue(this.destination == null && this.destinationName == null, "The 'destination', 'destinationName', and 'destinationExpression' properties are mutually exclusive."); this.destinationExpressionProcessor = new ExpressionEvaluatingMessageProcessor<Object>(destinationExpression); setPrimaryExpression(destinationExpression); }
@SuppressWarnings({"unchecked", "rawtypes"}) public ExpressionEvaluatingSplitter(Expression expression) { super(new ExpressionEvaluatingMessageProcessor(expression)); setPrimaryExpression(expression); }
@Override protected MessageHandler createExpressionEvaluatingHandler(Expression expression) { ExpressionEvaluatingMessageProcessor<Object> processor = new ExpressionEvaluatingMessageProcessor<Object>(expression); processor.setBeanFactory(this.getBeanFactory()); ServiceActivatingHandler handler = new ServiceActivatingHandler(processor); handler.setPrimaryExpression(expression); return this.configureHandler(handler); }
@Test public void testProcessMessage() { Expression expression = expressionParser.parseExpression("payload"); ExpressionEvaluatingMessageProcessor<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression); processor.setBeanFactory(mock(BeanFactory.class)); assertEquals("foo", processor.processMessage(new GenericMessage<>("foo"))); }
@Test public void testProcessMessageWithDollarPropertyAccess() { Expression expression = expressionParser.parseExpression("headers.$foo_id"); ExpressionEvaluatingMessageProcessor<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression); processor.setBeanFactory(mock(BeanFactory.class)); Message<String> message = MessageBuilder.withPayload("foo").setHeader("$foo_id", "xyz").build(); assertEquals("xyz", processor.processMessage(message)); }
@Test public void testProcessMessageWithStaticKey() { Expression expression = expressionParser.parseExpression("headers[headers.ID]"); ExpressionEvaluatingMessageProcessor<UUID> processor = new ExpressionEvaluatingMessageProcessor<>(expression); processor.setBeanFactory(mock(BeanFactory.class)); GenericMessage<String> message = new GenericMessage<>("foo"); assertEquals(message.getHeaders().getId(), processor.processMessage(message)); }
@Test public void testProcessMessageWithDollarInBrackets() { Expression expression = expressionParser.parseExpression("headers['$foo_id']"); ExpressionEvaluatingMessageProcessor<String> processor = new ExpressionEvaluatingMessageProcessor<>(expression); processor.setBeanFactory(mock(BeanFactory.class)); Message<String> message = MessageBuilder.withPayload("foo").setHeader("$foo_id", "abc").build(); assertEquals("abc", processor.processMessage(message)); }