use of org.springframework.integration.filter.ExpressionEvaluatingSelector in project spring-integration by spring-projects.
the class RecipientListRouterSpec method recipient.
/**
* Adds a recipient channel that will be selected if the the expression evaluates to 'true'.
* @param channelName the channel name.
* @param expression the expression.
* @return the router spec.
*/
public RecipientListRouterSpec recipient(String channelName, Expression expression) {
ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression);
this.handler.addRecipient(channelName, selector);
this.componentsToRegister.put(selector, null);
return _this();
}
use of org.springframework.integration.filter.ExpressionEvaluatingSelector in project spring-integration by spring-projects.
the class RecipientListRouter method removeRecipient.
@Override
@ManagedOperation
public int removeRecipient(String channelName, String selectorExpression) {
int counter = 0;
MessageChannel targetChannel = getChannelResolver().resolveDestination(channelName);
for (Iterator<Recipient> it = this.recipients.iterator(); it.hasNext(); ) {
Recipient next = it.next();
MessageSelector selector = next.getSelector();
MessageChannel channel = next.getChannel();
if (selector instanceof ExpressionEvaluatingSelector && channel == targetChannel && ((ExpressionEvaluatingSelector) selector).getExpressionString().equals(selectorExpression)) {
it.remove();
counter++;
}
}
return counter;
}
use of org.springframework.integration.filter.ExpressionEvaluatingSelector in project spring-integration by spring-projects.
the class RecipientListRouter method addRecipient.
private void addRecipient(String channelName, String selectorExpression, Queue<Recipient> recipients) {
Assert.hasText(channelName, "'channelName' must not be empty.");
Assert.hasText(selectorExpression, "'selectorExpression' must not be empty.");
ExpressionEvaluatingSelector expressionEvaluatingSelector = new ExpressionEvaluatingSelector(selectorExpression);
expressionEvaluatingSelector.setBeanFactory(getBeanFactory());
Recipient recipient = new Recipient(channelName, expressionEvaluatingSelector);
if (getBeanFactory() != null) {
recipient.setChannelResolver(getChannelResolver());
}
recipients.add(recipient);
}
use of org.springframework.integration.filter.ExpressionEvaluatingSelector in project spring-integration by spring-projects.
the class RecipientListRouterSpec method recipient.
/**
* Adds a recipient channel that will be selected if the the expression evaluates to 'true'.
* @param channel the recipient channel.
* @param expression the expression.
* @return the router spec.
*/
public RecipientListRouterSpec recipient(MessageChannel channel, Expression expression) {
if (expression != null) {
ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression);
this.handler.addRecipient(channel, selector);
this.componentsToRegister.put(selector, null);
} else {
this.handler.addRecipient(channel);
}
return _this();
}
Aggregations