KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > umo > routing > RoutingException


1 /*
2  * $Id: RoutingException.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.umo.routing;
12
13 import org.mule.config.i18n.Message;
14 import org.mule.config.i18n.Messages;
15 import org.mule.umo.MessagingException;
16 import org.mule.umo.UMOMessage;
17 import org.mule.umo.endpoint.UMOImmutableEndpoint;
18
19 /**
20  * <code>RoutingException</code> is a base class for all routing exceptions.
21  * Routing exceptions are only thrown for InboundMessageRouter and
22  * OutboundMessageRouter and deriving types. Mule itself does not throw routing
23  * exceptions when routing internal events.
24  *
25  * @version $Revision: 3798 $
26  */

27 public class RoutingException extends MessagingException
28 {
29     /**
30      * Serial version
31      */

32     private static final long serialVersionUID = 2478458847072048645L;
33
34     protected transient UMOImmutableEndpoint endpoint;
35
36     public RoutingException(UMOMessage message, UMOImmutableEndpoint endpoint)
37     {
38         super(generateMessage(null, endpoint), message);
39         this.endpoint = endpoint;
40     }
41
42     public RoutingException(UMOMessage umoMessage, UMOImmutableEndpoint endpoint, Throwable JavaDoc cause)
43     {
44         super(generateMessage(null, endpoint), umoMessage, cause);
45         this.endpoint = endpoint;
46     }
47
48     public RoutingException(Message message, UMOMessage umoMessage, UMOImmutableEndpoint endpoint)
49     {
50         super(generateMessage(message, endpoint), umoMessage);
51         this.endpoint = endpoint;
52     }
53
54     public RoutingException(Message message,
55                             UMOMessage umoMessage,
56                             UMOImmutableEndpoint endpoint,
57                             Throwable JavaDoc cause)
58     {
59         super(generateMessage(message, endpoint), umoMessage, cause);
60         this.endpoint = endpoint;
61     }
62
63     public UMOImmutableEndpoint getEndpoint()
64     {
65         return endpoint;
66     }
67
68     private static Message generateMessage(Message message, UMOImmutableEndpoint endpoint)
69     {
70         Message m = new Message(Messages.FAILED_TO_ROUTER_VIA_ENDPOINT, endpoint);
71         if (message != null)
72         {
73             message.setNextMessage(m);
74             return message;
75         }
76         else
77         {
78             return m;
79         }
80     }
81 }
82
Popular Tags