View Javadoc

1   /*
2    * $Id: ServiceRoutingException.java 11717 2008-05-09 13:26:38Z dirk.olmes $
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 CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
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      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = -113944443831267318L;
30  
31      private transient Service service;
32  
33      public ServiceRoutingException(Message message,
34                                       MuleMessage umoMessage,
35                                       ImmutableEndpoint endpoint,
36                                       Service service)
37      {
38          super(generateMessage(message, endpoint, service), umoMessage, endpoint);
39          this.service = service;
40      }
41  
42      public ServiceRoutingException(Message message,
43                                       MuleMessage umoMessage,
44                                       ImmutableEndpoint endpoint,
45                                       Service service,
46                                       Throwable cause)
47      {
48          super(generateMessage(message, endpoint, service), umoMessage, endpoint, cause);
49          this.service = service;
50      }
51  
52      public ServiceRoutingException(MuleMessage umoMessage,
53                                       ImmutableEndpoint endpoint,
54                                       Service service)
55      {
56          super(generateMessage(null, endpoint, service), umoMessage, endpoint);
57          this.service = service;
58      }
59  
60      public ServiceRoutingException(MuleMessage umoMessage,
61                                       ImmutableEndpoint endpoint,
62                                       Service service,
63                                       Throwable cause)
64      {
65          super(generateMessage(null, endpoint, service), umoMessage, endpoint, cause);
66          this.service = service;
67  
68      }
69  
70      private static Message generateMessage(Message message,
71                                             ImmutableEndpoint endpoint,
72                                             Service service)
73      {
74          Message m = CoreMessages.routingFailedOnEndpoint(service, endpoint);
75          if (message != null)
76          {
77              message.setNextMessage(m);
78              return message;
79          }
80          else
81          {
82              return m;
83          }
84      }
85  
86      public Service getService()
87      {
88          return service;
89      }
90  }