comparison org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkEvent.d @ 83:0628aaa2996c

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