KickJava   Java API By Example, From Geeks To Geeks.

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


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 $
3  *
4  * Copyright (c) OSGi Alliance (2000, 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  * An event from the Framework describing a bundle lifecycle change.
25  * <p>
26  * <code>BundleEvent</code> objects are delivered to
27  * <code>SynchronousBundleListener</code>s and <code>BundleListener</code>s
28  * when a change occurs in a bundle's lifecycle. A type code is used to identify
29  * the event type for future extendability.
30  *
31  * <p>
32  * OSGi Alliance reserves the right to extend the set of types.
33  *
34  * @Immutable
35  * @see BundleListener
36  * @see SynchronousBundleListener
37  * @version $Revision: 1.19 $
38  */

39
40 public class BundleEvent extends EventObject JavaDoc {
41     static final long serialVersionUID = 4080640865971756012L;
42     /**
43      * Bundle that had a change occur in its lifecycle.
44      */

45     private final Bundle bundle;
46
47     /**
48      * Type of bundle lifecycle change.
49      */

50     private final int type;
51
52     /**
53      * The bundle has been installed.
54      * <p>
55      * The value of <code>INSTALLED</code> is 0x00000001.
56      *
57      * @see BundleContext#installBundle(String)
58      */

59     public final static int INSTALLED = 0x00000001;
60
61     /**
62      * The bundle has been started.
63      * <p>
64      * The bundle's
65      * {@link BundleActivator#start(BundleContext) BundleActivator start} method
66      * has been executed if the bundle has a bundle activator class.
67      * <p>
68      * The value of <code>STARTED</code> is 0x00000002.
69      *
70      * @see Bundle#start()
71      */

72     public final static int STARTED = 0x00000002;
73
74     /**
75      * The bundle has been stopped.
76      * <p>
77      * The bundle's
78      * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method
79      * has been executed if the bundle has a bundle activator class.
80      * <p>
81      * The value of <code>STOPPED</code> is 0x00000004.
82      *
83      * @see Bundle#stop()
84      */

85     public final static int STOPPED = 0x00000004;
86
87     /**
88      * The bundle has been updated.
89      * <p>
90      * The value of <code>UPDATED</code> is 0x00000008.
91      *
92      * @see Bundle#update()
93      */

94     public final static int UPDATED = 0x00000008;
95
96     /**
97      * The bundle has been uninstalled.
98      * <p>
99      * The value of <code>UNINSTALLED</code> is 0x00000010.
100      *
101      * @see Bundle#uninstall
102      */

103     public final static int UNINSTALLED = 0x00000010;
104
105     /**
106      * The bundle has been resolved.
107      * <p>
108      * The value of <code>RESOLVED</code> is 0x00000020.
109      *
110      * @see Bundle#RESOLVED
111      * @since 1.3
112      */

113     public final static int RESOLVED = 0x00000020;
114
115     /**
116      * The bundle has been unresolved.
117      * <p>
118      * The value of <code>UNRESOLVED</code> is 0x00000040.
119      *
120      * @see Bundle#INSTALLED
121      * @since 1.3
122      */

123     public final static int UNRESOLVED = 0x00000040;
124
125     /**
126      * The bundle is about to be activated.
127      * <p>
128      * The bundle's
129      * {@link BundleActivator#start(BundleContext) BundleActivator start} method
130      * is about to be called if the bundle has a bundle activator class. This
131      * event is only delivered to {@link SynchronousBundleListener}s. It is not
132      * delivered to <code>BundleListener</code>s.
133      * <p>
134      * The value of <code>STARTING</code> is 0x00000080.
135      *
136      * @see Bundle#start()
137      * @since 1.3
138      */

139     public final static int STARTING = 0x00000080;
140
141     /**
142      * The bundle is about to deactivated.
143      * <p>
144      * The bundle's
145      * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method
146      * is about to be called if the bundle has a bundle activator class. This
147      * event is only delivered to {@link SynchronousBundleListener}s. It is not
148      * delivered to <code>BundleListener</code>s.
149      * <p>
150      * The value of <code>STOPPING</code> is 0x00000100.
151      *
152      * @see Bundle#stop()
153      * @since 1.3
154      */

155     public final static int STOPPING = 0x00000100;
156
157     /**
158      * The bundle will be lazily activated.
159      * <p>
160      * The bundle has a {@link Constants#ACTIVATION_LAZY lazy activation policy}
161      * and is waiting to be activated. It is now in the
162      * {@link Bundle#STARTING STARTING} state and has a valid
163      * <code>BundleContext</code>. This event is only delivered to
164      * {@link SynchronousBundleListener}s. It is not delivered to
165      * <code>BundleListener</code>s.
166      * <p>
167      * The value of <code>LAZY_ACTIVATION</code> is 0x00000200.
168      *
169      * @since 1.4
170      */

171     public final static int LAZY_ACTIVATION = 0x00000200;
172
173     /**
174      * Creates a bundle event of the specified type.
175      *
176      * @param type The event type.
177      * @param bundle The bundle which had a lifecycle change.
178      */

179
180     public BundleEvent(int type, Bundle bundle) {
181         super(bundle);
182         this.bundle = bundle;
183         this.type = type;
184     }
185
186     /**
187      * Returns the bundle which had a lifecycle change. This bundle is the
188      * source of the event.
189      *
190      * @return The bundle that had a change occur in its lifecycle.
191      */

192     public Bundle getBundle() {
193         return bundle;
194     }
195
196     /**
197      * Returns the type of lifecyle event. The type values are:
198      * <ul>
199      * <li>{@link #INSTALLED}
200      * <li>{@link #RESOLVED}
201      * <li>{@link #LAZY_ACTIVATION}
202      * <li>{@link #STARTING}
203      * <li>{@link #STARTED}
204      * <li>{@link #STOPPING}
205      * <li>{@link #STOPPED}
206      * <li>{@link #UPDATED}
207      * <li>{@link #UNRESOLVED}
208      * <li>{@link #UNINSTALLED}
209      * </ul>
210      *
211      * @return The type of lifecycle event.
212      */

213
214     public int getType() {
215         return type;
216     }
217 }
218
Popular Tags