Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ChoiceRouter |
|
| 0.0;0 |
1 | /* | |
2 | * $Id$ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.routing; | |
12 | ||
13 | import java.util.Collection; | |
14 | import java.util.Collections; | |
15 | ||
16 | import org.mule.api.MuleEvent; | |
17 | import org.mule.api.processor.MessageProcessor; | |
18 | import org.mule.api.routing.RoutePathNotFoundException; | |
19 | import org.mule.api.routing.filter.Filter; | |
20 | ||
21 | /** | |
22 | * Routes the event to a single<code>MessageProcessor</code> using a {@link Filter} | |
23 | * to evaluate the event being processed and find the first route that can be used. | |
24 | * <p> | |
25 | * If a default route has been configured and no match has been found, the default | |
26 | * route will be used. Otherwise it throws a {@link RoutePathNotFoundException}. | |
27 | */ | |
28 | 0 | public class ChoiceRouter extends AbstractSelectiveRouter |
29 | { | |
30 | @Override | |
31 | protected Collection<MessageProcessor> selectProcessors(MuleEvent event) | |
32 | { | |
33 | 0 | for (MessageProcessorFilterPair mpfp : getConditionalMessageProcessors()) |
34 | { | |
35 | 0 | if (mpfp.getFilter().accept(event.getMessage())) |
36 | { | |
37 | 0 | return Collections.singleton(mpfp.getMessageProcessor()); |
38 | } | |
39 | } | |
40 | ||
41 | 0 | return Collections.emptySet(); |
42 | } | |
43 | } |