KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > framework > FrameworkEvent


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 package org.osgi.framework;
20
21 import java.util.EventObject JavaDoc;
22
23 /**
24  * A general event from the Framework.
25  *
26  * <p>
27  * <code>FrameworkEvent</code> objects are delivered to
28  * <code>FrameworkListener</code>s when a general event occurs within the
29  * OSGi environment. A type code is used to identify the event type for future
30  * extendability.
31  *
32  * <p>
33  * OSGi Alliance reserves the right to extend the set of event types.
34  *
35  * @Immutable
36  * @see FrameworkListener
37  * @version $Revision: 1.15 $
38  */

39
40 public class FrameworkEvent extends EventObject JavaDoc {
41     static final long serialVersionUID = 207051004521261705L;
42     /**
43      * Bundle related to the event.
44      */

45     private final Bundle bundle;
46
47     /**
48      * Exception related to the event.
49      */

50     private final Throwable JavaDoc throwable;
51
52     /**
53      * Type of event.
54      */

55     private final int type;
56
57     /**
58      * The Framework has started.
59      *
60      * <p>
61      * This event is fired when the Framework has started after all installed
62      * bundles that are marked to be started have been started and the Framework
63      * has reached the intitial start level.
64      *
65      * <p>
66      * The value of <code>STARTED</code> is 0x00000001.
67      *
68      * @see "<code>StartLevel</code>"
69      */

70     public final static int STARTED = 0x00000001;
71
72     /**
73      * An error has occurred.
74      *
75      * <p>
76      * There was an error associated with a bundle.
77      *
78      * <p>
79      * The value of <code>ERROR</code> is 0x00000002.
80      */

81     public final static int ERROR = 0x00000002;
82
83     /**
84      * A PackageAdmin.refreshPackage operation has completed.
85      *
86      * <p>
87      * This event is fired when the Framework has completed the refresh packages
88      * operation initiated by a call to the PackageAdmin.refreshPackages method.
89      *
90      * <p>
91      * The value of <code>PACKAGES_REFRESHED</code> is 0x00000004.
92      *
93      * @since 1.2
94      * @see "<code>PackageAdmin.refreshPackages</code>"
95      */

96     public final static int PACKAGES_REFRESHED = 0x00000004;
97
98     /**
99      * A StartLevel.setStartLevel operation has completed.
100      *
101      * <p>
102      * This event is fired when the Framework has completed changing the active
103      * start level initiated by a call to the StartLevel.setStartLevel method.
104      *
105      * <p>
106      * The value of <code>STARTLEVEL_CHANGED</code> is 0x00000008.
107      *
108      * @since 1.2
109      * @see "<code>StartLevel</code>"
110      */

111     public final static int STARTLEVEL_CHANGED = 0x00000008;
112
113     /**
114      * A warning has occurred.
115      *
116      * <p>
117      * There was a warning associated with a bundle.
118      *
119      * <p>
120      * The value of <code>WARNING</code> is 0x00000010.
121      *
122      * @since 1.3
123      */

124     public final static int WARNING = 0x00000010;
125
126     /**
127      * An informational event has occurred.
128      *
129      * <p>
130      * There was an informational event associated with a bundle.
131      *
132      * <p>
133      * The value of <code>INFO</code> is 0x00000020.
134      *
135      * @since 1.3
136      */

137     public final static int INFO = 0x00000020;
138
139     /**
140      * Creates a Framework event.
141      *
142      * @param type The event type.
143      * @param source The event source object. This may not be <code>null</code>.
144      * @deprecated As of 1.2. This constructor is deprecated in favor of using
145      * the other constructor with the System Bundle as the event
146      * source.
147      */

148     public FrameworkEvent(int type, Object JavaDoc source) {
149         super(source);
150         this.type = type;
151         this.bundle = null;
152         this.throwable = null;
153     }
154
155     /**
156      * Creates a Framework event regarding the specified bundle.
157      *
158      * @param type The event type.
159      * @param bundle The event source.
160      * @param throwable The related exception. This argument may be
161      * <code>null</code> if there is no related exception.
162      */

163     public FrameworkEvent(int type, Bundle bundle, Throwable JavaDoc throwable) {
164         super(bundle);
165         this.type = type;
166         this.bundle = bundle;
167         this.throwable = throwable;
168     }
169
170     /**
171      * Returns the exception related to this event.
172      *
173      * @return The related exception or <code>null</code> if none.
174      */

175     public Throwable JavaDoc getThrowable() {
176         return throwable;
177     }
178
179     /**
180      * Returns the bundle associated with the event. This bundle is also the
181      * source of the event.
182      *
183      * @return The bundle associated with the event.
184      */

185     public Bundle getBundle() {
186         return bundle;
187     }
188
189     /**
190      * Returns the type of framework event.
191      * <p>
192      * The type values are:
193      * <ul>
194      * <li>{@link #STARTED}
195      * <li>{@link #ERROR}
196      * <li>{@link #WARNING}
197      * <li>{@link #INFO}
198      * <li>{@link #PACKAGES_REFRESHED}
199      * <li>{@link #STARTLEVEL_CHANGED}
200      * </ul>
201      *
202      * @return The type of state change.
203      */

204
205     public int getType() {
206         return type;
207     }
208 }
209
Popular Tags