KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > framework > BundleException


1 /*
2  * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleException.java,v 1.15 2006/07/11 13:15:54 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2000, 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.framework;
20
21 /**
22  * A Framework exception used to indicate that a bundle lifecycle problem
23  * occurred.
24  *
25  * <p>
26  * <code>BundleException</code> object is created by the Framework to denote
27  * an exception condition in the lifecycle of a bundle.
28  * <code>BundleException</code>s should not be created by bundle developers.
29  *
30  * <p>
31  * This exception is updated to conform to the general purpose exception
32  * chaining mechanism.
33  *
34  * @version $Revision: 1.15 $
35  */

36
37 public class BundleException extends Exception JavaDoc {
38     static final long serialVersionUID = 3571095144220455665L;
39     /**
40      * Nested exception.
41      */

42     private final Throwable JavaDoc cause;
43
44     /**
45      * Creates a <code>BundleException</code> that wraps another exception.
46      *
47      * @param msg The associated message.
48      * @param cause The cause of this exception.
49      */

50     public BundleException(String JavaDoc msg, Throwable JavaDoc cause) {
51         super(msg);
52         this.cause = cause;
53     }
54
55     /**
56      * Creates a <code>BundleException</code> object with the specified
57      * message.
58      *
59      * @param msg The message.
60      */

61     public BundleException(String JavaDoc msg) {
62         super(msg);
63         this.cause = null;
64     }
65
66     /**
67      * Returns any nested exceptions included in this exception.
68      *
69      * <p>
70      * This method predates the general purpose exception chaining mechanism.
71      * The {@link #getCause()} method is now the preferred means of obtaining
72      * this information.
73      *
74      * @return The nested exception; <code>null</code> if there is no nested
75      * exception.
76      */

77     public Throwable JavaDoc getNestedException() {
78         return cause;
79     }
80
81     /**
82      * Returns the cause of this exception or <code>null</code> if no cause
83      * was specified when this exception was created.
84      *
85      * @return The cause of this exception or <code>null</code> if no cause
86      * was specified.
87      * @since 1.3
88      */

89     public Throwable JavaDoc getCause() {
90         return cause;
91     }
92
93     /**
94      * The cause of this exception can only be set when constructed.
95      *
96      * @param cause Cause of the exception.
97      * @return This object.
98      * @throws java.lang.IllegalStateException This method will always throw an
99      * <code>IllegalStateException</code> since the cause of this
100      * exception can only be set when constructed.
101      * @since 1.3
102      */

103     public Throwable JavaDoc initCause(Throwable JavaDoc cause) {
104         throw new IllegalStateException JavaDoc();
105     }
106 }
107
Popular Tags