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 super();
31 }
32
33 @Override
34 public void addRoute(MessageProcessor target) throws MuleException
35 {
36 if (target == null)
37 {
38 return;
39 }
40 if (routes.size() == 1)
41 {
42 throw new IllegalArgumentException("Only one target can be set on the PassThrough router");
43 }
44 super.addRoute(target);
45 }
46
47 @Override
48 public void setRoutes(List<MessageProcessor> endpoints) throws MuleException
49 {
50 if (endpoints.size() > 1)
51 {
52 throw new IllegalArgumentException("Only one endpoint can be set on the PassThrough router");
53 }
54 super.setRoutes(endpoints);
55 }
56
57 @Override
58 public void setFilter(Filter filter)
59 {
60 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 if (routes == null || routes.size() == 0)
68 {
69 return event;
70 }
71 return super.route(event);
72 }
73 }