KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > umo > ComponentException


1 /*
2  * $Id: ComponentException.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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;
12
13 import org.mule.config.i18n.Message;
14 import org.mule.config.i18n.Messages;
15
16 /**
17  * <code>ComponentException</code> should be thrown when some action on a component
18  * fails, such as starting or stopping
19  */

20 // @ThreadSafe
21
public class ComponentException extends MessagingException
22 {
23     /**
24      * Serial version
25      */

26     private static final long serialVersionUID = 56178344205041599L;
27
28     private transient final UMOComponent component;
29
30     /**
31      * @param message the exception message
32      */

33     public ComponentException(Message message, UMOMessage umoMessage, UMOComponent component)
34     {
35         super(generateMessage(message, component), umoMessage);
36         this.component = component;
37     }
38
39     /**
40      * @param message the exception message
41      * @param cause the exception that cause this exception to be thrown
42      */

43     public ComponentException(Message message, UMOMessage umoMessage, UMOComponent component, Throwable JavaDoc cause)
44     {
45         super(generateMessage(message, component), umoMessage, cause);
46         this.component = component;
47     }
48
49     public ComponentException(UMOMessage umoMessage, UMOComponent component, Throwable JavaDoc cause)
50     {
51         super(generateMessage(null, component), umoMessage, cause);
52         this.component = component;
53     }
54
55     public UMOComponent getComponent()
56     {
57         return component;
58     }
59
60     private static Message generateMessage(Message previousMessage, UMOComponent component)
61     {
62         Message returnMessage = new Message(Messages.COMPONENT_CAUSED_ERROR_IS_X, component);
63         if (previousMessage != null)
64         {
65             previousMessage.setNextMessage(returnMessage);
66             return previousMessage;
67         }
68         else
69         {
70             return returnMessage;
71         }
72     }
73
74 }
75
Popular Tags