blob: dcd6e8eacd0f8a3892f14bae8292d31f57a5d47a [file] [log] [blame]
Richard S. Hall930fecc2005-08-16 18:33:34 +00001/*
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleEvent.java,v 1.10 2005/05/13 20:32:54 hargrave Exp $
3 *
4 * Copyright (c) OSGi Alliance (2000, 2005). All Rights Reserved.
5 *
6 * This program and the accompanying materials are made available under the
7 * terms of the Eclipse Public License v1.0 which accompanies this
8 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
9 */
10
11package org.osgi.framework;
12
13import java.util.EventObject;
14
15/**
16 * A Framework event describing a bundle lifecycle change.
17 * <p>
18 * <code>BundleEvent</code> objects are delivered to <code>BundleListener</code>
19 * objects when a change occurs in a bundle's lifecycle. A type code is used to
20 * identify the event type for future extendability.
21 *
22 * <p>
23 * OSGi Alliance reserves the right to extend the set of types.
24 *
25 * @version $Revision: 1.10 $
26 */
27
28public class BundleEvent extends EventObject {
29 static final long serialVersionUID = 4080640865971756012L;
30 /**
31 * Bundle that had a change occur in its lifecycle.
32 */
33 private Bundle bundle;
34
35 /**
36 * Type of bundle lifecycle change.
37 */
38 private int type;
39
40 /**
41 * The bundle has been installed.
42 * <p>
43 * The value of <code>INSTALLED</code> is 0x00000001.
44 *
45 * @see BundleContext#installBundle(String)
46 */
47 public final static int INSTALLED = 0x00000001;
48
49 /**
50 * The bundle has been started.
51 * <p>
52 * The value of <code>STARTED</code> is 0x00000002.
53 *
54 * @see Bundle#start
55 */
56 public final static int STARTED = 0x00000002;
57
58 /**
59 * The bundle has been stopped.
60 * <p>
61 * The value of <code>STOPPED</code> is 0x00000004.
62 *
63 * @see Bundle#stop
64 */
65 public final static int STOPPED = 0x00000004;
66
67 /**
68 * The bundle has been updated.
69 * <p>
70 * The value of <code>UPDATED</code> is 0x00000008.
71 *
72 * @see Bundle#update()
73 */
74 public final static int UPDATED = 0x00000008;
75
76 /**
77 * The bundle has been uninstalled.
78 * <p>
79 * The value of <code>UNINSTALLED</code> is 0x00000010.
80 *
81 * @see Bundle#uninstall
82 */
83 public final static int UNINSTALLED = 0x00000010;
84
85 /**
86 * The bundle has been resolved.
87 * <p>
88 * The value of <code>RESOLVED</code> is 0x00000020.
89 *
90 * @see Bundle#RESOLVED
91 * @since 1.3
92 */
93 public final static int RESOLVED = 0x00000020;
94
95 /**
96 * The bundle has been unresolved.
97 * <p>
98 * The value of <code>UNRESOLVED</code> is 0x00000040.
99 *
100 * @see Bundle#INSTALLED
101 * @since 1.3
102 */
103 public final static int UNRESOLVED = 0x00000040;
104
105 /**
106 * Creates a bundle event of the specified type.
107 *
108 * @param type The event type.
109 * @param bundle The bundle which had a lifecycle change.
110 */
111
112 public BundleEvent(int type, Bundle bundle) {
113 super(bundle);
114 this.bundle = bundle;
115 this.type = type;
116 }
117
118 /**
119 * Returns the bundle which had a lifecycle change. This bundle is the
120 * source of the event.
121 *
122 * @return The bundle that had a change occur in its lifecycle.
123 */
124 public Bundle getBundle() {
125 return bundle;
126 }
127
128 /**
129 * Returns the type of lifecyle event. The type values are:
130 * <ul>
131 * <li>{@link #INSTALLED}
132 * <li>{@link #STARTED}
133 * <li>{@link #STOPPED}
134 * <li>{@link #UPDATED}
135 * <li>{@link #UNINSTALLED}
136 * <li>{@link #RESOLVED}
137 * <li>{@link #UNRESOLVED}
138 * </ul>
139 *
140 * @return The type of lifecycle event.
141 */
142
143 public int getType() {
144 return type;
145 }
146}