Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 779d6e1b57baceff8571c2793ee2f81bc6b2dd9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
 * Copyright (c) OSGi Alliance (2000, 2010). All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.osgi.framework;

/**
 * A Framework exception used to indicate that a bundle lifecycle problem
 * occurred.
 * 
 * <p>
 * A {@code BundleException} object is created by the Framework to denote
 * an exception condition in the lifecycle of a bundle.
 * {@code BundleException}s should not be created by bundle developers.
 * A type code is used to identify the exception type for future extendability.
 * 
 * <p>
 * OSGi Alliance reserves the right to extend the set of types.
 * 
 * <p>
 * This exception conforms to the general purpose exception chaining mechanism.
 * 
 * @version $Id: dd5f95820ef8e87bd521e13dec86ff36da33456e $
 */

public class BundleException extends Exception {
	static final long		serialVersionUID		= 3571095144220455665L;
	/**
	 * Type of bundle exception.
	 * 
	 * @since 1.5
	 */
	private final int		type;

	/**
	 * No exception type is specified.
	 * 
	 * @since 1.5
	 */
	public static final int	UNSPECIFIED				= 0;
	/**
	 * The operation was unsupported.
	 * 
	 * @since 1.5
	 */
	public static final int	UNSUPPORTED_OPERATION	= 1;
	/**
	 * The operation was invalid.
	 * 
	 * @since 1.5
	 */
	public static final int	INVALID_OPERATION		= 2;
	/**
	 * The bundle manifest was in error.
	 * 
	 * @since 1.5
	 */
	public static final int	MANIFEST_ERROR			= 3;
	/**
	 * The bundle was not resolved.
	 * 
	 * @since 1.5
	 */
	public static final int	RESOLVE_ERROR			= 4;
	/**
	 * The bundle activator was in error.
	 * 
	 * @since 1.5
	 */
	public static final int	ACTIVATOR_ERROR			= 5;
	/**
	 * The operation failed due to insufficient permissions.
	 * 
	 * @since 1.5
	 */
	public static final int	SECURITY_ERROR			= 6;
	/**
	 * The operation failed to complete the requested lifecycle state change.
	 * 
	 * @since 1.5
	 */
	public static final int	STATECHANGE_ERROR		= 7;

	/**
	 * The bundle could not be resolved due to an error with the
	 * Bundle-NativeCode header.
	 * 
	 * @since 1.5
	 */
	public static final int	NATIVECODE_ERROR		= 8;

	/**
	 * The install or update operation failed because another already installed
	 * bundle has the same symbolic name and version. This exception type will
	 * only occur if the framework is configured to only allow a single bundle
	 * to be installed for a given symbolic name and version.
	 * 
	 * @see Constants#FRAMEWORK_BSNVERSION
	 * @since 1.5
	 */
	public static final int	DUPLICATE_BUNDLE_ERROR	= 9;
	
    /**
	 * The start transient operation failed because the start level of the
	 * bundle is greater than the current framework start level
	 * 
	 * @since 1.5
	 */
	public static final int	START_TRANSIENT_ERROR	= 10;

	/**
	 * Creates a {@code BundleException} with the specified message and
	 * exception cause.
	 * 
	 * @param msg The associated message.
	 * @param cause The cause of this exception.
	 */
	public BundleException(String msg, Throwable cause) {
		this(msg, UNSPECIFIED, cause);
	}

	/**
	 * Creates a {@code BundleException} with the specified message.
	 * 
	 * @param msg The message.
	 */
	public BundleException(String msg) {
		this(msg, UNSPECIFIED);
	}

	/**
	 * Creates a {@code BundleException} with the specified message, type
	 * and exception cause.
	 * 
	 * @param msg The associated message.
	 * @param type The type for this exception.
	 * @param cause The cause of this exception.
	 * @since 1.5
	 */
	public BundleException(String msg, int type, Throwable cause) {
		super(msg, cause);
		this.type = type;
	}

	/**
	 * Creates a {@code BundleException} with the specified message and
	 * type.
	 * 
	 * @param msg The message.
	 * @param type The type for this exception.
	 * @since 1.5
	 */
	public BundleException(String msg, int type) {
		super(msg);
		this.type = type;
	}

	/**
	 * Returns the cause of this exception or {@code null} if no cause was
	 * specified when this exception was created.
	 * 
	 * <p>
	 * This method predates the general purpose exception chaining mechanism.
	 * The {@code getCause()} method is now the preferred means of
	 * obtaining this information.
	 * 
	 * @return The result of calling {@code getCause()}.
	 */
	public Throwable getNestedException() {
		return getCause();
	}

	/**
	 * Returns the cause of this exception or {@code null} if no cause was
	 * set.
	 * 
	 * @return The cause of this exception or {@code null} if no cause was
	 *         set.
	 * @since 1.3
	 */
	public Throwable getCause() {
		return super.getCause();
	}

	/**
	 * Initializes the cause of this exception to the specified value.
	 * 
	 * @param cause The cause of this exception.
	 * @return This exception.
	 * @throws IllegalArgumentException If the specified cause is this
	 *         exception.
	 * @throws IllegalStateException If the cause of this exception has already
	 *         been set.
	 * @since 1.3
	 */
	public Throwable initCause(Throwable cause) {
		return super.initCause(cause);
	}

	/**
	 * Returns the type for this exception or {@code UNSPECIFIED} if the
	 * type was unspecified or unknown.
	 * 
	 * @return The type of this exception.
	 * @since 1.5
	 */
	public int getType() {
		return type;
	}
}

Back to the top