View Javadoc

1   /*
2    * $Id: ConnectorException.java 7963 2007-08-21 08:53:15Z 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.provider;
12  
13  import org.mule.config.i18n.CoreMessages;
14  import org.mule.config.i18n.Message;
15  import org.mule.umo.UMOException;
16  
17  /**
18   * <code>ConnectorException</code> Is thrown in the context of a UMOConnector,
19   * usually some sort of transport level error where the connection has failed. This
20   * exception maintains a reference to the connector.
21   * 
22   * @see UMOConnector
23   */
24  public class ConnectorException extends UMOException
25  {
26      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = 4729481487016346035L;
30  
31      /**
32       * The connector relevant to this exception
33       */
34      private transient UMOConnector connector;
35  
36      /**
37       * @param message the exception message
38       * @param connector where the exception occurred or is being thrown
39       */
40      public ConnectorException(Message message, UMOConnector connector)
41      {
42          super(generateMessage(message, connector));
43          this.connector = connector;
44      }
45  
46      /**
47       * @param message the exception message
48       * @param connector where the exception occurred or is being thrown
49       * @param cause the exception that cause this exception to be thrown
50       */
51      public ConnectorException(Message message, UMOConnector connector, Throwable cause)
52      {
53          super(generateMessage(message, connector), cause);
54          this.connector = connector;
55      }
56  
57      private static Message generateMessage(Message message, UMOConnector connector)
58      {
59          Message m = CoreMessages.connectorCausedError(connector);
60          if (message != null)
61          {
62              message.setNextMessage(m);
63          }
64          return message;
65      }
66  
67      public UMOConnector getConnector()
68      {
69          return connector;
70      }
71  }