KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > routing > outbound > OutboundPassThroughRouter


1 /*
2  * $Id: OutboundPassThroughRouter.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
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.outbound;
12
13 import org.mule.umo.UMOFilter;
14 import org.mule.umo.UMOImmutableDescriptor;
15 import org.mule.umo.UMOMessage;
16 import org.mule.umo.UMOSession;
17 import org.mule.umo.endpoint.UMOEndpoint;
18 import org.mule.umo.routing.RoutingException;
19
20 import java.util.List JavaDoc;
21
22 /**
23  * <code>InboundPassThroughRouter</code> allows outbound routing over a single
24  * endpoint without any filtering. This class is used by Mule when a single outbound
25  * router is set on a UMODescriptor.
26  *
27  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
28  * @version $Revision: 3798 $
29  */

30 public class OutboundPassThroughRouter extends FilteringOutboundRouter
31 {
32     public OutboundPassThroughRouter()
33     {
34         super();
35     }
36
37     public OutboundPassThroughRouter(UMOImmutableDescriptor descriptor)
38     {
39         super();
40         if (descriptor != null && descriptor.getOutboundEndpoint() != null)
41         {
42             addEndpoint(descriptor.getOutboundEndpoint());
43         }
44     }
45
46     public void addEndpoint(UMOEndpoint endpoint)
47     {
48         if (endpoint == null)
49         {
50             return;
51         }
52         if (endpoints.size() == 1)
53         {
54             throw new IllegalArgumentException JavaDoc("Only one endpoint can be set on the PassThrough router");
55         }
56         super.addEndpoint(endpoint);
57     }
58
59     public void setEndpoints(List JavaDoc endpoints)
60     {
61         if (endpoints.size() > 1)
62         {
63             throw new IllegalArgumentException JavaDoc("Only one endpoint can be set on the PassThrough router");
64         }
65         super.setEndpoints(endpoints);
66     }
67
68     public void setFilter(UMOFilter filter)
69     {
70         throw new UnsupportedOperationException JavaDoc(
71             "The Pass Through cannot use filters, use the FilteringOutboundRouter instead");
72     }
73
74     public UMOMessage route(UMOMessage message, UMOSession session, boolean synchronous)
75         throws RoutingException
76     {
77         if (endpoints == null || endpoints.size() == 0)
78         {
79             return message;
80         }
81         return super.route(message, session, synchronous);
82     }
83 }
84
Popular Tags