01: /*
02: * $Id: ServiceRoutingException.java 10529 2008-01-25 05:58:36Z 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.MuleMessage;
14: import org.mule.api.endpoint.ImmutableEndpoint;
15: import org.mule.api.service.Service;
16: import org.mule.config.i18n.CoreMessages;
17: import org.mule.config.i18n.Message;
18:
19: /**
20: * <code>ServiceRoutingException</code> is thrown due to a routing exception
21: * between the endpoint the event was received on and the service receiving the
22: * event.
23: */
24: public class ServiceRoutingException extends RoutingException {
25: /**
26: * Serial version
27: */
28: private static final long serialVersionUID = -113944443831267318L;
29:
30: private transient Service service;
31:
32: public ServiceRoutingException(Message message,
33: MuleMessage umoMessage, ImmutableEndpoint endpoint,
34: Service service) {
35: super (generateMessage(message, endpoint, service), umoMessage,
36: endpoint);
37: this .service = service;
38: }
39:
40: public ServiceRoutingException(Message message,
41: MuleMessage umoMessage, ImmutableEndpoint endpoint,
42: Service service, Throwable cause) {
43: super (generateMessage(message, endpoint, service), umoMessage,
44: endpoint, cause);
45: this .service = service;
46: }
47:
48: public ServiceRoutingException(MuleMessage umoMessage,
49: ImmutableEndpoint endpoint, Service service) {
50: super (generateMessage(null, endpoint, service), umoMessage,
51: endpoint);
52: this .service = service;
53: }
54:
55: public ServiceRoutingException(MuleMessage umoMessage,
56: ImmutableEndpoint endpoint, Service service, Throwable cause) {
57: super (generateMessage(null, endpoint, service), umoMessage,
58: endpoint, cause);
59: this .service = service;
60:
61: }
62:
63: private static Message generateMessage(Message message,
64: ImmutableEndpoint endpoint, Service service) {
65:
66: Message m = CoreMessages.routingFailedOnEndpoint(service
67: .getName(), endpoint.getEndpointURI());
68: if (message != null) {
69: message.setNextMessage(m);
70: return message;
71: } else {
72: return m;
73: }
74: }
75:
76: public Service getService() {
77: return service;
78: }
79: }
|