86
|
1 /*
|
|
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceEvent.java,v 1.15 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.ServiceEvent;
|
105
|
22
|
|
23 import java.lang.all;
|
86
|
24
|
105
|
25 import org.osgi.framework.ServiceReference; // packageimport
|
|
26
|
86
|
27 import java.util.EventObject;
|
|
28
|
|
29 /**
|
|
30 * An event from the Framework describing a service lifecycle change.
|
|
31 * <p>
|
|
32 * <code>ServiceEvent</code> objects are delivered to
|
|
33 * <code>ServiceListener</code>s and <code>AllServiceListener</code>s when
|
|
34 * a change occurs in this service'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 ServiceListener
|
|
42 * @see AllServiceListener
|
|
43 * @version $Revision: 1.15 $
|
|
44 */
|
|
45
|
|
46 public class ServiceEvent : EventObject {
|
|
47 static final long serialVersionUID = 8792901483909409299L;
|
|
48 /**
|
|
49 * Reference to the service that had a change occur in its lifecycle.
|
|
50 */
|
|
51 private final ServiceReference reference;
|
|
52
|
|
53 /**
|
|
54 * Type of service lifecycle change.
|
|
55 */
|
|
56 private final int type;
|
|
57
|
|
58 /**
|
|
59 * This service has been registered.
|
|
60 * <p>
|
|
61 * This event is synchronously delivered <strong>after</strong> the service
|
|
62 * has been registered with the Framework.
|
105
|
63 *
|
86
|
64 * <p>
|
|
65 * The value of <code>REGISTERED</code> is 0x00000001.
|
105
|
66 *
|
86
|
67 * @see BundleContext#registerService(String[],Object,java.util.Dictionary)
|
|
68 */
|
|
69 public final static int REGISTERED = 0x00000001;
|
|
70
|
|
71 /**
|
|
72 * The properties of a registered service have been modified.
|
|
73 * <p>
|
|
74 * This event is synchronously delivered <strong>after</strong> the service
|
|
75 * properties have been modified.
|
105
|
76 *
|
86
|
77 * <p>
|
|
78 * The value of <code>MODIFIED</code> is 0x00000002.
|
105
|
79 *
|
86
|
80 * @see ServiceRegistration#setProperties
|
|
81 */
|
|
82 public final static int MODIFIED = 0x00000002;
|
|
83
|
|
84 /**
|
|
85 * This service is in the process of being unregistered.
|
|
86 * <p>
|
|
87 * This event is synchronously delivered <strong>before</strong> the
|
|
88 * service has completed unregistering.
|
105
|
89 *
|
86
|
90 * <p>
|
|
91 * If a bundle is using a service that is <code>UNREGISTERING</code>, the
|
|
92 * bundle should release its use of the service when it receives this event.
|
|
93 * If the bundle does not release its use of the service when it receives
|
|
94 * this event, the Framework will automatically release the bundle's use of
|
|
95 * the service while completing the service unregistration operation.
|
105
|
96 *
|
86
|
97 * <p>
|
|
98 * The value of UNREGISTERING is 0x00000004.
|
105
|
99 *
|
86
|
100 * @see ServiceRegistration#unregister
|
|
101 * @see BundleContext#ungetService
|
|
102 */
|
|
103 public final static int UNREGISTERING = 0x00000004;
|
|
104
|
|
105 /**
|
|
106 * Creates a new service event object.
|
105
|
107 *
|
86
|
108 * @param type The event type.
|
|
109 * @param reference A <code>ServiceReference</code> object to the service
|
|
110 * that had a lifecycle change.
|
|
111 */
|
|
112 public this(int type, ServiceReference reference) {
|
105
|
113 super(reference);
|
86
|
114 this.reference = reference;
|
|
115 this.type = type;
|
|
116 }
|
|
117
|
|
118 /**
|
|
119 * Returns a reference to the service that had a change occur in its
|
|
120 * lifecycle.
|
|
121 * <p>
|
|
122 * This reference is the source of the event.
|
105
|
123 *
|
86
|
124 * @return Reference to the service that had a lifecycle change.
|
|
125 */
|
|
126 public ServiceReference getServiceReference() {
|
|
127 return reference;
|
|
128 }
|
|
129
|
|
130 /**
|
|
131 * Returns the type of event. The event type values are:
|
|
132 * <ul>
|
|
133 * <li>{@link #REGISTERED}
|
|
134 * <li>{@link #MODIFIED}
|
|
135 * <li>{@link #UNREGISTERING}
|
|
136 * </ul>
|
105
|
137 *
|
86
|
138 * @return Type of service lifecycle change.
|
|
139 */
|
|
140
|
|
141 public int getType() {
|
|
142 return type;
|
|
143 }
|
|
144 }
|