View Javadoc

1   /*
2    * $Id: ConnectException.java 20358 2010-11-26 20:15:18Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.transport;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.transport.Connectable;
15  import org.mule.config.i18n.Message;
16  
17  /** 
18   * When this exception is thrown it will trigger a retry (reconnection) policy to go into effect if one is configured.
19   */
20  public class ConnectException extends MuleException
21  {
22      /** Serial version */
23      private static final long serialVersionUID = -7802483584780922653L;
24  
25      /** Resource which has disconnected */
26      private Connectable failed;
27      
28      public ConnectException(Message message, Connectable failed)
29      {
30          super(message);
31          // In the case of a MessageReceiver/MessageDispatcher, what we really want to reconnect is the Connector
32          this.failed = failed instanceof AbstractTransportMessageHandler ? ((AbstractTransportMessageHandler) failed).getConnector() : failed;
33      }
34  
35      public ConnectException(Message message, Throwable cause, Connectable failed)
36      {
37          super(message, cause);
38          // In the case of a MessageReceiver/MessageDispatcher, what we really want to reconnect is the Connector
39          this.failed = failed instanceof AbstractTransportMessageHandler ? ((AbstractTransportMessageHandler) failed).getConnector() : failed;
40      }
41  
42      public ConnectException(Throwable cause, Connectable failed)
43      {
44          super(cause);
45          // In the case of a MessageReceiver/MessageDispatcher, what we really want to reconnect is the Connector
46          this.failed = failed instanceof AbstractTransportMessageHandler ? ((AbstractTransportMessageHandler) failed).getConnector() : failed;
47      }
48      
49      public Connectable getFailed()
50      {
51          return failed;
52      }
53  }