1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.routing.outbound; |
12 | |
|
13 | |
import org.mule.api.MuleEvent; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.processor.MessageProcessor; |
16 | |
import org.mule.api.routing.RoutingException; |
17 | |
import org.mule.api.routing.filter.Filter; |
18 | |
|
19 | |
import java.util.List; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class OutboundPassThroughRouter extends FilteringOutboundRouter |
27 | |
{ |
28 | |
public OutboundPassThroughRouter() |
29 | |
{ |
30 | 0 | super(); |
31 | 0 | } |
32 | |
|
33 | |
@Override |
34 | |
public void addRoute(MessageProcessor target) throws MuleException |
35 | |
{ |
36 | 0 | if (target == null) |
37 | |
{ |
38 | 0 | return; |
39 | |
} |
40 | 0 | if (routes.size() == 1) |
41 | |
{ |
42 | 0 | throw new IllegalArgumentException("Only one target can be set on the PassThrough router"); |
43 | |
} |
44 | 0 | super.addRoute(target); |
45 | 0 | } |
46 | |
|
47 | |
@Override |
48 | |
public void setRoutes(List<MessageProcessor> endpoints) throws MuleException |
49 | |
{ |
50 | 0 | if (endpoints.size() > 1) |
51 | |
{ |
52 | 0 | throw new IllegalArgumentException("Only one endpoint can be set on the PassThrough router"); |
53 | |
} |
54 | 0 | super.setRoutes(endpoints); |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
public void setFilter(Filter filter) |
59 | |
{ |
60 | 0 | throw new UnsupportedOperationException( |
61 | |
"The Pass Through cannot use filters, use the FilteringOutboundRouter instead"); |
62 | |
} |
63 | |
|
64 | |
@Override |
65 | |
public MuleEvent route(MuleEvent event) throws RoutingException |
66 | |
{ |
67 | 0 | if (routes == null || routes.size() == 0) |
68 | |
{ |
69 | 0 | return event; |
70 | |
} |
71 | 0 | return super.route(event); |
72 | |
} |
73 | |
} |