86
|
1 /*
|
|
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleEvent.java,v 1.19 2007/02/20 00:14:12 hargrave Exp $
|
105
|
3 *
|
86
|
4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved.
|
105
|
5 *
|
86
|
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>
|
86
|
21 module org.osgi.framework.BundleEvent;
|
105
|
22
|
|
23 import java.lang.all;
|
|
24
|
|
25 import org.osgi.framework.Bundle; // packageimport
|
86
|
26
|
|
27 import java.util.EventObject;
|
|
28
|
|
29 /**
|
|
30 * An event from the Framework describing a bundle lifecycle change.
|
|
31 * <p>
|
|
32 * <code>BundleEvent</code> objects are delivered to
|
|
33 * <code>SynchronousBundleListener</code>s and <code>BundleListener</code>s
|
|
34 * when a change occurs in a bundle's lifecycle. A type code is used to identify
|
|
35 * the event type for future extendability.
|
105
|
36 *
|
86
|
37 * <p>
|
|
38 * OSGi Alliance reserves the right to extend the set of types.
|
105
|
39 *
|
86
|
40 * @Immutable
|
|
41 * @see BundleListener
|
|
42 * @see SynchronousBundleListener
|
|
43 * @version $Revision: 1.19 $
|
|
44 */
|
|
45
|
|
46 public class BundleEvent : EventObject {
|
|
47 static final long serialVersionUID = 4080640865971756012L;
|
|
48 /**
|
|
49 * Bundle that had a change occur in its lifecycle.
|
|
50 */
|
|
51 private final Bundle bundle;
|
|
52
|
|
53 /**
|
|
54 * Type of bundle lifecycle change.
|
|
55 */
|
|
56 private final int type;
|
|
57
|
|
58 /**
|
|
59 * The bundle has been installed.
|
|
60 * <p>
|
|
61 * The value of <code>INSTALLED</code> is 0x00000001.
|
105
|
62 *
|
86
|
63 * @see BundleContext#installBundle(String)
|
|
64 */
|
|
65 public final static int INSTALLED = 0x00000001;
|
|
66
|
|
67 /**
|
|
68 * The bundle has been started.
|
|
69 * <p>
|
|
70 * The bundle's
|
|
71 * {@link BundleActivator#start(BundleContext) BundleActivator start} method
|
|
72 * has been executed if the bundle has a bundle activator class.
|
|
73 * <p>
|
|
74 * The value of <code>STARTED</code> is 0x00000002.
|
105
|
75 *
|
86
|
76 * @see Bundle#start()
|
|
77 */
|
|
78 public final static int STARTED = 0x00000002;
|
|
79
|
|
80 /**
|
|
81 * The bundle has been stopped.
|
|
82 * <p>
|
|
83 * The bundle's
|
|
84 * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method
|
|
85 * has been executed if the bundle has a bundle activator class.
|
|
86 * <p>
|
|
87 * The value of <code>STOPPED</code> is 0x00000004.
|
105
|
88 *
|
86
|
89 * @see Bundle#stop()
|
|
90 */
|
|
91 public final static int STOPPED = 0x00000004;
|
|
92
|
|
93 /**
|
|
94 * The bundle has been updated.
|
|
95 * <p>
|
|
96 * The value of <code>UPDATED</code> is 0x00000008.
|
105
|
97 *
|
86
|
98 * @see Bundle#update()
|
|
99 */
|
|
100 public final static int UPDATED = 0x00000008;
|
|
101
|
|
102 /**
|
|
103 * The bundle has been uninstalled.
|
|
104 * <p>
|
|
105 * The value of <code>UNINSTALLED</code> is 0x00000010.
|
105
|
106 *
|
86
|
107 * @see Bundle#uninstall
|
|
108 */
|
|
109 public final static int UNINSTALLED = 0x00000010;
|
|
110
|
|
111 /**
|
|
112 * The bundle has been resolved.
|
|
113 * <p>
|
|
114 * The value of <code>RESOLVED</code> is 0x00000020.
|
105
|
115 *
|
86
|
116 * @see Bundle#RESOLVED
|
|
117 * @since 1.3
|
|
118 */
|
|
119 public final static int RESOLVED = 0x00000020;
|
|
120
|
|
121 /**
|
|
122 * The bundle has been unresolved.
|
|
123 * <p>
|
|
124 * The value of <code>UNRESOLVED</code> is 0x00000040.
|
105
|
125 *
|
86
|
126 * @see Bundle#INSTALLED
|
|
127 * @since 1.3
|
|
128 */
|
|
129 public final static int UNRESOLVED = 0x00000040;
|
|
130
|
|
131 /**
|
|
132 * The bundle is about to be activated.
|
|
133 * <p>
|
|
134 * The bundle's
|
|
135 * {@link BundleActivator#start(BundleContext) BundleActivator start} method
|
|
136 * is about to be called if the bundle has a bundle activator class. This
|
|
137 * event is only delivered to {@link SynchronousBundleListener}s. It is not
|
|
138 * delivered to <code>BundleListener</code>s.
|
|
139 * <p>
|
|
140 * The value of <code>STARTING</code> is 0x00000080.
|
105
|
141 *
|
86
|
142 * @see Bundle#start()
|
|
143 * @since 1.3
|
|
144 */
|
|
145 public final static int STARTING = 0x00000080;
|
|
146
|
|
147 /**
|
|
148 * The bundle is about to deactivated.
|
|
149 * <p>
|
|
150 * The bundle's
|
|
151 * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method
|
|
152 * is about to be called if the bundle has a bundle activator class. This
|
|
153 * event is only delivered to {@link SynchronousBundleListener}s. It is not
|
|
154 * delivered to <code>BundleListener</code>s.
|
|
155 * <p>
|
|
156 * The value of <code>STOPPING</code> is 0x00000100.
|
105
|
157 *
|
86
|
158 * @see Bundle#stop()
|
|
159 * @since 1.3
|
|
160 */
|
|
161 public final static int STOPPING = 0x00000100;
|
|
162
|
|
163 /**
|
|
164 * The bundle will be lazily activated.
|
|
165 * <p>
|
|
166 * The bundle has a {@link Constants#ACTIVATION_LAZY lazy activation policy}
|
|
167 * and is waiting to be activated. It is now in the
|
|
168 * {@link Bundle#STARTING STARTING} state and has a valid
|
|
169 * <code>BundleContext</code>. This event is only delivered to
|
|
170 * {@link SynchronousBundleListener}s. It is not delivered to
|
|
171 * <code>BundleListener</code>s.
|
|
172 * <p>
|
|
173 * The value of <code>LAZY_ACTIVATION</code> is 0x00000200.
|
105
|
174 *
|
86
|
175 * @since 1.4
|
|
176 */
|
|
177 public final static int LAZY_ACTIVATION = 0x00000200;
|
|
178
|
|
179 /**
|
|
180 * Creates a bundle event of the specified type.
|
105
|
181 *
|
86
|
182 * @param type The event type.
|
|
183 * @param bundle The bundle which had a lifecycle change.
|
|
184 */
|
|
185
|
|
186 public this(int type, Bundle bundle) {
|
105
|
187 super(bundle);
|
86
|
188 this.bundle = bundle;
|
|
189 this.type = type;
|
|
190 }
|
|
191
|
|
192 /**
|
|
193 * Returns the bundle which had a lifecycle change. This bundle is the
|
|
194 * source of the event.
|
105
|
195 *
|
86
|
196 * @return The bundle that had a change occur in its lifecycle.
|
|
197 */
|
|
198 public Bundle getBundle() {
|
|
199 return bundle;
|
|
200 }
|
|
201
|
|
202 /**
|
|
203 * Returns the type of lifecyle event. The type values are:
|
|
204 * <ul>
|
|
205 * <li>{@link #INSTALLED}
|
|
206 * <li>{@link #RESOLVED}
|
|
207 * <li>{@link #LAZY_ACTIVATION}
|
|
208 * <li>{@link #STARTING}
|
|
209 * <li>{@link #STARTED}
|
|
210 * <li>{@link #STOPPING}
|
|
211 * <li>{@link #STOPPED}
|
|
212 * <li>{@link #UPDATED}
|
|
213 * <li>{@link #UNRESOLVED}
|
|
214 * <li>{@link #UNINSTALLED}
|
|
215 * </ul>
|
105
|
216 *
|
86
|
217 * @return The type of lifecycle event.
|
|
218 */
|
|
219
|
|
220 public int getType() {
|
|
221 return type;
|
|
222 }
|
|
223 }
|