use of org.springframework.integration.core.MessageSelector in project spring-integration by spring-projects.
the class TopLevelSelectorParserTests method topLevelSelector.
@Test
public void topLevelSelector() {
MessageSelector selector = (MessageSelector) context.getBean("selector");
assertTrue(selector.accept(new GenericMessage<String>("test")));
}
use of org.springframework.integration.core.MessageSelector in project spring-integration by spring-projects.
the class RecipientListRouterSpec method recipient.
/**
* Adds a recipient channel that will be selected if the the selector's accept method returns 'true'.
* @param channel the recipient channel.
* @param selector the selector.
* @param <P> the selector source type.
* @return the router spec.
*/
public <P> RecipientListRouterSpec recipient(MessageChannel channel, GenericSelector<P> selector) {
MessageSelector messageSelector;
if (selector instanceof MessageSelector) {
messageSelector = (MessageSelector) selector;
} else {
messageSelector = isLambda(selector) ? new MethodInvokingSelector(new LambdaMessageProcessor(selector, null)) : new MethodInvokingSelector(selector);
}
this.handler.addRecipient(channel, messageSelector);
return _this();
}
use of org.springframework.integration.core.MessageSelector in project spring-integration by spring-projects.
the class RecipientListRouterSpec method recipient.
/**
* Adds a recipient channel that will be selected if the the selector's accept method returns 'true'.
* @param channelName the channel name.
* @param selector the selector.
* @param <P> the selector source type.
* @return the router spec.
*/
public <P> RecipientListRouterSpec recipient(String channelName, GenericSelector<P> selector) {
MessageSelector messageSelector;
if (selector instanceof MessageSelector) {
messageSelector = (MessageSelector) selector;
} else {
messageSelector = isLambda(selector) ? new MethodInvokingSelector(new LambdaMessageProcessor(selector, null)) : new MethodInvokingSelector(selector);
}
this.handler.addRecipient(channelName, messageSelector);
return _this();
}
use of org.springframework.integration.core.MessageSelector in project spring-integration by spring-projects.
the class MessageSelectorChain method accept.
/**
* Pass the message through the selector chain. Whether the Message is
* {@link #accept(Message) accepted} is based upon the tallied results of
* the individual selectors' responses in accordance with this chain's
* {@link VotingStrategy}.
*/
@Override
public final boolean accept(Message<?> message) {
int count = 0;
int accepted = 0;
for (MessageSelector next : this.selectors) {
count++;
if (next.accept(message)) {
if (this.votingStrategy.equals(VotingStrategy.ANY)) {
return true;
}
accepted++;
} else if (this.votingStrategy.equals(VotingStrategy.ALL)) {
return false;
}
}
return this.decide(accepted, count);
}
use of org.springframework.integration.core.MessageSelector in project spring-integration by spring-projects.
the class MessageSelectingInterceptorTests method testSingleSelectorRejects.
@Test(expected = MessageDeliveryException.class)
public void testSingleSelectorRejects() {
final AtomicInteger counter = new AtomicInteger();
MessageSelector selector = new TestMessageSelector(false, counter);
MessageSelectingInterceptor interceptor = new MessageSelectingInterceptor(selector);
QueueChannel channel = new QueueChannel();
channel.addInterceptor(interceptor);
channel.send(new GenericMessage<String>("test1"));
}
Aggregations