View Javadoc

1   /*
2    * $Id: ComponentRoutingException.java 11728 2008-05-13 07:31:11Z 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.umo.routing;
12  
13  import org.mule.config.i18n.CoreMessages;
14  import org.mule.config.i18n.Message;
15  import org.mule.umo.UMOComponent;
16  import org.mule.umo.UMOMessage;
17  import org.mule.umo.endpoint.UMOImmutableEndpoint;
18  
19  /**
20   * <code>ComponentRoutingException</code> is thrown due to a routing exception
21   * between the endpoint the event was received on and the component receiving the
22   * event.
23   */
24  public class ComponentRoutingException extends RoutingException
25  {
26      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = -113944443831267318L;
30  
31      private transient UMOComponent component;
32  
33      public ComponentRoutingException(Message message,
34                                       UMOMessage umoMessage,
35                                       UMOImmutableEndpoint endpoint,
36                                       UMOComponent component)
37      {
38          super(generateMessage(message, endpoint, component), umoMessage, endpoint);
39          this.component = component;
40      }
41  
42      public ComponentRoutingException(Message message,
43                                       UMOMessage umoMessage,
44                                       UMOImmutableEndpoint endpoint,
45                                       UMOComponent component,
46                                       Throwable cause)
47      {
48          super(generateMessage(message, endpoint, component), umoMessage, endpoint, cause);
49          this.component = component;
50      }
51  
52      public ComponentRoutingException(UMOMessage umoMessage,
53                                       UMOImmutableEndpoint endpoint,
54                                       UMOComponent component)
55      {
56          super(generateMessage(null, endpoint, component), umoMessage, endpoint);
57          this.component = component;
58      }
59  
60      public ComponentRoutingException(UMOMessage umoMessage,
61                                       UMOImmutableEndpoint endpoint,
62                                       UMOComponent component,
63                                       Throwable cause)
64      {
65          super(generateMessage(null, endpoint, component), umoMessage, endpoint, cause);
66          this.component = component;
67  
68      }
69  
70      private static Message generateMessage(Message message,
71                                             UMOImmutableEndpoint endpoint,
72                                             UMOComponent component)
73      {
74          Message m = CoreMessages.routingFailedOnEndpoint(component, 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 UMOComponent getComponent()
87      {
88          return component;
89      }
90  }