Mercurial > projects > dwt2
diff 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 |
line wrap: on
line diff
--- a/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleContext.d Sat May 02 11:27:24 2009 +0200 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleContext.d Sun Nov 08 12:42:30 2009 +0100 @@ -1,8 +1,8 @@ /* * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleContext.java,v 1.22 2007/02/21 16:49:05 hargrave Exp $ - * + * * Copyright (c) OSGi Alliance (2000, 2007). All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,16 +16,22 @@ * limitations under the License. */ +// Port to the D programming language: +// Frank Benoit <benoit@tionex.de> module org.osgi.framework.BundleContext; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleListener; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.FrameworkListener; -import org.osgi.framework.ServiceReference; -import org.osgi.framework.ServiceRegistration; -import org.osgi.framework.Filter; import java.lang.all; + +import org.osgi.framework.BundleListener; // packageimport +import org.osgi.framework.BundleException; // packageimport +import org.osgi.framework.ServiceListener; // packageimport +import org.osgi.framework.InvalidSyntaxException; // packageimport +import org.osgi.framework.ServiceRegistration; // packageimport +import org.osgi.framework.ServiceReference; // packageimport +import org.osgi.framework.Bundle; // packageimport +import org.osgi.framework.Filter; // packageimport +import org.osgi.framework.FrameworkListener; // packageimport + import java.io.File; import java.io.InputStream; import java.util.Dictionary; @@ -34,7 +40,7 @@ * A bundle's execution context within the Framework. The context is used to * grant access to other methods so that this bundle can interact with the * Framework. - * + * * <p> * <code>BundleContext</code> methods allow a bundle to: * <ul> @@ -49,7 +55,7 @@ * <li>Create <code>File</code> objects for files in a persistent storage * area provided for the bundle by the Framework. * </ul> - * + * * <p> * A <code>BundleContext</code> object will be created and provided to the * bundle associated with this context when it is started using the @@ -59,11 +65,11 @@ * <code>BundleContext</code> object is generally for the private use of its * associated bundle and is not meant to be shared with other bundles in the * OSGi environment. - * + * * <p> * The <code>Bundle</code> object associated with a <code>BundleContext</code> * object is called the <em>context bundle</em>. - * + * * <p> * The <code>BundleContext</code> object is only valid during the execution of * its context bundle; that is, during the period from when the context bundle @@ -72,11 +78,11 @@ * object is used subsequently, an <code>IllegalStateException</code> must be * thrown. The <code>BundleContext</code> object must never be reused after * its context bundle is stopped. - * + * * <p> * The Framework is the only entity that can create <code>BundleContext</code> * objects and they are only valid within the Framework that created them. - * + * * @ThreadSafe * @version $Revision: 1.22 $ */ @@ -86,7 +92,7 @@ * Returns the value of the specified property. If the key is not found in * the Framework properties, the system properties are then searched. The * method returns <code>null</code> if the property is not found. - * + * * <p> * The Framework defines the following standard property keys: * </p> @@ -106,12 +112,12 @@ * </ul> * <p> * All bundles must have permission to read these properties. - * + * * <p> * Note: The last four standard properties are used by the * {@link Constants#BUNDLE_NATIVECODE} <code>Manifest</code> header's * matching algorithm for selecting native language code. - * + * * @param key The name of the requested property. * @return The value of the requested property, or <code>null</code> if * the property is undefined. @@ -124,7 +130,7 @@ /** * Returns the <code>Bundle</code> object associated with this * <code>BundleContext</code>. This bundle is called the context bundle. - * + * * @return The <code>Bundle</code> object associated with this * <code>BundleContext</code>. * @throws java.lang.IllegalStateException If this BundleContext is no @@ -139,38 +145,38 @@ * <p> * Every installed bundle is uniquely identified by its location string, * typically in the form of a URL. - * + * * <p> * The following steps are required to install a bundle: * <ol> * <li>If a bundle containing the same location string is already * installed, the <code>Bundle</code> object for that bundle is returned. - * + * * <li>The bundle's content is read from the location string. If this * fails, a {@link BundleException} is thrown. - * + * * <li>The bundle's <code>Bundle-NativeCode</code> dependencies are * resolved. If this fails, a <code>BundleException</code> is thrown. - * + * * <li>The bundle's associated resources are allocated. The associated * resources minimally consist of a unique identifier and a persistent * storage area if the platform has file system support. If this step fails, * a <code>BundleException</code> is thrown. - * + * * <li>If the bundle has declared an Bundle-RequiredExecutionEnvironment * header, then the listed execution environments must be verified against - * the installed execution environments. If none of the listed execution + * the installed execution environments. If none of the listed execution * environments match an installed execution environment, a * <code>BundleException</code> must be thrown. - * + * * <li>The bundle's state is set to <code>INSTALLED</code>. - * + * * <li>A bundle event of type {@link BundleEvent#INSTALLED} is fired. - * + * * <li>The <code>Bundle</code> object for the newly or previously * installed bundle is returned. * </ol> - * + * * <b>Postconditions, no exceptions thrown </b> * <ul> * <li><code>getState()</code> in {<code>INSTALLED</code>,<code>RESOLVED</code>}. @@ -180,7 +186,7 @@ * <ul> * <li>Bundle is not installed and no trace of the bundle exists. * </ul> - * + * * @param location The location identifier of the bundle to install. * @return The <code>Bundle</code> object of the installed bundle. * @throws BundleException If the installation failed. @@ -190,22 +196,22 @@ * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. */ - public Bundle installBundle(String location); + public Bundle installBundle(String location) ; /** * Installs a bundle from the specified <code>InputStream</code> object. - * + * * <p> * This method performs all of the steps listed in * <code>BundleContext.installBundle(String location)</code>, except that * the bundle's content will be read from the <code>InputStream</code> * object. The location identifier string specified will be used as the * identity of the bundle. - * + * * <p> * This method must always close the <code>InputStream</code> object, even * if an exception is thrown. - * + * * @param location The location identifier of the bundle to install. * @param input The <code>InputStream</code> object from which this bundle * will be read. @@ -219,11 +225,11 @@ * longer valid. * @see #installBundle(java.lang.String) */ - public Bundle installBundle(String location, InputStream input); + public Bundle installBundle(String location, InputStream input) ; /** * Returns the bundle with the specified identifier. - * + * * @param id The identifier of the bundle to retrieve. * @return A <code>Bundle</code> object or <code>null</code> if the * identifier does not match any installed bundle. @@ -237,7 +243,7 @@ * environment at the time of the call to this method. However, since the * Framework is a very dynamic environment, bundles can be installed or * uninstalled at anytime. - * + * * @return An array of <code>Bundle</code> objects, one object per * installed bundle. */ @@ -249,19 +255,19 @@ * listeners. See {@link Filter} for a description of the filter syntax. * <code>ServiceListener</code> objects are notified when a service has a * lifecycle state change. - * + * * <p> * If the context bundle's list of listeners already contains a listener * <code>l</code> such that <code>(l==listener)</code>, then this * method replaces that listener's filter (which may be <code>null</code>) * with the specified one (which may be <code>null</code>). - * + * * <p> * The listener is called if the filter criteria is met. To filter based * upon the class of the service, the filter should reference the * {@link Constants#OBJECTCLASS} property. If <code>filter</code> is * <code>null</code>, all services are considered to match the filter. - * + * * <p> * When using a <code>filter</code>, it is possible that the * <code>ServiceEvent</code>s for the complete lifecycle of a service @@ -275,43 +281,43 @@ * <code>ServiceEvent</code> of type <code>MODIFIED</code>. Thus, the * listener will not be called with a <code>ServiceEvent</code> of type * <code>REGISTERED</code>. - * + * * <p> * If the Java Runtime Environment supports permissions, the * <code>ServiceListener</code> object will be notified of a service event * only if the bundle that is registering it has the * <code>ServicePermission</code> to get the service using at least one of * the named classes the service was registered under. - * + * * @param listener The <code>ServiceListener</code> object to be added. * @param filter The filter criteria. - * + * * @throws InvalidSyntaxException If <code>filter</code> contains an * invalid filter string that cannot be parsed. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. - * + * * @see ServiceEvent * @see ServiceListener * @see ServicePermission */ public void addServiceListener(ServiceListener listener, - String filter); + String filter) ; /** * Adds the specified <code>ServiceListener</code> object to the context * bundle's list of listeners. - * + * * <p> * This method is the same as calling * <code>BundleContext.addServiceListener(ServiceListener listener, * String filter)</code> * with <code>filter</code> set to <code>null</code>. - * + * * @param listener The <code>ServiceListener</code> object to be added. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. - * + * * @see #addServiceListener(ServiceListener, String) */ public void addServiceListener(ServiceListener listener); @@ -319,11 +325,11 @@ /** * Removes the specified <code>ServiceListener</code> object from the * context bundle's list of listeners. - * + * * <p> * If <code>listener</code> is not contained in this context bundle's list * of listeners, this method does nothing. - * + * * @param listener The <code>ServiceListener</code> to be removed. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. @@ -334,12 +340,12 @@ * Adds the specified <code>BundleListener</code> object to the context * bundle's list of listeners if not already present. BundleListener objects * are notified when a bundle has a lifecycle state change. - * + * * <p> * If the context bundle's list of listeners already contains a listener * <code>l</code> such that <code>(l==listener)</code>, this method * does nothing. - * + * * @param listener The <code>BundleListener</code> to be added. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. @@ -347,7 +353,7 @@ * <code>SynchronousBundleListener</code> and the caller does not * have the appropriate <code>AdminPermission[context bundle,LISTENER]</code>, * and the Java Runtime Environment supports permissions. - * + * * @see BundleEvent * @see BundleListener */ @@ -356,11 +362,11 @@ /** * Removes the specified <code>BundleListener</code> object from the * context bundle's list of listeners. - * + * * <p> * If <code>listener</code> is not contained in the context bundle's list * of listeners, this method does nothing. - * + * * @param listener The <code>BundleListener</code> object to be removed. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. @@ -375,16 +381,16 @@ * Adds the specified <code>FrameworkListener</code> object to the context * bundle's list of listeners if not already present. FrameworkListeners are * notified of general Framework events. - * + * * <p> * If the context bundle's list of listeners already contains a listener * <code>l</code> such that <code>(l==listener)</code>, this method * does nothing. - * + * * @param listener The <code>FrameworkListener</code> object to be added. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. - * + * * @see FrameworkEvent * @see FrameworkListener */ @@ -393,11 +399,11 @@ /** * Removes the specified <code>FrameworkListener</code> object from the * context bundle's list of listeners. - * + * * <p> * If <code>listener</code> is not contained in the context bundle's list * of listeners, this method does nothing. - * + * * @param listener The <code>FrameworkListener</code> object to be * removed. * @throws java.lang.IllegalStateException If this BundleContext is no @@ -414,12 +420,12 @@ * bundles. The registering bundle is defined to be the context bundle. * Other bundles can locate the service by using either the * {@link #getServiceReferences} or {@link #getServiceReference} method. - * + * * <p> * A bundle can register a service object that implements the * {@link ServiceFactory} interface to have more flexibility in providing * service objects to other bundles. - * + * * <p> * The following steps are required to register a service: * <ol> @@ -441,7 +447,7 @@ * <li>A <code>ServiceRegistration</code> object for this registration is * returned. * </ol> - * + * * @param clazzes The class names under which the service can be located. * The class names in this array will be stored in the service's * properties under the key {@link Constants#OBJECTCLASS}. @@ -455,11 +461,11 @@ * {@link ServiceRegistration#setProperties} method must be called. * The set of properties may be <code>null</code> if the service * has no properties. - * + * * @return A <code>ServiceRegistration</code> object for use by the bundle * registering the service to update the service's properties or to * unregister the service. - * + * * @throws java.lang.IllegalArgumentException If one of the following is * true: * <ul> @@ -470,15 +476,15 @@ * <li><code>properties</code> contains case variants of the same * key name. * </ul> - * + * * @throws java.lang.SecurityException If the caller does not have the * <code>ServicePermission</code> to register the service for all * the named classes and the Java Runtime Environment supports * permissions. - * + * * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. - * + * * @see ServiceRegistration * @see ServiceFactory */ @@ -488,7 +494,7 @@ /** * Registers the specified service object with the specified properties * under the specified class name with the Framework. - * + * * <p> * This method is otherwise identical to * {@link #registerService(java.lang.String[], java.lang.Object, @@ -497,16 +503,16 @@ * Note that even in this case the value of the service's * {@link Constants#OBJECTCLASS} property will be an array of strings, * rather than just a single string. - * + * * @param clazz The class name under which the service can be located. * @param service The service object or a <code>ServiceFactory</code> * object. - * @param properties The properties for this service. - * + * @param properties The properties for this service. + * * @return A <code>ServiceRegistration</code> object for use by the bundle * registering the service to update the service's properties or to * unregister the service. - * + * * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. * @see #registerService(java.lang.String[], java.lang.Object, @@ -522,23 +528,23 @@ * criteria, and the packages for the class names under which the services * were registered match the context bundle's packages as defined in * {@link ServiceReference#isAssignableTo(Bundle, String)}. - * + * * <p> * The list is valid at the time of the call to this method, however since * the Framework is a very dynamic environment, services can be modified or * unregistered at anytime. - * + * * <p> * <code>filter</code> is used to select the registered service whose * properties objects contain keys and values which satisfy the filter. See * {@link Filter} for a description of the filter string syntax. - * + * * <p> * If <code>filter</code> is <code>null</code>, all registered services * are considered to match the filter. If <code>filter</code> cannot be * parsed, an {@link InvalidSyntaxException} will be thrown with a human * readable message where the filter became unparsable. - * + * * <p> * The following steps are required to select a set of * <code>ServiceReference</code> objects: @@ -573,7 +579,7 @@ * <li>An array of the remaining <code>ServiceReference</code> objects is * returned. * </ol> - * + * * @param clazz The class name with which the service was registered or * <code>null</code> for all services. * @param filter The filter criteria. @@ -586,30 +592,30 @@ * longer valid. */ public ServiceReference[] getServiceReferences(String clazz, - String filter); + String filter) ; /** * Returns an array of <code>ServiceReference</code> objects. The returned * array of <code>ServiceReference</code> objects contains services that * were registered under the specified class and match the specified filter * criteria. - * + * * <p> * The list is valid at the time of the call to this method, however since * the Framework is a very dynamic environment, services can be modified or * unregistered at anytime. - * + * * <p> * <code>filter</code> is used to select the registered service whose * properties objects contain keys and values which satisfy the filter. See * {@link Filter} for a description of the filter string syntax. - * + * * <p> * If <code>filter</code> is <code>null</code>, all registered services * are considered to match the filter. If <code>filter</code> cannot be * parsed, an {@link InvalidSyntaxException} will be thrown with a human * readable message where the filter became unparsable. - * + * * <p> * The following steps are required to select a set of * <code>ServiceReference</code> objects: @@ -635,7 +641,7 @@ * <li>An array of the remaining <code>ServiceReference</code> objects is * returned. * </ol> - * + * * @param clazz The class name with which the service was registered or * <code>null</code> for all services. * @param filter The filter criteria. @@ -649,17 +655,17 @@ * @since 1.3 */ public ServiceReference[] getAllServiceReferences(String clazz, - String filter); + String filter) ; /** * Returns a <code>ServiceReference</code> object for a service that * implements and was registered under the specified class. - * + * * <p> * This <code>ServiceReference</code> object is valid at the time of the * call to this method, however as the Framework is a very dynamic * environment, services can be modified or unregistered at anytime. - * + * * <p> * This method is the same as calling * {@link BundleContext#getServiceReferences(String, String)} with a @@ -673,7 +679,7 @@ * If there is a tie in ranking, the service with the lowest service ID (as * specified in its {@link Constants#SERVICE_ID} property); that is, the * service that was registered first is returned. - * + * * @param clazz The class name with which the service was registered. * @return A <code>ServiceReference</code> object, or <code>null</code> * if no services are registered which implement the named class. @@ -695,11 +701,11 @@ * <p> * When a bundle's use count for a service drops to zero, the bundle should * no longer use that service. - * + * * <p> * This method will always return <code>null</code> when the service * associated with this <code>reference</code> has been unregistered. - * + * * <p> * The following steps are required to get the service object: * <ol> @@ -723,7 +729,7 @@ * type {@link FrameworkEvent#ERROR} is fired. * <li>The service object for the service is returned. * </ol> - * + * * @param reference A reference to the service. * @return A service object for the service associated with * <code>reference</code> or <code>null</code> if the service is @@ -746,12 +752,12 @@ * for the service is zero, this method returns <code>false</code>. * Otherwise, the context bundle's use count for the service is decremented * by one. - * + * * <p> * The service's service object should no longer be used and all references * to it should be destroyed when a bundle's use count for the service drops * to zero. - * + * * <p> * The following steps are required to unget the service object: * <ol> @@ -766,7 +772,7 @@ * method is called to release the service object for the context bundle. * <li><code>true</code> is returned. * </ol> - * + * * @param reference A reference to the service to be released. * @return <code>false</code> if the context bundle's use count for the * service is zero or if the service has been unregistered; @@ -782,20 +788,20 @@ * Creates a <code>File</code> object for a file in the persistent storage * area provided for the bundle by the Framework. This method will return * <code>null</code> if the platform does not have file system support. - * + * * <p> * A <code>File</code> object for the base directory of the persistent * storage area provided for the context bundle by the Framework can be * obtained by calling this method with an empty string as * <code>filename</code>. - * + * * <p> * If the Java Runtime Environment supports permissions, the Framework will * ensure that the bundle has the <code>java.io.FilePermission</code> with * actions <code>read</code>,<code>write</code>,<code>delete</code> * for all files (recursively) in the persistent storage area provided for * the context bundle. - * + * * @param filename A relative name to the file to be accessed. * @return A <code>File</code> object that represents the requested file * or <code>null</code> if the platform does not have file system @@ -809,11 +815,11 @@ * Creates a <code>Filter</code> object. This <code>Filter</code> object * may be used to match a <code>ServiceReference</code> object or a * <code>Dictionary</code> object. - * + * * <p> * If the filter cannot be parsed, an {@link InvalidSyntaxException} will be * thrown with a human readable message where the filter became unparsable. - * + * * @param filter The filter string. * @return A <code>Filter</code> object encapsulating the filter string. * @throws InvalidSyntaxException If <code>filter</code> contains an @@ -821,10 +827,10 @@ * @throws NullPointerException If <code>filter</code> is null. * @throws java.lang.IllegalStateException If this BundleContext is no * longer valid. - * + * * @since 1.1 * @see "Framework specification for a description of the filter string syntax." * @see FrameworkUtil#createFilter(String) */ - public Filter createFilter(String filter); + public Filter createFilter(String filter) ; }