Mercurial > projects > dwt2
comparison org.eclipse.osgi/osgi/src/org/osgi/framework/BundleContext.d @ 105:bbe49769ec18
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 08 Nov 2009 12:42:30 +0100 |
parents | 12b890a6392a |
children |
comparison
equal
deleted
inserted
replaced
104:88652073d1c2 | 105:bbe49769ec18 |
---|---|
1 /* | 1 /* |
2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleContext.java,v 1.22 2007/02/21 16:49:05 hargrave Exp $ | 2 * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleContext.java,v 1.22 2007/02/21 16:49:05 hargrave Exp $ |
3 * | 3 * |
4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved. | 4 * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved. |
5 * | 5 * |
6 * Licensed under the Apache License, Version 2.0 (the "License"); | 6 * Licensed under the Apache License, Version 2.0 (the "License"); |
7 * you may not use this file except in compliance with 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 | 8 * You may obtain a copy of the License at |
9 * | 9 * |
10 * http://www.apache.org/licenses/LICENSE-2.0 | 10 * http://www.apache.org/licenses/LICENSE-2.0 |
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 * See the License for the specific language governing permissions and | 15 * See the License for the specific language governing permissions and |
16 * limitations under the License. | 16 * limitations under the License. |
17 */ | 17 */ |
18 | 18 |
19 // Port to the D programming language: | |
20 // Frank Benoit <benoit@tionex.de> | |
19 module org.osgi.framework.BundleContext; | 21 module org.osgi.framework.BundleContext; |
20 import org.osgi.framework.Bundle; | |
21 import org.osgi.framework.BundleListener; | |
22 import org.osgi.framework.ServiceListener; | |
23 import org.osgi.framework.FrameworkListener; | |
24 import org.osgi.framework.ServiceReference; | |
25 import org.osgi.framework.ServiceRegistration; | |
26 import org.osgi.framework.Filter; | |
27 | 22 |
28 import java.lang.all; | 23 import java.lang.all; |
24 | |
25 import org.osgi.framework.BundleListener; // packageimport | |
26 import org.osgi.framework.BundleException; // packageimport | |
27 import org.osgi.framework.ServiceListener; // packageimport | |
28 import org.osgi.framework.InvalidSyntaxException; // packageimport | |
29 import org.osgi.framework.ServiceRegistration; // packageimport | |
30 import org.osgi.framework.ServiceReference; // packageimport | |
31 import org.osgi.framework.Bundle; // packageimport | |
32 import org.osgi.framework.Filter; // packageimport | |
33 import org.osgi.framework.FrameworkListener; // packageimport | |
34 | |
29 import java.io.File; | 35 import java.io.File; |
30 import java.io.InputStream; | 36 import java.io.InputStream; |
31 import java.util.Dictionary; | 37 import java.util.Dictionary; |
32 | 38 |
33 /** | 39 /** |
34 * A bundle's execution context within the Framework. The context is used to | 40 * A bundle's execution context within the Framework. The context is used to |
35 * grant access to other methods so that this bundle can interact with the | 41 * grant access to other methods so that this bundle can interact with the |
36 * Framework. | 42 * Framework. |
37 * | 43 * |
38 * <p> | 44 * <p> |
39 * <code>BundleContext</code> methods allow a bundle to: | 45 * <code>BundleContext</code> methods allow a bundle to: |
40 * <ul> | 46 * <ul> |
41 * <li>Subscribe to events published by the Framework. | 47 * <li>Subscribe to events published by the Framework. |
42 * <li>Register service objects with the Framework service registry. | 48 * <li>Register service objects with the Framework service registry. |
47 * <li>Get the list of bundles installed in the Framework. | 53 * <li>Get the list of bundles installed in the Framework. |
48 * <li>Get the {@link Bundle} object for a bundle. | 54 * <li>Get the {@link Bundle} object for a bundle. |
49 * <li>Create <code>File</code> objects for files in a persistent storage | 55 * <li>Create <code>File</code> objects for files in a persistent storage |
50 * area provided for the bundle by the Framework. | 56 * area provided for the bundle by the Framework. |
51 * </ul> | 57 * </ul> |
52 * | 58 * |
53 * <p> | 59 * <p> |
54 * A <code>BundleContext</code> object will be created and provided to the | 60 * A <code>BundleContext</code> object will be created and provided to the |
55 * bundle associated with this context when it is started using the | 61 * bundle associated with this context when it is started using the |
56 * {@link BundleActivator#start} method. The same <code>BundleContext</code> | 62 * {@link BundleActivator#start} method. The same <code>BundleContext</code> |
57 * object will be passed to the bundle associated with this context when it is | 63 * object will be passed to the bundle associated with this context when it is |
58 * stopped using the {@link BundleActivator#stop} method. A | 64 * stopped using the {@link BundleActivator#stop} method. A |
59 * <code>BundleContext</code> object is generally for the private use of its | 65 * <code>BundleContext</code> object is generally for the private use of its |
60 * associated bundle and is not meant to be shared with other bundles in the | 66 * associated bundle and is not meant to be shared with other bundles in the |
61 * OSGi environment. | 67 * OSGi environment. |
62 * | 68 * |
63 * <p> | 69 * <p> |
64 * The <code>Bundle</code> object associated with a <code>BundleContext</code> | 70 * The <code>Bundle</code> object associated with a <code>BundleContext</code> |
65 * object is called the <em>context bundle</em>. | 71 * object is called the <em>context bundle</em>. |
66 * | 72 * |
67 * <p> | 73 * <p> |
68 * The <code>BundleContext</code> object is only valid during the execution of | 74 * The <code>BundleContext</code> object is only valid during the execution of |
69 * its context bundle; that is, during the period from when the context bundle | 75 * its context bundle; that is, during the period from when the context bundle |
70 * is in the <code>STARTING</code>, <code>STOPPING</code>, and | 76 * is in the <code>STARTING</code>, <code>STOPPING</code>, and |
71 * <code>ACTIVE</code> bundle states. If the <code>BundleContext</code> | 77 * <code>ACTIVE</code> bundle states. If the <code>BundleContext</code> |
72 * object is used subsequently, an <code>IllegalStateException</code> must be | 78 * object is used subsequently, an <code>IllegalStateException</code> must be |
73 * thrown. The <code>BundleContext</code> object must never be reused after | 79 * thrown. The <code>BundleContext</code> object must never be reused after |
74 * its context bundle is stopped. | 80 * its context bundle is stopped. |
75 * | 81 * |
76 * <p> | 82 * <p> |
77 * The Framework is the only entity that can create <code>BundleContext</code> | 83 * The Framework is the only entity that can create <code>BundleContext</code> |
78 * objects and they are only valid within the Framework that created them. | 84 * objects and they are only valid within the Framework that created them. |
79 * | 85 * |
80 * @ThreadSafe | 86 * @ThreadSafe |
81 * @version $Revision: 1.22 $ | 87 * @version $Revision: 1.22 $ |
82 */ | 88 */ |
83 | 89 |
84 public interface BundleContext { | 90 public interface BundleContext { |
85 /** | 91 /** |
86 * Returns the value of the specified property. If the key is not found in | 92 * Returns the value of the specified property. If the key is not found in |
87 * the Framework properties, the system properties are then searched. The | 93 * the Framework properties, the system properties are then searched. The |
88 * method returns <code>null</code> if the property is not found. | 94 * method returns <code>null</code> if the property is not found. |
89 * | 95 * |
90 * <p> | 96 * <p> |
91 * The Framework defines the following standard property keys: | 97 * The Framework defines the following standard property keys: |
92 * </p> | 98 * </p> |
93 * <ul> | 99 * <ul> |
94 * <li>{@link Constants#FRAMEWORK_VERSION} - The OSGi Framework version. | 100 * <li>{@link Constants#FRAMEWORK_VERSION} - The OSGi Framework version. |
104 * <li>{@link Constants#FRAMEWORK_PROCESSOR} - The host computer processor | 110 * <li>{@link Constants#FRAMEWORK_PROCESSOR} - The host computer processor |
105 * name.</li> | 111 * name.</li> |
106 * </ul> | 112 * </ul> |
107 * <p> | 113 * <p> |
108 * All bundles must have permission to read these properties. | 114 * All bundles must have permission to read these properties. |
109 * | 115 * |
110 * <p> | 116 * <p> |
111 * Note: The last four standard properties are used by the | 117 * Note: The last four standard properties are used by the |
112 * {@link Constants#BUNDLE_NATIVECODE} <code>Manifest</code> header's | 118 * {@link Constants#BUNDLE_NATIVECODE} <code>Manifest</code> header's |
113 * matching algorithm for selecting native language code. | 119 * matching algorithm for selecting native language code. |
114 * | 120 * |
115 * @param key The name of the requested property. | 121 * @param key The name of the requested property. |
116 * @return The value of the requested property, or <code>null</code> if | 122 * @return The value of the requested property, or <code>null</code> if |
117 * the property is undefined. | 123 * the property is undefined. |
118 * @throws java.lang.SecurityException If the caller does not have the | 124 * @throws java.lang.SecurityException If the caller does not have the |
119 * appropriate <code>PropertyPermission</code> to read the | 125 * appropriate <code>PropertyPermission</code> to read the |
122 public String getProperty(String key); | 128 public String getProperty(String key); |
123 | 129 |
124 /** | 130 /** |
125 * Returns the <code>Bundle</code> object associated with this | 131 * Returns the <code>Bundle</code> object associated with this |
126 * <code>BundleContext</code>. This bundle is called the context bundle. | 132 * <code>BundleContext</code>. This bundle is called the context bundle. |
127 * | 133 * |
128 * @return The <code>Bundle</code> object associated with this | 134 * @return The <code>Bundle</code> object associated with this |
129 * <code>BundleContext</code>. | 135 * <code>BundleContext</code>. |
130 * @throws java.lang.IllegalStateException If this BundleContext is no | 136 * @throws java.lang.IllegalStateException If this BundleContext is no |
131 * longer valid. | 137 * longer valid. |
132 */ | 138 */ |
137 * obtained from <code>location</code> as interpreted by the Framework in | 143 * obtained from <code>location</code> as interpreted by the Framework in |
138 * an implementation dependent manner. | 144 * an implementation dependent manner. |
139 * <p> | 145 * <p> |
140 * Every installed bundle is uniquely identified by its location string, | 146 * Every installed bundle is uniquely identified by its location string, |
141 * typically in the form of a URL. | 147 * typically in the form of a URL. |
142 * | 148 * |
143 * <p> | 149 * <p> |
144 * The following steps are required to install a bundle: | 150 * The following steps are required to install a bundle: |
145 * <ol> | 151 * <ol> |
146 * <li>If a bundle containing the same location string is already | 152 * <li>If a bundle containing the same location string is already |
147 * installed, the <code>Bundle</code> object for that bundle is returned. | 153 * installed, the <code>Bundle</code> object for that bundle is returned. |
148 * | 154 * |
149 * <li>The bundle's content is read from the location string. If this | 155 * <li>The bundle's content is read from the location string. If this |
150 * fails, a {@link BundleException} is thrown. | 156 * fails, a {@link BundleException} is thrown. |
151 * | 157 * |
152 * <li>The bundle's <code>Bundle-NativeCode</code> dependencies are | 158 * <li>The bundle's <code>Bundle-NativeCode</code> dependencies are |
153 * resolved. If this fails, a <code>BundleException</code> is thrown. | 159 * resolved. If this fails, a <code>BundleException</code> is thrown. |
154 * | 160 * |
155 * <li>The bundle's associated resources are allocated. The associated | 161 * <li>The bundle's associated resources are allocated. The associated |
156 * resources minimally consist of a unique identifier and a persistent | 162 * resources minimally consist of a unique identifier and a persistent |
157 * storage area if the platform has file system support. If this step fails, | 163 * storage area if the platform has file system support. If this step fails, |
158 * a <code>BundleException</code> is thrown. | 164 * a <code>BundleException</code> is thrown. |
159 * | 165 * |
160 * <li>If the bundle has declared an Bundle-RequiredExecutionEnvironment | 166 * <li>If the bundle has declared an Bundle-RequiredExecutionEnvironment |
161 * header, then the listed execution environments must be verified against | 167 * header, then the listed execution environments must be verified against |
162 * the installed execution environments. If none of the listed execution | 168 * the installed execution environments. If none of the listed execution |
163 * environments match an installed execution environment, a | 169 * environments match an installed execution environment, a |
164 * <code>BundleException</code> must be thrown. | 170 * <code>BundleException</code> must be thrown. |
165 * | 171 * |
166 * <li>The bundle's state is set to <code>INSTALLED</code>. | 172 * <li>The bundle's state is set to <code>INSTALLED</code>. |
167 * | 173 * |
168 * <li>A bundle event of type {@link BundleEvent#INSTALLED} is fired. | 174 * <li>A bundle event of type {@link BundleEvent#INSTALLED} is fired. |
169 * | 175 * |
170 * <li>The <code>Bundle</code> object for the newly or previously | 176 * <li>The <code>Bundle</code> object for the newly or previously |
171 * installed bundle is returned. | 177 * installed bundle is returned. |
172 * </ol> | 178 * </ol> |
173 * | 179 * |
174 * <b>Postconditions, no exceptions thrown </b> | 180 * <b>Postconditions, no exceptions thrown </b> |
175 * <ul> | 181 * <ul> |
176 * <li><code>getState()</code> in {<code>INSTALLED</code>,<code>RESOLVED</code>}. | 182 * <li><code>getState()</code> in {<code>INSTALLED</code>,<code>RESOLVED</code>}. |
177 * <li>Bundle has a unique ID. | 183 * <li>Bundle has a unique ID. |
178 * </ul> | 184 * </ul> |
179 * <b>Postconditions, when an exception is thrown </b> | 185 * <b>Postconditions, when an exception is thrown </b> |
180 * <ul> | 186 * <ul> |
181 * <li>Bundle is not installed and no trace of the bundle exists. | 187 * <li>Bundle is not installed and no trace of the bundle exists. |
182 * </ul> | 188 * </ul> |
183 * | 189 * |
184 * @param location The location identifier of the bundle to install. | 190 * @param location The location identifier of the bundle to install. |
185 * @return The <code>Bundle</code> object of the installed bundle. | 191 * @return The <code>Bundle</code> object of the installed bundle. |
186 * @throws BundleException If the installation failed. | 192 * @throws BundleException If the installation failed. |
187 * @throws java.lang.SecurityException If the caller does not have the | 193 * @throws java.lang.SecurityException If the caller does not have the |
188 * appropriate <code>AdminPermission[installed bundle,LIFECYCLE]</code>, and the | 194 * appropriate <code>AdminPermission[installed bundle,LIFECYCLE]</code>, and the |
189 * Java Runtime Environment supports permissions. | 195 * Java Runtime Environment supports permissions. |
190 * @throws java.lang.IllegalStateException If this BundleContext is no | 196 * @throws java.lang.IllegalStateException If this BundleContext is no |
191 * longer valid. | 197 * longer valid. |
192 */ | 198 */ |
193 public Bundle installBundle(String location); | 199 public Bundle installBundle(String location) ; |
194 | 200 |
195 /** | 201 /** |
196 * Installs a bundle from the specified <code>InputStream</code> object. | 202 * Installs a bundle from the specified <code>InputStream</code> object. |
197 * | 203 * |
198 * <p> | 204 * <p> |
199 * This method performs all of the steps listed in | 205 * This method performs all of the steps listed in |
200 * <code>BundleContext.installBundle(String location)</code>, except that | 206 * <code>BundleContext.installBundle(String location)</code>, except that |
201 * the bundle's content will be read from the <code>InputStream</code> | 207 * the bundle's content will be read from the <code>InputStream</code> |
202 * object. The location identifier string specified will be used as the | 208 * object. The location identifier string specified will be used as the |
203 * identity of the bundle. | 209 * identity of the bundle. |
204 * | 210 * |
205 * <p> | 211 * <p> |
206 * This method must always close the <code>InputStream</code> object, even | 212 * This method must always close the <code>InputStream</code> object, even |
207 * if an exception is thrown. | 213 * if an exception is thrown. |
208 * | 214 * |
209 * @param location The location identifier of the bundle to install. | 215 * @param location The location identifier of the bundle to install. |
210 * @param input The <code>InputStream</code> object from which this bundle | 216 * @param input The <code>InputStream</code> object from which this bundle |
211 * will be read. | 217 * will be read. |
212 * @return The <code>Bundle</code> object of the installed bundle. | 218 * @return The <code>Bundle</code> object of the installed bundle. |
213 * @throws BundleException If the provided stream cannot be read or the | 219 * @throws BundleException If the provided stream cannot be read or the |
217 * Java Runtime Environment supports permissions. | 223 * Java Runtime Environment supports permissions. |
218 * @throws java.lang.IllegalStateException If this BundleContext is no | 224 * @throws java.lang.IllegalStateException If this BundleContext is no |
219 * longer valid. | 225 * longer valid. |
220 * @see #installBundle(java.lang.String) | 226 * @see #installBundle(java.lang.String) |
221 */ | 227 */ |
222 public Bundle installBundle(String location, InputStream input); | 228 public Bundle installBundle(String location, InputStream input) ; |
223 | 229 |
224 /** | 230 /** |
225 * Returns the bundle with the specified identifier. | 231 * Returns the bundle with the specified identifier. |
226 * | 232 * |
227 * @param id The identifier of the bundle to retrieve. | 233 * @param id The identifier of the bundle to retrieve. |
228 * @return A <code>Bundle</code> object or <code>null</code> if the | 234 * @return A <code>Bundle</code> object or <code>null</code> if the |
229 * identifier does not match any installed bundle. | 235 * identifier does not match any installed bundle. |
230 */ | 236 */ |
231 public Bundle getBundle(long id); | 237 public Bundle getBundle(long id); |
235 * <p> | 241 * <p> |
236 * This method returns a list of all bundles installed in the OSGi | 242 * This method returns a list of all bundles installed in the OSGi |
237 * environment at the time of the call to this method. However, since the | 243 * environment at the time of the call to this method. However, since the |
238 * Framework is a very dynamic environment, bundles can be installed or | 244 * Framework is a very dynamic environment, bundles can be installed or |
239 * uninstalled at anytime. | 245 * uninstalled at anytime. |
240 * | 246 * |
241 * @return An array of <code>Bundle</code> objects, one object per | 247 * @return An array of <code>Bundle</code> objects, one object per |
242 * installed bundle. | 248 * installed bundle. |
243 */ | 249 */ |
244 public Bundle[] getBundles(); | 250 public Bundle[] getBundles(); |
245 | 251 |
247 * Adds the specified <code>ServiceListener</code> object with the | 253 * Adds the specified <code>ServiceListener</code> object with the |
248 * specified <code>filter</code> to the context bundle's list of | 254 * specified <code>filter</code> to the context bundle's list of |
249 * listeners. See {@link Filter} for a description of the filter syntax. | 255 * listeners. See {@link Filter} for a description of the filter syntax. |
250 * <code>ServiceListener</code> objects are notified when a service has a | 256 * <code>ServiceListener</code> objects are notified when a service has a |
251 * lifecycle state change. | 257 * lifecycle state change. |
252 * | 258 * |
253 * <p> | 259 * <p> |
254 * If the context bundle's list of listeners already contains a listener | 260 * If the context bundle's list of listeners already contains a listener |
255 * <code>l</code> such that <code>(l==listener)</code>, then this | 261 * <code>l</code> such that <code>(l==listener)</code>, then this |
256 * method replaces that listener's filter (which may be <code>null</code>) | 262 * method replaces that listener's filter (which may be <code>null</code>) |
257 * with the specified one (which may be <code>null</code>). | 263 * with the specified one (which may be <code>null</code>). |
258 * | 264 * |
259 * <p> | 265 * <p> |
260 * The listener is called if the filter criteria is met. To filter based | 266 * The listener is called if the filter criteria is met. To filter based |
261 * upon the class of the service, the filter should reference the | 267 * upon the class of the service, the filter should reference the |
262 * {@link Constants#OBJECTCLASS} property. If <code>filter</code> is | 268 * {@link Constants#OBJECTCLASS} property. If <code>filter</code> is |
263 * <code>null</code>, all services are considered to match the filter. | 269 * <code>null</code>, all services are considered to match the filter. |
264 * | 270 * |
265 * <p> | 271 * <p> |
266 * When using a <code>filter</code>, it is possible that the | 272 * When using a <code>filter</code>, it is possible that the |
267 * <code>ServiceEvent</code>s for the complete lifecycle of a service | 273 * <code>ServiceEvent</code>s for the complete lifecycle of a service |
268 * will not be delivered to the listener. For example, if the | 274 * will not be delivered to the listener. For example, if the |
269 * <code>filter</code> only matches when the property <code>x</code> has | 275 * <code>filter</code> only matches when the property <code>x</code> has |
273 * setting property <code>x</code> to the value <code>1</code>, the | 279 * setting property <code>x</code> to the value <code>1</code>, the |
274 * filter will match and the listener will be called with a | 280 * filter will match and the listener will be called with a |
275 * <code>ServiceEvent</code> of type <code>MODIFIED</code>. Thus, the | 281 * <code>ServiceEvent</code> of type <code>MODIFIED</code>. Thus, the |
276 * listener will not be called with a <code>ServiceEvent</code> of type | 282 * listener will not be called with a <code>ServiceEvent</code> of type |
277 * <code>REGISTERED</code>. | 283 * <code>REGISTERED</code>. |
278 * | 284 * |
279 * <p> | 285 * <p> |
280 * If the Java Runtime Environment supports permissions, the | 286 * If the Java Runtime Environment supports permissions, the |
281 * <code>ServiceListener</code> object will be notified of a service event | 287 * <code>ServiceListener</code> object will be notified of a service event |
282 * only if the bundle that is registering it has the | 288 * only if the bundle that is registering it has the |
283 * <code>ServicePermission</code> to get the service using at least one of | 289 * <code>ServicePermission</code> to get the service using at least one of |
284 * the named classes the service was registered under. | 290 * the named classes the service was registered under. |
285 * | 291 * |
286 * @param listener The <code>ServiceListener</code> object to be added. | 292 * @param listener The <code>ServiceListener</code> object to be added. |
287 * @param filter The filter criteria. | 293 * @param filter The filter criteria. |
288 * | 294 * |
289 * @throws InvalidSyntaxException If <code>filter</code> contains an | 295 * @throws InvalidSyntaxException If <code>filter</code> contains an |
290 * invalid filter string that cannot be parsed. | 296 * invalid filter string that cannot be parsed. |
291 * @throws java.lang.IllegalStateException If this BundleContext is no | 297 * @throws java.lang.IllegalStateException If this BundleContext is no |
292 * longer valid. | 298 * longer valid. |
293 * | 299 * |
294 * @see ServiceEvent | 300 * @see ServiceEvent |
295 * @see ServiceListener | 301 * @see ServiceListener |
296 * @see ServicePermission | 302 * @see ServicePermission |
297 */ | 303 */ |
298 public void addServiceListener(ServiceListener listener, | 304 public void addServiceListener(ServiceListener listener, |
299 String filter); | 305 String filter) ; |
300 | 306 |
301 /** | 307 /** |
302 * Adds the specified <code>ServiceListener</code> object to the context | 308 * Adds the specified <code>ServiceListener</code> object to the context |
303 * bundle's list of listeners. | 309 * bundle's list of listeners. |
304 * | 310 * |
305 * <p> | 311 * <p> |
306 * This method is the same as calling | 312 * This method is the same as calling |
307 * <code>BundleContext.addServiceListener(ServiceListener listener, | 313 * <code>BundleContext.addServiceListener(ServiceListener listener, |
308 * String filter)</code> | 314 * String filter)</code> |
309 * with <code>filter</code> set to <code>null</code>. | 315 * with <code>filter</code> set to <code>null</code>. |
310 * | 316 * |
311 * @param listener The <code>ServiceListener</code> object to be added. | 317 * @param listener The <code>ServiceListener</code> object to be added. |
312 * @throws java.lang.IllegalStateException If this BundleContext is no | 318 * @throws java.lang.IllegalStateException If this BundleContext is no |
313 * longer valid. | 319 * longer valid. |
314 * | 320 * |
315 * @see #addServiceListener(ServiceListener, String) | 321 * @see #addServiceListener(ServiceListener, String) |
316 */ | 322 */ |
317 public void addServiceListener(ServiceListener listener); | 323 public void addServiceListener(ServiceListener listener); |
318 | 324 |
319 /** | 325 /** |
320 * Removes the specified <code>ServiceListener</code> object from the | 326 * Removes the specified <code>ServiceListener</code> object from the |
321 * context bundle's list of listeners. | 327 * context bundle's list of listeners. |
322 * | 328 * |
323 * <p> | 329 * <p> |
324 * If <code>listener</code> is not contained in this context bundle's list | 330 * If <code>listener</code> is not contained in this context bundle's list |
325 * of listeners, this method does nothing. | 331 * of listeners, this method does nothing. |
326 * | 332 * |
327 * @param listener The <code>ServiceListener</code> to be removed. | 333 * @param listener The <code>ServiceListener</code> to be removed. |
328 * @throws java.lang.IllegalStateException If this BundleContext is no | 334 * @throws java.lang.IllegalStateException If this BundleContext is no |
329 * longer valid. | 335 * longer valid. |
330 */ | 336 */ |
331 public void removeServiceListener(ServiceListener listener); | 337 public void removeServiceListener(ServiceListener listener); |
332 | 338 |
333 /** | 339 /** |
334 * Adds the specified <code>BundleListener</code> object to the context | 340 * Adds the specified <code>BundleListener</code> object to the context |
335 * bundle's list of listeners if not already present. BundleListener objects | 341 * bundle's list of listeners if not already present. BundleListener objects |
336 * are notified when a bundle has a lifecycle state change. | 342 * are notified when a bundle has a lifecycle state change. |
337 * | 343 * |
338 * <p> | 344 * <p> |
339 * If the context bundle's list of listeners already contains a listener | 345 * If the context bundle's list of listeners already contains a listener |
340 * <code>l</code> such that <code>(l==listener)</code>, this method | 346 * <code>l</code> such that <code>(l==listener)</code>, this method |
341 * does nothing. | 347 * does nothing. |
342 * | 348 * |
343 * @param listener The <code>BundleListener</code> to be added. | 349 * @param listener The <code>BundleListener</code> to be added. |
344 * @throws java.lang.IllegalStateException If this BundleContext is no | 350 * @throws java.lang.IllegalStateException If this BundleContext is no |
345 * longer valid. | 351 * longer valid. |
346 * @throws java.lang.SecurityException If listener is a | 352 * @throws java.lang.SecurityException If listener is a |
347 * <code>SynchronousBundleListener</code> and the caller does not | 353 * <code>SynchronousBundleListener</code> and the caller does not |
348 * have the appropriate <code>AdminPermission[context bundle,LISTENER]</code>, | 354 * have the appropriate <code>AdminPermission[context bundle,LISTENER]</code>, |
349 * and the Java Runtime Environment supports permissions. | 355 * and the Java Runtime Environment supports permissions. |
350 * | 356 * |
351 * @see BundleEvent | 357 * @see BundleEvent |
352 * @see BundleListener | 358 * @see BundleListener |
353 */ | 359 */ |
354 public void addBundleListener(BundleListener listener); | 360 public void addBundleListener(BundleListener listener); |
355 | 361 |
356 /** | 362 /** |
357 * Removes the specified <code>BundleListener</code> object from the | 363 * Removes the specified <code>BundleListener</code> object from the |
358 * context bundle's list of listeners. | 364 * context bundle's list of listeners. |
359 * | 365 * |
360 * <p> | 366 * <p> |
361 * If <code>listener</code> is not contained in the context bundle's list | 367 * If <code>listener</code> is not contained in the context bundle's list |
362 * of listeners, this method does nothing. | 368 * of listeners, this method does nothing. |
363 * | 369 * |
364 * @param listener The <code>BundleListener</code> object to be removed. | 370 * @param listener The <code>BundleListener</code> object to be removed. |
365 * @throws java.lang.IllegalStateException If this BundleContext is no | 371 * @throws java.lang.IllegalStateException If this BundleContext is no |
366 * longer valid. | 372 * longer valid. |
367 * @throws java.lang.SecurityException If listener is a | 373 * @throws java.lang.SecurityException If listener is a |
368 * <code>SynchronousBundleListener</code> and the caller does not | 374 * <code>SynchronousBundleListener</code> and the caller does not |
373 | 379 |
374 /** | 380 /** |
375 * Adds the specified <code>FrameworkListener</code> object to the context | 381 * Adds the specified <code>FrameworkListener</code> object to the context |
376 * bundle's list of listeners if not already present. FrameworkListeners are | 382 * bundle's list of listeners if not already present. FrameworkListeners are |
377 * notified of general Framework events. | 383 * notified of general Framework events. |
378 * | 384 * |
379 * <p> | 385 * <p> |
380 * If the context bundle's list of listeners already contains a listener | 386 * If the context bundle's list of listeners already contains a listener |
381 * <code>l</code> such that <code>(l==listener)</code>, this method | 387 * <code>l</code> such that <code>(l==listener)</code>, this method |
382 * does nothing. | 388 * does nothing. |
383 * | 389 * |
384 * @param listener The <code>FrameworkListener</code> object to be added. | 390 * @param listener The <code>FrameworkListener</code> object to be added. |
385 * @throws java.lang.IllegalStateException If this BundleContext is no | 391 * @throws java.lang.IllegalStateException If this BundleContext is no |
386 * longer valid. | 392 * longer valid. |
387 * | 393 * |
388 * @see FrameworkEvent | 394 * @see FrameworkEvent |
389 * @see FrameworkListener | 395 * @see FrameworkListener |
390 */ | 396 */ |
391 public void addFrameworkListener(FrameworkListener listener); | 397 public void addFrameworkListener(FrameworkListener listener); |
392 | 398 |
393 /** | 399 /** |
394 * Removes the specified <code>FrameworkListener</code> object from the | 400 * Removes the specified <code>FrameworkListener</code> object from the |
395 * context bundle's list of listeners. | 401 * context bundle's list of listeners. |
396 * | 402 * |
397 * <p> | 403 * <p> |
398 * If <code>listener</code> is not contained in the context bundle's list | 404 * If <code>listener</code> is not contained in the context bundle's list |
399 * of listeners, this method does nothing. | 405 * of listeners, this method does nothing. |
400 * | 406 * |
401 * @param listener The <code>FrameworkListener</code> object to be | 407 * @param listener The <code>FrameworkListener</code> object to be |
402 * removed. | 408 * removed. |
403 * @throws java.lang.IllegalStateException If this BundleContext is no | 409 * @throws java.lang.IllegalStateException If this BundleContext is no |
404 * longer valid. | 410 * longer valid. |
405 */ | 411 */ |
412 * <code>ServiceRegistration</code> object is for the private use of the | 418 * <code>ServiceRegistration</code> object is for the private use of the |
413 * bundle registering the service and should not be shared with other | 419 * bundle registering the service and should not be shared with other |
414 * bundles. The registering bundle is defined to be the context bundle. | 420 * bundles. The registering bundle is defined to be the context bundle. |
415 * Other bundles can locate the service by using either the | 421 * Other bundles can locate the service by using either the |
416 * {@link #getServiceReferences} or {@link #getServiceReference} method. | 422 * {@link #getServiceReferences} or {@link #getServiceReference} method. |
417 * | 423 * |
418 * <p> | 424 * <p> |
419 * A bundle can register a service object that implements the | 425 * A bundle can register a service object that implements the |
420 * {@link ServiceFactory} interface to have more flexibility in providing | 426 * {@link ServiceFactory} interface to have more flexibility in providing |
421 * service objects to other bundles. | 427 * service objects to other bundles. |
422 * | 428 * |
423 * <p> | 429 * <p> |
424 * The following steps are required to register a service: | 430 * The following steps are required to register a service: |
425 * <ol> | 431 * <ol> |
426 * <li>If <code>service</code> is not a <code>ServiceFactory</code>, | 432 * <li>If <code>service</code> is not a <code>ServiceFactory</code>, |
427 * an <code>IllegalArgumentException</code> is thrown if | 433 * an <code>IllegalArgumentException</code> is thrown if |
439 * <li>A service event of type {@link ServiceEvent#REGISTERED} is | 445 * <li>A service event of type {@link ServiceEvent#REGISTERED} is |
440 * fired. | 446 * fired. |
441 * <li>A <code>ServiceRegistration</code> object for this registration is | 447 * <li>A <code>ServiceRegistration</code> object for this registration is |
442 * returned. | 448 * returned. |
443 * </ol> | 449 * </ol> |
444 * | 450 * |
445 * @param clazzes The class names under which the service can be located. | 451 * @param clazzes The class names under which the service can be located. |
446 * The class names in this array will be stored in the service's | 452 * The class names in this array will be stored in the service's |
447 * properties under the key {@link Constants#OBJECTCLASS}. | 453 * properties under the key {@link Constants#OBJECTCLASS}. |
448 * @param service The service object or a <code>ServiceFactory</code> | 454 * @param service The service object or a <code>ServiceFactory</code> |
449 * object. | 455 * object. |
453 * Changes should not be made to this object after calling this | 459 * Changes should not be made to this object after calling this |
454 * method. To update the service's properties the | 460 * method. To update the service's properties the |
455 * {@link ServiceRegistration#setProperties} method must be called. | 461 * {@link ServiceRegistration#setProperties} method must be called. |
456 * The set of properties may be <code>null</code> if the service | 462 * The set of properties may be <code>null</code> if the service |
457 * has no properties. | 463 * has no properties. |
458 * | 464 * |
459 * @return A <code>ServiceRegistration</code> object for use by the bundle | 465 * @return A <code>ServiceRegistration</code> object for use by the bundle |
460 * registering the service to update the service's properties or to | 466 * registering the service to update the service's properties or to |
461 * unregister the service. | 467 * unregister the service. |
462 * | 468 * |
463 * @throws java.lang.IllegalArgumentException If one of the following is | 469 * @throws java.lang.IllegalArgumentException If one of the following is |
464 * true: | 470 * true: |
465 * <ul> | 471 * <ul> |
466 * <li><code>service</code> is <code>null</code>. | 472 * <li><code>service</code> is <code>null</code>. |
467 * <li><code>service</code> is not a <code>ServiceFactory</code> | 473 * <li><code>service</code> is not a <code>ServiceFactory</code> |
468 * object and is not an instance of all the named classes in | 474 * object and is not an instance of all the named classes in |
469 * <code>clazzes</code>. | 475 * <code>clazzes</code>. |
470 * <li><code>properties</code> contains case variants of the same | 476 * <li><code>properties</code> contains case variants of the same |
471 * key name. | 477 * key name. |
472 * </ul> | 478 * </ul> |
473 * | 479 * |
474 * @throws java.lang.SecurityException If the caller does not have the | 480 * @throws java.lang.SecurityException If the caller does not have the |
475 * <code>ServicePermission</code> to register the service for all | 481 * <code>ServicePermission</code> to register the service for all |
476 * the named classes and the Java Runtime Environment supports | 482 * the named classes and the Java Runtime Environment supports |
477 * permissions. | 483 * permissions. |
478 * | 484 * |
479 * @throws java.lang.IllegalStateException If this BundleContext is no | 485 * @throws java.lang.IllegalStateException If this BundleContext is no |
480 * longer valid. | 486 * longer valid. |
481 * | 487 * |
482 * @see ServiceRegistration | 488 * @see ServiceRegistration |
483 * @see ServiceFactory | 489 * @see ServiceFactory |
484 */ | 490 */ |
485 public ServiceRegistration registerService(String[] clazzes, | 491 public ServiceRegistration registerService(String[] clazzes, |
486 Object service, Dictionary properties); | 492 Object service, Dictionary properties); |
487 | 493 |
488 /** | 494 /** |
489 * Registers the specified service object with the specified properties | 495 * Registers the specified service object with the specified properties |
490 * under the specified class name with the Framework. | 496 * under the specified class name with the Framework. |
491 * | 497 * |
492 * <p> | 498 * <p> |
493 * This method is otherwise identical to | 499 * This method is otherwise identical to |
494 * {@link #registerService(java.lang.String[], java.lang.Object, | 500 * {@link #registerService(java.lang.String[], java.lang.Object, |
495 * java.util.Dictionary)} and is provided as a convenience when | 501 * java.util.Dictionary)} and is provided as a convenience when |
496 * <code>service</code> will only be registered under a single class name. | 502 * <code>service</code> will only be registered under a single class name. |
497 * Note that even in this case the value of the service's | 503 * Note that even in this case the value of the service's |
498 * {@link Constants#OBJECTCLASS} property will be an array of strings, | 504 * {@link Constants#OBJECTCLASS} property will be an array of strings, |
499 * rather than just a single string. | 505 * rather than just a single string. |
500 * | 506 * |
501 * @param clazz The class name under which the service can be located. | 507 * @param clazz The class name under which the service can be located. |
502 * @param service The service object or a <code>ServiceFactory</code> | 508 * @param service The service object or a <code>ServiceFactory</code> |
503 * object. | 509 * object. |
504 * @param properties The properties for this service. | 510 * @param properties The properties for this service. |
505 * | 511 * |
506 * @return A <code>ServiceRegistration</code> object for use by the bundle | 512 * @return A <code>ServiceRegistration</code> object for use by the bundle |
507 * registering the service to update the service's properties or to | 513 * registering the service to update the service's properties or to |
508 * unregister the service. | 514 * unregister the service. |
509 * | 515 * |
510 * @throws java.lang.IllegalStateException If this BundleContext is no | 516 * @throws java.lang.IllegalStateException If this BundleContext is no |
511 * longer valid. | 517 * longer valid. |
512 * @see #registerService(java.lang.String[], java.lang.Object, | 518 * @see #registerService(java.lang.String[], java.lang.Object, |
513 * java.util.Dictionary) | 519 * java.util.Dictionary) |
514 */ | 520 */ |
520 * array of <code>ServiceReference</code> objects contains services that | 526 * array of <code>ServiceReference</code> objects contains services that |
521 * were registered under the specified class, match the specified filter | 527 * were registered under the specified class, match the specified filter |
522 * criteria, and the packages for the class names under which the services | 528 * criteria, and the packages for the class names under which the services |
523 * were registered match the context bundle's packages as defined in | 529 * were registered match the context bundle's packages as defined in |
524 * {@link ServiceReference#isAssignableTo(Bundle, String)}. | 530 * {@link ServiceReference#isAssignableTo(Bundle, String)}. |
525 * | 531 * |
526 * <p> | 532 * <p> |
527 * The list is valid at the time of the call to this method, however since | 533 * The list is valid at the time of the call to this method, however since |
528 * the Framework is a very dynamic environment, services can be modified or | 534 * the Framework is a very dynamic environment, services can be modified or |
529 * unregistered at anytime. | 535 * unregistered at anytime. |
530 * | 536 * |
531 * <p> | 537 * <p> |
532 * <code>filter</code> is used to select the registered service whose | 538 * <code>filter</code> is used to select the registered service whose |
533 * properties objects contain keys and values which satisfy the filter. See | 539 * properties objects contain keys and values which satisfy the filter. See |
534 * {@link Filter} for a description of the filter string syntax. | 540 * {@link Filter} for a description of the filter string syntax. |
535 * | 541 * |
536 * <p> | 542 * <p> |
537 * If <code>filter</code> is <code>null</code>, all registered services | 543 * If <code>filter</code> is <code>null</code>, all registered services |
538 * are considered to match the filter. If <code>filter</code> cannot be | 544 * are considered to match the filter. If <code>filter</code> cannot be |
539 * parsed, an {@link InvalidSyntaxException} will be thrown with a human | 545 * parsed, an {@link InvalidSyntaxException} will be thrown with a human |
540 * readable message where the filter became unparsable. | 546 * readable message where the filter became unparsable. |
541 * | 547 * |
542 * <p> | 548 * <p> |
543 * The following steps are required to select a set of | 549 * The following steps are required to select a set of |
544 * <code>ServiceReference</code> objects: | 550 * <code>ServiceReference</code> objects: |
545 * <ol> | 551 * <ol> |
546 * <li>If the filter string is not <code>null</code>, the filter string | 552 * <li>If the filter string is not <code>null</code>, the filter string |
571 * <code>false</code>, then it is removed from the set of | 577 * <code>false</code>, then it is removed from the set of |
572 * <code>ServiceReference</code> objects. | 578 * <code>ServiceReference</code> objects. |
573 * <li>An array of the remaining <code>ServiceReference</code> objects is | 579 * <li>An array of the remaining <code>ServiceReference</code> objects is |
574 * returned. | 580 * returned. |
575 * </ol> | 581 * </ol> |
576 * | 582 * |
577 * @param clazz The class name with which the service was registered or | 583 * @param clazz The class name with which the service was registered or |
578 * <code>null</code> for all services. | 584 * <code>null</code> for all services. |
579 * @param filter The filter criteria. | 585 * @param filter The filter criteria. |
580 * @return An array of <code>ServiceReference</code> objects or | 586 * @return An array of <code>ServiceReference</code> objects or |
581 * <code>null</code> if no services are registered which satisfy | 587 * <code>null</code> if no services are registered which satisfy |
584 * invalid filter string that cannot be parsed. | 590 * invalid filter string that cannot be parsed. |
585 * @throws java.lang.IllegalStateException If this BundleContext is no | 591 * @throws java.lang.IllegalStateException If this BundleContext is no |
586 * longer valid. | 592 * longer valid. |
587 */ | 593 */ |
588 public ServiceReference[] getServiceReferences(String clazz, | 594 public ServiceReference[] getServiceReferences(String clazz, |
589 String filter); | 595 String filter) ; |
590 | 596 |
591 /** | 597 /** |
592 * Returns an array of <code>ServiceReference</code> objects. The returned | 598 * Returns an array of <code>ServiceReference</code> objects. The returned |
593 * array of <code>ServiceReference</code> objects contains services that | 599 * array of <code>ServiceReference</code> objects contains services that |
594 * were registered under the specified class and match the specified filter | 600 * were registered under the specified class and match the specified filter |
595 * criteria. | 601 * criteria. |
596 * | 602 * |
597 * <p> | 603 * <p> |
598 * The list is valid at the time of the call to this method, however since | 604 * The list is valid at the time of the call to this method, however since |
599 * the Framework is a very dynamic environment, services can be modified or | 605 * the Framework is a very dynamic environment, services can be modified or |
600 * unregistered at anytime. | 606 * unregistered at anytime. |
601 * | 607 * |
602 * <p> | 608 * <p> |
603 * <code>filter</code> is used to select the registered service whose | 609 * <code>filter</code> is used to select the registered service whose |
604 * properties objects contain keys and values which satisfy the filter. See | 610 * properties objects contain keys and values which satisfy the filter. See |
605 * {@link Filter} for a description of the filter string syntax. | 611 * {@link Filter} for a description of the filter string syntax. |
606 * | 612 * |
607 * <p> | 613 * <p> |
608 * If <code>filter</code> is <code>null</code>, all registered services | 614 * If <code>filter</code> is <code>null</code>, all registered services |
609 * are considered to match the filter. If <code>filter</code> cannot be | 615 * are considered to match the filter. If <code>filter</code> cannot be |
610 * parsed, an {@link InvalidSyntaxException} will be thrown with a human | 616 * parsed, an {@link InvalidSyntaxException} will be thrown with a human |
611 * readable message where the filter became unparsable. | 617 * readable message where the filter became unparsable. |
612 * | 618 * |
613 * <p> | 619 * <p> |
614 * The following steps are required to select a set of | 620 * The following steps are required to select a set of |
615 * <code>ServiceReference</code> objects: | 621 * <code>ServiceReference</code> objects: |
616 * <ol> | 622 * <ol> |
617 * <li>If the filter string is not <code>null</code>, the filter string | 623 * <li>If the filter string is not <code>null</code>, the filter string |
633 * the service was registered is available from the service's | 639 * the service was registered is available from the service's |
634 * {@link Constants#OBJECTCLASS} property. | 640 * {@link Constants#OBJECTCLASS} property. |
635 * <li>An array of the remaining <code>ServiceReference</code> objects is | 641 * <li>An array of the remaining <code>ServiceReference</code> objects is |
636 * returned. | 642 * returned. |
637 * </ol> | 643 * </ol> |
638 * | 644 * |
639 * @param clazz The class name with which the service was registered or | 645 * @param clazz The class name with which the service was registered or |
640 * <code>null</code> for all services. | 646 * <code>null</code> for all services. |
641 * @param filter The filter criteria. | 647 * @param filter The filter criteria. |
642 * @return An array of <code>ServiceReference</code> objects or | 648 * @return An array of <code>ServiceReference</code> objects or |
643 * <code>null</code> if no services are registered which satisfy | 649 * <code>null</code> if no services are registered which satisfy |
647 * @throws java.lang.IllegalStateException If this BundleContext is no | 653 * @throws java.lang.IllegalStateException If this BundleContext is no |
648 * longer valid. | 654 * longer valid. |
649 * @since 1.3 | 655 * @since 1.3 |
650 */ | 656 */ |
651 public ServiceReference[] getAllServiceReferences(String clazz, | 657 public ServiceReference[] getAllServiceReferences(String clazz, |
652 String filter); | 658 String filter) ; |
653 | 659 |
654 /** | 660 /** |
655 * Returns a <code>ServiceReference</code> object for a service that | 661 * Returns a <code>ServiceReference</code> object for a service that |
656 * implements and was registered under the specified class. | 662 * implements and was registered under the specified class. |
657 * | 663 * |
658 * <p> | 664 * <p> |
659 * This <code>ServiceReference</code> object is valid at the time of the | 665 * This <code>ServiceReference</code> object is valid at the time of the |
660 * call to this method, however as the Framework is a very dynamic | 666 * call to this method, however as the Framework is a very dynamic |
661 * environment, services can be modified or unregistered at anytime. | 667 * environment, services can be modified or unregistered at anytime. |
662 * | 668 * |
663 * <p> | 669 * <p> |
664 * This method is the same as calling | 670 * This method is the same as calling |
665 * {@link BundleContext#getServiceReferences(String, String)} with a | 671 * {@link BundleContext#getServiceReferences(String, String)} with a |
666 * <code>null</code> filter string. It is provided as a convenience for | 672 * <code>null</code> filter string. It is provided as a convenience for |
667 * when the caller is interested in any service that implements the | 673 * when the caller is interested in any service that implements the |
671 * specified in its {@link Constants#SERVICE_RANKING} property) is returned. | 677 * specified in its {@link Constants#SERVICE_RANKING} property) is returned. |
672 * <p> | 678 * <p> |
673 * If there is a tie in ranking, the service with the lowest service ID (as | 679 * If there is a tie in ranking, the service with the lowest service ID (as |
674 * specified in its {@link Constants#SERVICE_ID} property); that is, the | 680 * specified in its {@link Constants#SERVICE_ID} property); that is, the |
675 * service that was registered first is returned. | 681 * service that was registered first is returned. |
676 * | 682 * |
677 * @param clazz The class name with which the service was registered. | 683 * @param clazz The class name with which the service was registered. |
678 * @return A <code>ServiceReference</code> object, or <code>null</code> | 684 * @return A <code>ServiceReference</code> object, or <code>null</code> |
679 * if no services are registered which implement the named class. | 685 * if no services are registered which implement the named class. |
680 * @throws java.lang.IllegalStateException If this BundleContext is no | 686 * @throws java.lang.IllegalStateException If this BundleContext is no |
681 * longer valid. | 687 * longer valid. |
693 * {@link #ungetService(ServiceReference)} the context bundle's use count | 699 * {@link #ungetService(ServiceReference)} the context bundle's use count |
694 * for that service is decremented by one. | 700 * for that service is decremented by one. |
695 * <p> | 701 * <p> |
696 * When a bundle's use count for a service drops to zero, the bundle should | 702 * When a bundle's use count for a service drops to zero, the bundle should |
697 * no longer use that service. | 703 * no longer use that service. |
698 * | 704 * |
699 * <p> | 705 * <p> |
700 * This method will always return <code>null</code> when the service | 706 * This method will always return <code>null</code> when the service |
701 * associated with this <code>reference</code> has been unregistered. | 707 * associated with this <code>reference</code> has been unregistered. |
702 * | 708 * |
703 * <p> | 709 * <p> |
704 * The following steps are required to get the service object: | 710 * The following steps are required to get the service object: |
705 * <ol> | 711 * <ol> |
706 * <li>If the service has been unregistered, <code>null</code> is | 712 * <li>If the service has been unregistered, <code>null</code> is |
707 * returned. | 713 * returned. |
721 * service was registered or the <code>ServiceFactory</code> object throws | 727 * service was registered or the <code>ServiceFactory</code> object throws |
722 * an exception, <code>null</code> is returned and a Framework event of | 728 * an exception, <code>null</code> is returned and a Framework event of |
723 * type {@link FrameworkEvent#ERROR} is fired. | 729 * type {@link FrameworkEvent#ERROR} is fired. |
724 * <li>The service object for the service is returned. | 730 * <li>The service object for the service is returned. |
725 * </ol> | 731 * </ol> |
726 * | 732 * |
727 * @param reference A reference to the service. | 733 * @param reference A reference to the service. |
728 * @return A service object for the service associated with | 734 * @return A service object for the service associated with |
729 * <code>reference</code> or <code>null</code> if the service is | 735 * <code>reference</code> or <code>null</code> if the service is |
730 * not registered or does not implement the classes under which it | 736 * not registered or does not implement the classes under which it |
731 * was registered in the case of a <code>ServiceFactory</code>. | 737 * was registered in the case of a <code>ServiceFactory</code>. |
744 * Releases the service object referenced by the specified | 750 * Releases the service object referenced by the specified |
745 * <code>ServiceReference</code> object. If the context bundle's use count | 751 * <code>ServiceReference</code> object. If the context bundle's use count |
746 * for the service is zero, this method returns <code>false</code>. | 752 * for the service is zero, this method returns <code>false</code>. |
747 * Otherwise, the context bundle's use count for the service is decremented | 753 * Otherwise, the context bundle's use count for the service is decremented |
748 * by one. | 754 * by one. |
749 * | 755 * |
750 * <p> | 756 * <p> |
751 * The service's service object should no longer be used and all references | 757 * The service's service object should no longer be used and all references |
752 * to it should be destroyed when a bundle's use count for the service drops | 758 * to it should be destroyed when a bundle's use count for the service drops |
753 * to zero. | 759 * to zero. |
754 * | 760 * |
755 * <p> | 761 * <p> |
756 * The following steps are required to unget the service object: | 762 * The following steps are required to unget the service object: |
757 * <ol> | 763 * <ol> |
758 * <li>If the context bundle's use count for the service is zero or the | 764 * <li>If the context bundle's use count for the service is zero or the |
759 * service has been unregistered, <code>false</code> is returned. | 765 * service has been unregistered, <code>false</code> is returned. |
764 * object, the | 770 * object, the |
765 * {@link ServiceFactory#ungetService(Bundle, ServiceRegistration, Object)} | 771 * {@link ServiceFactory#ungetService(Bundle, ServiceRegistration, Object)} |
766 * method is called to release the service object for the context bundle. | 772 * method is called to release the service object for the context bundle. |
767 * <li><code>true</code> is returned. | 773 * <li><code>true</code> is returned. |
768 * </ol> | 774 * </ol> |
769 * | 775 * |
770 * @param reference A reference to the service to be released. | 776 * @param reference A reference to the service to be released. |
771 * @return <code>false</code> if the context bundle's use count for the | 777 * @return <code>false</code> if the context bundle's use count for the |
772 * service is zero or if the service has been unregistered; | 778 * service is zero or if the service has been unregistered; |
773 * <code>true</code> otherwise. | 779 * <code>true</code> otherwise. |
774 * @throws java.lang.IllegalStateException If this BundleContext is no | 780 * @throws java.lang.IllegalStateException If this BundleContext is no |
780 | 786 |
781 /** | 787 /** |
782 * Creates a <code>File</code> object for a file in the persistent storage | 788 * Creates a <code>File</code> object for a file in the persistent storage |
783 * area provided for the bundle by the Framework. This method will return | 789 * area provided for the bundle by the Framework. This method will return |
784 * <code>null</code> if the platform does not have file system support. | 790 * <code>null</code> if the platform does not have file system support. |
785 * | 791 * |
786 * <p> | 792 * <p> |
787 * A <code>File</code> object for the base directory of the persistent | 793 * A <code>File</code> object for the base directory of the persistent |
788 * storage area provided for the context bundle by the Framework can be | 794 * storage area provided for the context bundle by the Framework can be |
789 * obtained by calling this method with an empty string as | 795 * obtained by calling this method with an empty string as |
790 * <code>filename</code>. | 796 * <code>filename</code>. |
791 * | 797 * |
792 * <p> | 798 * <p> |
793 * If the Java Runtime Environment supports permissions, the Framework will | 799 * If the Java Runtime Environment supports permissions, the Framework will |
794 * ensure that the bundle has the <code>java.io.FilePermission</code> with | 800 * ensure that the bundle has the <code>java.io.FilePermission</code> with |
795 * actions <code>read</code>,<code>write</code>,<code>delete</code> | 801 * actions <code>read</code>,<code>write</code>,<code>delete</code> |
796 * for all files (recursively) in the persistent storage area provided for | 802 * for all files (recursively) in the persistent storage area provided for |
797 * the context bundle. | 803 * the context bundle. |
798 * | 804 * |
799 * @param filename A relative name to the file to be accessed. | 805 * @param filename A relative name to the file to be accessed. |
800 * @return A <code>File</code> object that represents the requested file | 806 * @return A <code>File</code> object that represents the requested file |
801 * or <code>null</code> if the platform does not have file system | 807 * or <code>null</code> if the platform does not have file system |
802 * support. | 808 * support. |
803 * @throws java.lang.IllegalStateException If this BundleContext is no | 809 * @throws java.lang.IllegalStateException If this BundleContext is no |
807 | 813 |
808 /** | 814 /** |
809 * Creates a <code>Filter</code> object. This <code>Filter</code> object | 815 * Creates a <code>Filter</code> object. This <code>Filter</code> object |
810 * may be used to match a <code>ServiceReference</code> object or a | 816 * may be used to match a <code>ServiceReference</code> object or a |
811 * <code>Dictionary</code> object. | 817 * <code>Dictionary</code> object. |
812 * | 818 * |
813 * <p> | 819 * <p> |
814 * If the filter cannot be parsed, an {@link InvalidSyntaxException} will be | 820 * If the filter cannot be parsed, an {@link InvalidSyntaxException} will be |
815 * thrown with a human readable message where the filter became unparsable. | 821 * thrown with a human readable message where the filter became unparsable. |
816 * | 822 * |
817 * @param filter The filter string. | 823 * @param filter The filter string. |
818 * @return A <code>Filter</code> object encapsulating the filter string. | 824 * @return A <code>Filter</code> object encapsulating the filter string. |
819 * @throws InvalidSyntaxException If <code>filter</code> contains an | 825 * @throws InvalidSyntaxException If <code>filter</code> contains an |
820 * invalid filter string that cannot be parsed. | 826 * invalid filter string that cannot be parsed. |
821 * @throws NullPointerException If <code>filter</code> is null. | 827 * @throws NullPointerException If <code>filter</code> is null. |
822 * @throws java.lang.IllegalStateException If this BundleContext is no | 828 * @throws java.lang.IllegalStateException If this BundleContext is no |
823 * longer valid. | 829 * longer valid. |
824 * | 830 * |
825 * @since 1.1 | 831 * @since 1.1 |
826 * @see "Framework specification for a description of the filter string syntax." | 832 * @see "Framework specification for a description of the filter string syntax." |
827 * @see FrameworkUtil#createFilter(String) | 833 * @see FrameworkUtil#createFilter(String) |
828 */ | 834 */ |
829 public Filter createFilter(String filter); | 835 public Filter createFilter(String filter) ; |
830 } | 836 } |