1
2
3
4
5
6
7
8
9
10
11 package org.mule.routing.outbound;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.MuleSession;
15 import org.mule.api.endpoint.OutboundEndpoint;
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
27 public class OutboundPassThroughRouter extends FilteringOutboundRouter
28 {
29 public OutboundPassThroughRouter()
30 {
31 super();
32 }
33
34
35 public void addEndpoint(OutboundEndpoint endpoint)
36 {
37 if (endpoint == null)
38 {
39 return;
40 }
41 if (endpoints.size() == 1)
42 {
43 throw new IllegalArgumentException("Only one endpoint can be set on the PassThrough router");
44 }
45 super.addEndpoint(endpoint);
46 }
47
48 public void setEndpoints(List endpoints)
49 {
50 if (endpoints.size() > 1)
51 {
52 throw new IllegalArgumentException("Only one endpoint can be set on the PassThrough router");
53 }
54 super.setEndpoints(endpoints);
55 }
56
57 public void setFilter(Filter filter)
58 {
59 throw new UnsupportedOperationException(
60 "The Pass Through cannot use filters, use the FilteringOutboundRouter instead");
61 }
62
63 public MuleMessage route(MuleMessage message, MuleSession session, boolean synchronous)
64 throws RoutingException
65 {
66 if (endpoints == null || endpoints.size() == 0)
67 {
68 return message;
69 }
70 return super.route(message, session, synchronous);
71 }
72 }