83
|
1 /*
|
|
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/FrameworkEvent.java,v 1.15 2007/02/20 00:14:12 hargrave Exp $
|
105
|
3 *
|
83
|
4 * Copyright (c) OSGi Alliance (2004, 2007). All Rights Reserved.
|
105
|
5 *
|
83
|
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
|
105
|
19 // Port to the D programming language:
|
|
20 // Frank Benoit <benoit@tionex.de>
|
83
|
21 module org.osgi.framework.FrameworkEvent;
|
|
22
|
|
23 import java.lang.all;
|
105
|
24
|
|
25 import org.osgi.framework.Bundle; // packageimport
|
|
26
|
83
|
27 import java.util.EventObject;
|
|
28
|
|
29 /**
|
|
30 * A general event from the Framework.
|
105
|
31 *
|
83
|
32 * <p>
|
|
33 * <code>FrameworkEvent</code> objects are delivered to
|
|
34 * <code>FrameworkListener</code>s when a general event occurs within the
|
|
35 * OSGi environment. A type code is used to identify the event type for future
|
|
36 * extendability.
|
105
|
37 *
|
83
|
38 * <p>
|
|
39 * OSGi Alliance reserves the right to extend the set of event types.
|
105
|
40 *
|
83
|
41 * @Immutable
|
|
42 * @see FrameworkListener
|
|
43 * @version $Revision: 1.15 $
|
|
44 */
|
|
45
|
|
46 public class FrameworkEvent : EventObject {
|
|
47 static final long serialVersionUID = 207051004521261705L;
|
|
48 /**
|
|
49 * Bundle related to the event.
|
|
50 */
|
|
51 private final Bundle bundle;
|
|
52
|
|
53 /**
|
|
54 * Exception related to the event.
|
|
55 */
|
|
56 private final Throwable throwable;
|
|
57
|
|
58 /**
|
|
59 * Type of event.
|
|
60 */
|
|
61 private final int type;
|
|
62
|
|
63 /**
|
|
64 * The Framework has started.
|
105
|
65 *
|
83
|
66 * <p>
|
|
67 * This event is fired when the Framework has started after all installed
|
|
68 * bundles that are marked to be started have been started and the Framework
|
|
69 * has reached the intitial start level.
|
105
|
70 *
|
83
|
71 * <p>
|
|
72 * The value of <code>STARTED</code> is 0x00000001.
|
105
|
73 *
|
83
|
74 * @see "<code>StartLevel</code>"
|
|
75 */
|
|
76 public final static int STARTED = 0x00000001;
|
|
77
|
|
78 /**
|
|
79 * An error has occurred.
|
105
|
80 *
|
83
|
81 * <p>
|
|
82 * There was an error associated with a bundle.
|
105
|
83 *
|
83
|
84 * <p>
|
|
85 * The value of <code>ERROR</code> is 0x00000002.
|
|
86 */
|
|
87 public final static int ERROR = 0x00000002;
|
|
88
|
|
89 /**
|
|
90 * A PackageAdmin.refreshPackage operation has completed.
|
105
|
91 *
|
83
|
92 * <p>
|
|
93 * This event is fired when the Framework has completed the refresh packages
|
|
94 * operation initiated by a call to the PackageAdmin.refreshPackages method.
|
105
|
95 *
|
83
|
96 * <p>
|
|
97 * The value of <code>PACKAGES_REFRESHED</code> is 0x00000004.
|
105
|
98 *
|
83
|
99 * @since 1.2
|
|
100 * @see "<code>PackageAdmin.refreshPackages</code>"
|
|
101 */
|
|
102 public final static int PACKAGES_REFRESHED = 0x00000004;
|
|
103
|
|
104 /**
|
|
105 * A StartLevel.setStartLevel operation has completed.
|
105
|
106 *
|
83
|
107 * <p>
|
|
108 * This event is fired when the Framework has completed changing the active
|
|
109 * start level initiated by a call to the StartLevel.setStartLevel method.
|
105
|
110 *
|
83
|
111 * <p>
|
|
112 * The value of <code>STARTLEVEL_CHANGED</code> is 0x00000008.
|
105
|
113 *
|
83
|
114 * @since 1.2
|
|
115 * @see "<code>StartLevel</code>"
|
|
116 */
|
|
117 public final static int STARTLEVEL_CHANGED = 0x00000008;
|
|
118
|
|
119 /**
|
|
120 * A warning has occurred.
|
105
|
121 *
|
83
|
122 * <p>
|
|
123 * There was a warning associated with a bundle.
|
105
|
124 *
|
83
|
125 * <p>
|
|
126 * The value of <code>WARNING</code> is 0x00000010.
|
105
|
127 *
|
83
|
128 * @since 1.3
|
|
129 */
|
|
130 public final static int WARNING = 0x00000010;
|
|
131
|
|
132 /**
|
|
133 * An informational event has occurred.
|
105
|
134 *
|
83
|
135 * <p>
|
|
136 * There was an informational event associated with a bundle.
|
105
|
137 *
|
83
|
138 * <p>
|
|
139 * The value of <code>INFO</code> is 0x00000020.
|
105
|
140 *
|
83
|
141 * @since 1.3
|
|
142 */
|
|
143 public final static int INFO = 0x00000020;
|
|
144
|
|
145 /**
|
|
146 * Creates a Framework event.
|
105
|
147 *
|
83
|
148 * @param type The event type.
|
|
149 * @param source The event source object. This may not be <code>null</code>.
|
|
150 * @deprecated As of 1.2. This constructor is deprecated in favor of using
|
|
151 * the other constructor with the System Bundle as the event
|
|
152 * source.
|
|
153 */
|
|
154 public this(int type, Object source) {
|
|
155 super(source);
|
|
156 this.type = type;
|
|
157 this.bundle = null;
|
|
158 this.throwable = null;
|
|
159 }
|
|
160
|
|
161 /**
|
|
162 * Creates a Framework event regarding the specified bundle.
|
105
|
163 *
|
83
|
164 * @param type The event type.
|
|
165 * @param bundle The event source.
|
|
166 * @param throwable The related exception. This argument may be
|
|
167 * <code>null</code> if there is no related exception.
|
|
168 */
|
|
169 public this(int type, Bundle bundle, Throwable throwable) {
|
105
|
170 super(bundle);
|
83
|
171 this.type = type;
|
|
172 this.bundle = bundle;
|
|
173 this.throwable = throwable;
|
|
174 }
|
|
175
|
|
176 /**
|
|
177 * Returns the exception related to this event.
|
105
|
178 *
|
83
|
179 * @return The related exception or <code>null</code> if none.
|
|
180 */
|
|
181 public Throwable getThrowable() {
|
|
182 return throwable;
|
|
183 }
|
|
184
|
|
185 /**
|
|
186 * Returns the bundle associated with the event. This bundle is also the
|
|
187 * source of the event.
|
105
|
188 *
|
83
|
189 * @return The bundle associated with the event.
|
|
190 */
|
|
191 public Bundle getBundle() {
|
|
192 return bundle;
|
|
193 }
|
|
194
|
|
195 /**
|
|
196 * Returns the type of framework event.
|
|
197 * <p>
|
|
198 * The type values are:
|
|
199 * <ul>
|
|
200 * <li>{@link #STARTED}
|
|
201 * <li>{@link #ERROR}
|
|
202 * <li>{@link #WARNING}
|
|
203 * <li>{@link #INFO}
|
|
204 * <li>{@link #PACKAGES_REFRESHED}
|
|
205 * <li>{@link #STARTLEVEL_CHANGED}
|
|
206 * </ul>
|
105
|
207 *
|
83
|
208 * @return The type of state change.
|
|
209 */
|
|
210
|
|
211 public int getType() {
|
|
212 return type;
|
|
213 }
|
|
214 }
|