01: /*
02: * $Id: RoutingException.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.api.routing;
12:
13: import org.mule.api.MessagingException;
14: import org.mule.api.MuleMessage;
15: import org.mule.api.endpoint.ImmutableEndpoint;
16: import org.mule.config.i18n.CoreMessages;
17: import org.mule.config.i18n.Message;
18:
19: /**
20: * <code>RoutingException</code> is a base class for all routing exceptions.
21: * Routing exceptions are only thrown for DefaultInboundRouterCollection and
22: * DefaultOutboundRouterCollection and deriving types. Mule itself does not throw routing
23: * exceptions when routing internal events.
24: */
25: public class RoutingException extends MessagingException {
26: /**
27: * Serial version
28: */
29: private static final long serialVersionUID = 2478458847072048645L;
30:
31: protected final transient ImmutableEndpoint endpoint;
32:
33: public RoutingException(MuleMessage message,
34: ImmutableEndpoint endpoint) {
35: super (generateMessage(null, endpoint), message);
36: this .endpoint = endpoint;
37: }
38:
39: public RoutingException(MuleMessage umoMessage,
40: ImmutableEndpoint endpoint, Throwable cause) {
41: super (generateMessage(null, endpoint), umoMessage, cause);
42: this .endpoint = endpoint;
43: }
44:
45: public RoutingException(Message message, MuleMessage umoMessage,
46: ImmutableEndpoint endpoint) {
47: super (generateMessage(message, endpoint), umoMessage);
48: this .endpoint = endpoint;
49: }
50:
51: public RoutingException(Message message, MuleMessage umoMessage,
52: ImmutableEndpoint endpoint, Throwable cause) {
53: super (generateMessage(message, endpoint), umoMessage, cause);
54: this .endpoint = endpoint;
55: }
56:
57: public ImmutableEndpoint getEndpoint() {
58: return endpoint;
59: }
60:
61: private static Message generateMessage(Message message,
62: ImmutableEndpoint endpoint) {
63: Message m = CoreMessages.failedToRouterViaEndpoint(endpoint);
64: if (message != null) {
65: message.setNextMessage(m);
66: return message;
67: } else {
68: return m;
69: }
70: }
71: }
|