KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > application > ApplicationException


1 /*
2  * $Header: /cvshome/build/org.osgi.service.application/src/org/osgi/service/application/ApplicationException.java,v 1.10 2006/07/10 11:49:12 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2005, 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.application;
20
21 /**
22  * This exception is used to indicate problems related to application
23  * lifecycle management.
24  *
25  * <code>ApplicationException</code> object is created by the Application Admin to denote
26  * an exception condition in the lifecycle of an application.
27  * <code>ApplicationException</code>s should not be created by developers.
28  * <br/>
29  * <code>ApplicationException</code>s are associated with an error code. This code
30  * describes the type of problem reported in this exception. The possible codes are:
31  * <ul>
32  * <li> {@link #APPLICATION_LOCKED} - The application couldn't be launched because it is locked.</li>
33  * <li> {@link #APPLICATION_NOT_LAUNCHABLE} - The application is not in launchable state.</li>
34  * <li> {@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the application or its
35  * container during launch.</li>
36  * <li> {@link #APPLICATION_SCHEDULING_FAILED} - The scheduling of an application
37  * failed.
38  * </ul>
39  *
40  */

41 public class ApplicationException extends Exception JavaDoc {
42     private static final long serialVersionUID = -7173190453622508207L;
43     private final Throwable JavaDoc cause;
44     private final int errorCode;
45     
46     /**
47      * The application couldn't be launched because it is locked.
48      */

49     public static final int APPLICATION_LOCKED = 0x01;
50     
51     /**
52      * The application is not in launchable state, it's
53      * {@link ApplicationDescriptor#APPLICATION_LAUNCHABLE}
54      * attribute is false.
55      */

56     public static final int APPLICATION_NOT_LAUNCHABLE = 0x02;
57     
58     /**
59      * An exception was thrown by the application or the corresponding
60      * container during launch. The exception is available in {@link #getCause()}.
61      */

62     public static final int APPLICATION_INTERNAL_ERROR = 0x03;
63     
64     /**
65      * The application schedule could not be created due to some internal error
66      * (for example, the schedule information couldn't be saved).
67      */

68     public static final int APPLICATION_SCHEDULING_FAILED = 0x04;
69     
70     /**
71      * The application scheduling failed because the specified identifier
72      * is already in use.
73      */

74     public static final int APPLICATION_DUPLICATE_SCHEDULE_ID = 0x05;
75
76     /**
77      * Creates an <code>ApplicationException</code> with the specified error code.
78      * @param errorCode The code of the error
79      */

80     public ApplicationException(int errorCode) {
81         this(errorCode,(Throwable JavaDoc) null);
82     }
83     
84     /**
85      * Creates a <code>ApplicationException</code> that wraps another exception.
86      *
87      * @param errorCode The code of the error
88      * @param cause The cause of this exception.
89      */

90     public ApplicationException(int errorCode, Throwable JavaDoc cause) {
91         super();
92         this.cause = cause;
93         this.errorCode = errorCode;
94     }
95
96     /**
97      * Creates an <code>ApplicationException</code> with the specified error code.
98      * @param errorCode The code of the error
99      * @param message The associated message
100      */

101     public ApplicationException(int errorCode, String JavaDoc message) {
102         this(errorCode, message,null);
103     }
104
105     /**
106      * Creates a <code>ApplicationException</code> that wraps another exception.
107      *
108      * @param errorCode The code of the error
109      * @param message The associated message.
110      * @param cause The cause of this exception.
111      */

112     public ApplicationException(int errorCode, String JavaDoc message, Throwable JavaDoc cause) {
113         super(message);
114         this.cause = cause;
115         this.errorCode = errorCode;
116     }
117
118     /**
119      * Returns the cause of this exception or <code>null</code> if no cause
120      * was specified when this exception was created.
121      *
122      * @return The cause of this exception or <code>null</code> if no cause
123      * was specified.
124      */

125     public Throwable JavaDoc getCause() {
126         return cause;
127     }
128
129     /**
130      * Returns the error code associcated with this exception.
131      * @return The error code of this exception.
132      */

133     public int getErrorCode() {
134         return errorCode;
135     }
136 }
137
Popular Tags