View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.api.lifecycle;
8   
9   import org.mule.api.MuleException;
10  import org.mule.config.i18n.CoreMessages;
11  import org.mule.config.i18n.Message;
12  import org.mule.util.ObjectUtils;
13  
14  /** <code>LifecycleException</code> TODO */
15  
16  public class LifecycleException extends MuleException
17  {
18  
19      /** Serial version */
20      private static final long serialVersionUID = 2909614055858287394L;
21  
22      private transient Object component;
23  
24      /**
25       * @param message   the exception message
26       * @param component the object that failed during a lifecycle method call
27       */
28      public LifecycleException(Message message, Object component)
29      {
30          super(message);
31          this.component = component;
32      }
33  
34      /**
35       * @param message   the exception message
36       * @param cause     the exception that cause this exception to be thrown
37       * @param component the object that failed during a lifecycle method call
38       */
39      public LifecycleException(Message message, Throwable cause, Object component)
40      {
41          super(message, cause);
42          this.component = component;
43      }
44  
45      /**
46       * @param cause     the exception that cause this exception to be thrown
47       * @param component the object that failed during a lifecycle method call
48       */
49      public LifecycleException(Throwable cause, Object component)
50      {
51          super(CoreMessages.createStaticMessage(cause.getMessage()), cause);
52          this.component = component;
53          addInfo("Object", ObjectUtils.toString(component, "null"));
54      }
55  
56      public Object getComponent()
57      {
58          return component;
59      }
60  }