KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > component > ComponentException


1 /*
2  * $Header: /cvshome/build/org.osgi.service.component/src/org/osgi/service/component/ComponentException.java,v 1.13 2006/07/11 13:15:56 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.osgi.service.component;
20
21 /**
22  * Unchecked exception which may be thrown by the Service Component Runtime.
23  *
24  * @version $Revision: 1.13 $
25  */

26 public class ComponentException extends RuntimeException JavaDoc {
27     static final long serialVersionUID = -7438212656298726924L;
28     /**
29      * Nested exception.
30      */

31     private final Throwable JavaDoc cause;
32
33     /**
34      * Construct a new ComponentException with the specified message and cause.
35      *
36      * @param message The message for the exception.
37      * @param cause The cause of the exception. May be <code>null</code>.
38      */

39     public ComponentException(String JavaDoc message, Throwable JavaDoc cause) {
40         super(message);
41         this.cause = cause;
42     }
43
44     /**
45      * Construct a new ComponentException with the specified message.
46      *
47      * @param message The message for the exception.
48      */

49     public ComponentException(String JavaDoc message) {
50         super(message);
51         this.cause = null;
52     }
53
54     /**
55      * Construct a new ComponentException with the specified cause.
56      *
57      * @param cause The cause of the exception. May be <code>null</code>.
58      */

59     public ComponentException(Throwable JavaDoc cause) {
60         super();
61         this.cause = cause;
62     }
63
64     /**
65      * Returns the cause of this exception or <code>null</code> if no cause
66      * was specified when this exception was created.
67      *
68      * @return The cause of this exception or <code>null</code> if no cause
69      * was specified.
70      */

71     public Throwable JavaDoc getCause() {
72         return cause;
73     }
74
75     /**
76      * The cause of this exception can only be set when constructed.
77      *
78      * @param cause Cause of the exception.
79      * @return This object.
80      * @throws java.lang.IllegalStateException This method will always throw an
81      * <code>IllegalStateException</code> since the cause of this
82      * exception can only be set when constructed.
83      */

84     public Throwable JavaDoc initCause(Throwable JavaDoc cause) {
85         throw new IllegalStateException JavaDoc();
86     }
87 }
88
Popular Tags