# HG changeset patch # User Frank Benoit # Date 1240055915 -7200 # Node ID 12b890a6392af9f2fb9e0cc7f48dbb3657942c61 # Parent 6be48cf9f95cb6dea1ed31f40fb18b0c17639150 Work on databinding diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.d --- a/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.d Sat Apr 18 13:58:35 2009 +0200 @@ -79,8 +79,11 @@ public static void isNotNull(Object object) { isNotNull(object, ""); //$NON-NLS-1$ } - public static void isNotNull(String object) { - isTrue(object.ptr !is null); //$NON-NLS-1$ + public static void isNotNull(String str) { + isTrue(str.ptr !is null); //$NON-NLS-1$ + } + public static void isNotNull(void* ptr) { + isTrue(ptr !is null); //$NON-NLS-1$ } /** Asserts that the given object is not null. If this @@ -94,6 +97,12 @@ if (object is null) throw new AssertionFailedException("null argument:" ~ message); //$NON-NLS-1$ } + public static void isNotNull(String str, String message) { + isTrue(str.ptr !is null, message ); //$NON-NLS-1$ + } + public static void isNotNull(void* ptr, String message) { + isTrue(ptr !is null, message ); //$NON-NLS-1$ + } /** Asserts that the given bool is true. If this * is not the case, some kind of unchecked exception is thrown. diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.jface/src/org/eclipse/jface/action/Action.d --- a/org.eclipse.jface/src/org/eclipse/jface/action/Action.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.jface/src/org/eclipse/jface/action/Action.d Sat Apr 18 13:58:35 2009 +0200 @@ -62,10 +62,10 @@ return null; } }; - VAL_RADIO_BTN_OFF = new ValueWrapperInt(0); - VAL_RADIO_BTN_ON = new ValueWrapperInt(1); - VAL_TOGGLE_BTN_OFF = new ValueWrapperBool(false); - VAL_TOGGLE_BTN_ON = new ValueWrapperBool(true); + VAL_RADIO_BTN_OFF = new Integer(0); + VAL_RADIO_BTN_ON = new Integer(1); + VAL_TOGGLE_BTN_OFF = new Boolean(false); + VAL_TOGGLE_BTN_ON = new Boolean(true); } /* @@ -74,13 +74,13 @@ */ private static const String VAL_PUSH_BTN = "PUSH_BTN"; //$NON-NLS-1$ - private static const ValueWrapperInt VAL_RADIO_BTN_OFF; + private static const Integer VAL_RADIO_BTN_OFF; - private static const ValueWrapperInt VAL_RADIO_BTN_ON; + private static const Integer VAL_RADIO_BTN_ON; - private static const ValueWrapperBool VAL_TOGGLE_BTN_OFF; + private static const Boolean VAL_TOGGLE_BTN_OFF; - private static const ValueWrapperBool VAL_TOGGLE_BTN_ON; + private static const Boolean VAL_TOGGLE_BTN_ON; /** * Converts an accelerator key code to a string representation. diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.jface/src/org/eclipse/jface/action/IContributionManagerOverrides.d --- a/org.eclipse.jface/src/org/eclipse/jface/action/IContributionManagerOverrides.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.jface/src/org/eclipse/jface/action/IContributionManagerOverrides.d Sat Apr 18 13:58:35 2009 +0200 @@ -57,7 +57,7 @@ * @param item the contribution item for which the accelerator value is determined * @return the accelerator */ - public ValueWrapperInt getAccelerator(IContributionItem item); + public Integer getAccelerator(IContributionItem item); /** * This is not intended to be called outside of the workbench. This method diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.d --- a/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.d Sat Apr 18 13:58:35 2009 +0200 @@ -648,10 +648,10 @@ Button button = new Button(parent, SWT.PUSH); button.setText(label); button.setFont(JFaceResources.getDialogFont()); - button.setData(new ValueWrapperInt(id)); + button.setData(new Integer(id)); button.addSelectionListener(new class SelectionAdapter { public void widgetSelected(SelectionEvent event) { - buttonPressed((cast(ValueWrapperInt) event.widget.getData()).value); + buttonPressed((cast(Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.jface/src/org/eclipse/jface/preference/ScaleFieldEditor.d --- a/org.eclipse.jface/src/org/eclipse/jface/preference/ScaleFieldEditor.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.jface/src/org/eclipse/jface/preference/ScaleFieldEditor.d Sat Apr 18 13:58:35 2009 +0200 @@ -379,8 +379,8 @@ int newValue = scale.getSelection(); if (newValue !is oldValue) { fireStateChanged(IS_VALID, false, true); - fireValueChanged(VALUE, new ValueWrapperInt(oldValue), - new ValueWrapperInt(newValue)); + fireValueChanged(VALUE, new Integer(oldValue), + new Integer(newValue)); oldValue = newValue; } } diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxCellEditor.d --- a/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxCellEditor.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxCellEditor.d Sat Apr 18 13:58:35 2009 +0200 @@ -187,7 +187,7 @@ * Integer */ protected override Object doGetValue() { - return new ValueWrapperInt(selection); + return new Integer(selection); } /* @@ -229,8 +229,8 @@ * Integer */ protected override void doSetValue(Object value) { - Assert.isTrue(comboBox !is null && (cast(ValueWrapperInt)value )); - selection = (cast(ValueWrapperInt) value).value; + Assert.isTrue(comboBox !is null && (cast(Integer)value )); + selection = (cast(Integer) value).intValue(); comboBox.select(selection); } diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/BundleActivator.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleActivator.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,93 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleActivator.java,v 1.14 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.BundleActivator; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; + +import java.lang.all; + +/** + * Customizes the starting and stopping of a bundle. + *

+ * BundleActivator is an interface that may be implemented when a + * bundle is started or stopped. The Framework can create instances of a + * bundle's BundleActivator as required. If an instance's + * BundleActivator.start method executes successfully, it is + * guaranteed that the same instance's BundleActivator.stop + * method will be called when the bundle is to be stopped. The Framework must + * not concurrently call a BundleActivator object. + * + *

+ * BundleActivator is specified through the + * Bundle-Activator Manifest header. A bundle can only specify a + * single BundleActivator in the Manifest file. Fragment bundles + * must not have a BundleActivator. The form of the Manifest + * header is: + * + *

+ * Bundle-Activator: class-name + * + *

+ * where class-name is a fully qualified Java classname. + *

+ * The specified BundleActivator class must have a public + * constructor that takes no parameters so that a BundleActivator + * object can be created by Class.newInstance(). + * + * @NotThreadSafe + * @version $Revision: 1.14 $ + */ + +public interface BundleActivator { + /** + * Called when this bundle is started so the Framework can perform the + * bundle-specific activities necessary to start this bundle. This method + * can be used to register services or to allocate any resources that this + * bundle needs. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context The execution context of the bundle being started. + * @throws java.lang.Exception If this method throws an exception, this + * bundle is marked as stopped and the Framework will remove this + * bundle's listeners, unregister all services registered by this + * bundle, and release all services used by this bundle. + */ + public void start(BundleContext context); + + /** + * Called when this bundle is stopped so the Framework can perform the + * bundle-specific activities necessary to stop the bundle. In general, this + * method should undo the work that the BundleActivator.start + * method started. There should be no active threads that were started by + * this bundle when this bundle returns. A stopped bundle must not call any + * Framework objects. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context The execution context of the bundle being stopped. + * @throws java.lang.Exception If this method throws an exception, the + * bundle is still marked as stopped, and the Framework will remove + * the bundle's listeners, unregister all services registered by the + * bundle, and release all services used by the bundle. + */ + public void stop(BundleContext context); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/BundleContext.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleContext.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,830 @@ +/* + * $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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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 java.io.File; +import java.io.InputStream; +import java.util.Dictionary; + +/** + * 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. + * + *

+ * BundleContext methods allow a bundle to: + *

+ * + *

+ * A BundleContext object will be created and provided to the + * bundle associated with this context when it is started using the + * {@link BundleActivator#start} method. The same BundleContext + * object will be passed to the bundle associated with this context when it is + * stopped using the {@link BundleActivator#stop} method. A + * BundleContext 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. + * + *

+ * The Bundle object associated with a BundleContext + * object is called the context bundle. + * + *

+ * The BundleContext object is only valid during the execution of + * its context bundle; that is, during the period from when the context bundle + * is in the STARTING, STOPPING, and + * ACTIVE bundle states. If the BundleContext + * object is used subsequently, an IllegalStateException must be + * thrown. The BundleContext object must never be reused after + * its context bundle is stopped. + * + *

+ * The Framework is the only entity that can create BundleContext + * objects and they are only valid within the Framework that created them. + * + * @ThreadSafe + * @version $Revision: 1.22 $ + */ + +public interface BundleContext { + /** + * 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 null if the property is not found. + * + *

+ * The Framework defines the following standard property keys: + *

+ * + *

+ * All bundles must have permission to read these properties. + * + *

+ * Note: The last four standard properties are used by the + * {@link Constants#BUNDLE_NATIVECODE} Manifest 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 null if + * the property is undefined. + * @throws java.lang.SecurityException If the caller does not have the + * appropriate PropertyPermission to read the + * property, and the Java Runtime Environment supports permissions. + */ + public String getProperty(String key); + + /** + * Returns the Bundle object associated with this + * BundleContext. This bundle is called the context bundle. + * + * @return The Bundle object associated with this + * BundleContext. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public Bundle getBundle(); + + /** + * Installs a bundle from the specified location string. A bundle is + * obtained from location as interpreted by the Framework in + * an implementation dependent manner. + *

+ * Every installed bundle is uniquely identified by its location string, + * typically in the form of a URL. + * + *

+ * The following steps are required to install a bundle: + *

    + *
  1. If a bundle containing the same location string is already + * installed, the Bundle object for that bundle is returned. + * + *
  2. The bundle's content is read from the location string. If this + * fails, a {@link BundleException} is thrown. + * + *
  3. The bundle's Bundle-NativeCode dependencies are + * resolved. If this fails, a BundleException is thrown. + * + *
  4. 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 BundleException is thrown. + * + *
  5. 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 + * environments match an installed execution environment, a + * BundleException must be thrown. + * + *
  6. The bundle's state is set to INSTALLED. + * + *
  7. A bundle event of type {@link BundleEvent#INSTALLED} is fired. + * + *
  8. The Bundle object for the newly or previously + * installed bundle is returned. + *
+ * + * Postconditions, no exceptions thrown + * + * Postconditions, when an exception is thrown + * + * + * @param location The location identifier of the bundle to install. + * @return The Bundle object of the installed bundle. + * @throws BundleException If the installation failed. + * @throws java.lang.SecurityException If the caller does not have the + * appropriate AdminPermission[installed bundle,LIFECYCLE], and the + * Java Runtime Environment supports permissions. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public Bundle installBundle(String location); + + /** + * Installs a bundle from the specified InputStream object. + * + *

+ * This method performs all of the steps listed in + * BundleContext.installBundle(String location), except that + * the bundle's content will be read from the InputStream + * object. The location identifier string specified will be used as the + * identity of the bundle. + * + *

+ * This method must always close the InputStream object, even + * if an exception is thrown. + * + * @param location The location identifier of the bundle to install. + * @param input The InputStream object from which this bundle + * will be read. + * @return The Bundle object of the installed bundle. + * @throws BundleException If the provided stream cannot be read or the + * installation failed. + * @throws java.lang.SecurityException If the caller does not have the + * appropriate AdminPermission[installed bundle,LIFECYCLE], and the + * Java Runtime Environment supports permissions. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @see #installBundle(java.lang.String) + */ + 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 Bundle object or null if the + * identifier does not match any installed bundle. + */ + public Bundle getBundle(long id); + + /** + * Returns a list of all installed bundles. + *

+ * This method returns a list of all bundles installed in the OSGi + * 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 Bundle objects, one object per + * installed bundle. + */ + public Bundle[] getBundles(); + + /** + * Adds the specified ServiceListener object with the + * specified filter to the context bundle's list of + * listeners. See {@link Filter} for a description of the filter syntax. + * ServiceListener objects are notified when a service has a + * lifecycle state change. + * + *

+ * If the context bundle's list of listeners already contains a listener + * l such that (l==listener), then this + * method replaces that listener's filter (which may be null) + * with the specified one (which may be null). + * + *

+ * 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 filter is + * null, all services are considered to match the filter. + * + *

+ * When using a filter, it is possible that the + * ServiceEvents for the complete lifecycle of a service + * will not be delivered to the listener. For example, if the + * filter only matches when the property x has + * the value 1, the listener will not be called if the + * service is registered with the property x not set to the + * value 1. Subsequently, when the service is modified + * setting property x to the value 1, the + * filter will match and the listener will be called with a + * ServiceEvent of type MODIFIED. Thus, the + * listener will not be called with a ServiceEvent of type + * REGISTERED. + * + *

+ * If the Java Runtime Environment supports permissions, the + * ServiceListener object will be notified of a service event + * only if the bundle that is registering it has the + * ServicePermission to get the service using at least one of + * the named classes the service was registered under. + * + * @param listener The ServiceListener object to be added. + * @param filter The filter criteria. + * + * @throws InvalidSyntaxException If filter 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); + + /** + * Adds the specified ServiceListener object to the context + * bundle's list of listeners. + * + *

+ * This method is the same as calling + * BundleContext.addServiceListener(ServiceListener listener, + * String filter) + * with filter set to null. + * + * @param listener The ServiceListener object to be added. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * + * @see #addServiceListener(ServiceListener, String) + */ + public void addServiceListener(ServiceListener listener); + + /** + * Removes the specified ServiceListener object from the + * context bundle's list of listeners. + * + *

+ * If listener is not contained in this context bundle's list + * of listeners, this method does nothing. + * + * @param listener The ServiceListener to be removed. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public void removeServiceListener(ServiceListener listener); + + /** + * Adds the specified BundleListener 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. + * + *

+ * If the context bundle's list of listeners already contains a listener + * l such that (l==listener), this method + * does nothing. + * + * @param listener The BundleListener to be added. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @throws java.lang.SecurityException If listener is a + * SynchronousBundleListener and the caller does not + * have the appropriate AdminPermission[context bundle,LISTENER], + * and the Java Runtime Environment supports permissions. + * + * @see BundleEvent + * @see BundleListener + */ + public void addBundleListener(BundleListener listener); + + /** + * Removes the specified BundleListener object from the + * context bundle's list of listeners. + * + *

+ * If listener is not contained in the context bundle's list + * of listeners, this method does nothing. + * + * @param listener The BundleListener object to be removed. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @throws java.lang.SecurityException If listener is a + * SynchronousBundleListener and the caller does not + * have the appropriate AdminPermission[context bundle,LISTENER], + * and the Java Runtime Environment supports permissions. + */ + public void removeBundleListener(BundleListener listener); + + /** + * Adds the specified FrameworkListener object to the context + * bundle's list of listeners if not already present. FrameworkListeners are + * notified of general Framework events. + * + *

+ * If the context bundle's list of listeners already contains a listener + * l such that (l==listener), this method + * does nothing. + * + * @param listener The FrameworkListener object to be added. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * + * @see FrameworkEvent + * @see FrameworkListener + */ + public void addFrameworkListener(FrameworkListener listener); + + /** + * Removes the specified FrameworkListener object from the + * context bundle's list of listeners. + * + *

+ * If listener is not contained in the context bundle's list + * of listeners, this method does nothing. + * + * @param listener The FrameworkListener object to be + * removed. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public void removeFrameworkListener(FrameworkListener listener); + + /** + * Registers the specified service object with the specified properties + * under the specified class names into the Framework. A + * ServiceRegistration object is returned. The + * ServiceRegistration object is for the private use of the + * bundle registering the service and should not be shared with other + * 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. + * + *

+ * A bundle can register a service object that implements the + * {@link ServiceFactory} interface to have more flexibility in providing + * service objects to other bundles. + * + *

+ * The following steps are required to register a service: + *

    + *
  1. If service is not a ServiceFactory, + * an IllegalArgumentException is thrown if + * service is not an instanceof all the + * classes named. + *
  2. The Framework adds these service properties to the specified + * Dictionary (which may be null): a property + * named {@link Constants#SERVICE_ID} identifying the registration number of + * the service and a property named {@link Constants#OBJECTCLASS} containing + * all the specified classes. If any of these properties have already been + * specified by the registering bundle, their values will be overwritten by + * the Framework. + *
  3. The service is added to the Framework service registry and may now + * be used by other bundles. + *
  4. A service event of type {@link ServiceEvent#REGISTERED} is + * fired. + *
  5. A ServiceRegistration object for this registration is + * returned. + *
+ * + * @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}. + * @param service The service object or a ServiceFactory + * object. + * @param properties The properties for this service. The keys in the + * properties object must all be String objects. See + * {@link Constants} for a list of standard service property keys. + * Changes should not be made to this object after calling this + * method. To update the service's properties the + * {@link ServiceRegistration#setProperties} method must be called. + * The set of properties may be null if the service + * has no properties. + * + * @return A ServiceRegistration 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: + * + * + * @throws java.lang.SecurityException If the caller does not have the + * ServicePermission 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 + */ + public ServiceRegistration registerService(String[] clazzes, + Object service, Dictionary properties); + + /** + * Registers the specified service object with the specified properties + * under the specified class name with the Framework. + * + *

+ * This method is otherwise identical to + * {@link #registerService(java.lang.String[], java.lang.Object, + * java.util.Dictionary)} and is provided as a convenience when + * service will only be registered under a single class name. + * 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 ServiceFactory + * object. + * @param properties The properties for this service. + * + * @return A ServiceRegistration 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, + * java.util.Dictionary) + */ + public ServiceRegistration registerService(String clazz, + Object service, Dictionary properties); + + /** + * Returns an array of ServiceReference objects. The returned + * array of ServiceReference objects contains services that + * were registered under the specified class, match the specified filter + * 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)}. + * + *

+ * 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. + * + *

+ * filter 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. + * + *

+ * If filter is null, all registered services + * are considered to match the filter. If filter cannot be + * parsed, an {@link InvalidSyntaxException} will be thrown with a human + * readable message where the filter became unparsable. + * + *

+ * The following steps are required to select a set of + * ServiceReference objects: + *

    + *
  1. If the filter string is not null, the filter string + * is parsed and the set ServiceReference objects of + * registered services that satisfy the filter is produced. If the filter + * string is null, then all registered services are + * considered to satisfy the filter. + *
  2. If the Java Runtime Environment supports permissions, the set of + * ServiceReference objects produced by the previous step is + * reduced by checking that the caller has the + * ServicePermission to get at least one of the class names + * under which the service was registered. If the caller does not have the + * correct permission for a particular ServiceReference + * object, then it is removed from the set. + *
  3. If clazz is not null, the set is + * further reduced to those services that are an instanceof + * and were registered under the specified class. The complete list of + * classes of which a service is an instance and which were specified when + * the service was registered is available from the service's + * {@link Constants#OBJECTCLASS} property. + *
  4. The set is reduced one final time by cycling through each + * ServiceReference object and calling + * {@link ServiceReference#isAssignableTo(Bundle, String)} with the context + * bundle and each class name under which the ServiceReference + * object was registered. For any given ServiceReference + * object, if any call to + * {@link ServiceReference#isAssignableTo(Bundle, String)} returns + * false, then it is removed from the set of + * ServiceReference objects. + *
  5. An array of the remaining ServiceReference objects is + * returned. + *
+ * + * @param clazz The class name with which the service was registered or + * null for all services. + * @param filter The filter criteria. + * @return An array of ServiceReference objects or + * null if no services are registered which satisfy + * the search. + * @throws InvalidSyntaxException If filter contains an + * invalid filter string that cannot be parsed. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public ServiceReference[] getServiceReferences(String clazz, + String filter); + + /** + * Returns an array of ServiceReference objects. The returned + * array of ServiceReference objects contains services that + * were registered under the specified class and match the specified filter + * criteria. + * + *

+ * 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. + * + *

+ * filter 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. + * + *

+ * If filter is null, all registered services + * are considered to match the filter. If filter cannot be + * parsed, an {@link InvalidSyntaxException} will be thrown with a human + * readable message where the filter became unparsable. + * + *

+ * The following steps are required to select a set of + * ServiceReference objects: + *

    + *
  1. If the filter string is not null, the filter string + * is parsed and the set ServiceReference objects of + * registered services that satisfy the filter is produced. If the filter + * string is null, then all registered services are + * considered to satisfy the filter. + *
  2. If the Java Runtime Environment supports permissions, the set of + * ServiceReference objects produced by the previous step is + * reduced by checking that the caller has the + * ServicePermission to get at least one of the class names + * under which the service was registered. If the caller does not have the + * correct permission for a particular ServiceReference + * object, then it is removed from the set. + *
  3. If clazz is not null, the set is + * further reduced to those services that are an instanceof + * and were registered under the specified class. The complete list of + * classes of which a service is an instance and which were specified when + * the service was registered is available from the service's + * {@link Constants#OBJECTCLASS} property. + *
  4. An array of the remaining ServiceReference objects is + * returned. + *
+ * + * @param clazz The class name with which the service was registered or + * null for all services. + * @param filter The filter criteria. + * @return An array of ServiceReference objects or + * null if no services are registered which satisfy + * the search. + * @throws InvalidSyntaxException If filter contains an + * invalid filter string that cannot be parsed. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @since 1.3 + */ + public ServiceReference[] getAllServiceReferences(String clazz, + String filter); + + /** + * Returns a ServiceReference object for a service that + * implements and was registered under the specified class. + * + *

+ * This ServiceReference 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. + * + *

+ * This method is the same as calling + * {@link BundleContext#getServiceReferences(String, String)} with a + * null filter string. It is provided as a convenience for + * when the caller is interested in any service that implements the + * specified class. + *

+ * If multiple such services exist, the service with the highest ranking (as + * specified in its {@link Constants#SERVICE_RANKING} property) is returned. + *

+ * 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 ServiceReference object, or null + * if no services are registered which implement the named class. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @see #getServiceReferences(String, String) + */ + public ServiceReference getServiceReference(String clazz); + + /** + * Returns the specified service object for a service. + *

+ * A bundle's use of a service is tracked by the bundle's use count of that + * service. Each time a service's service object is returned by + * {@link #getService(ServiceReference)} the context bundle's use count for + * that service is incremented by one. Each time the service is released by + * {@link #ungetService(ServiceReference)} the context bundle's use count + * for that service is decremented by one. + *

+ * When a bundle's use count for a service drops to zero, the bundle should + * no longer use that service. + * + *

+ * This method will always return null when the service + * associated with this reference has been unregistered. + * + *

+ * The following steps are required to get the service object: + *

    + *
  1. If the service has been unregistered, null is + * returned. + *
  2. The context bundle's use count for this service is incremented by + * one. + *
  3. If the context bundle's use count for the service is currently one + * and the service was registered with an object implementing the + * ServiceFactory interface, the + * {@link ServiceFactory#getService(Bundle, ServiceRegistration)} method is + * called to create a service object for the context bundle. This service + * object is cached by the Framework. While the context bundle's use count + * for the service is greater than zero, subsequent calls to get the + * services's service object for the context bundle will return the cached + * service object.
    + * If the service object returned by the ServiceFactory + * object is not an instanceof all the classes named when the + * service was registered or the ServiceFactory object throws + * an exception, null is returned and a Framework event of + * type {@link FrameworkEvent#ERROR} is fired. + *
  4. The service object for the service is returned. + *
+ * + * @param reference A reference to the service. + * @return A service object for the service associated with + * reference or null if the service is + * not registered or does not implement the classes under which it + * was registered in the case of a ServiceFactory. + * @throws java.lang.SecurityException If the caller does not have the + * ServicePermission to get the service using at + * least one of the named classes the service was registered under + * and the Java Runtime Environment supports permissions. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @see #ungetService(ServiceReference) + * @see ServiceFactory + */ + public Object getService(ServiceReference reference); + + /** + * Releases the service object referenced by the specified + * ServiceReference object. If the context bundle's use count + * for the service is zero, this method returns false. + * Otherwise, the context bundle's use count for the service is decremented + * by one. + * + *

+ * 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. + * + *

+ * The following steps are required to unget the service object: + *

    + *
  1. If the context bundle's use count for the service is zero or the + * service has been unregistered, false is returned. + *
  2. The context bundle's use count for this service is decremented by + * one. + *
  3. If the context bundle's use count for the service is currently zero + * and the service was registered with a ServiceFactory + * object, the + * {@link ServiceFactory#ungetService(Bundle, ServiceRegistration, Object)} + * method is called to release the service object for the context bundle. + *
  4. true is returned. + *
+ * + * @param reference A reference to the service to be released. + * @return false if the context bundle's use count for the + * service is zero or if the service has been unregistered; + * true otherwise. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + * @see #getService + * @see ServiceFactory + */ + public bool ungetService(ServiceReference reference); + + /** + * Creates a File object for a file in the persistent storage + * area provided for the bundle by the Framework. This method will return + * null if the platform does not have file system support. + * + *

+ * A File 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 + * filename. + * + *

+ * If the Java Runtime Environment supports permissions, the Framework will + * ensure that the bundle has the java.io.FilePermission with + * actions read,write,delete + * 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 File object that represents the requested file + * or null if the platform does not have file system + * support. + * @throws java.lang.IllegalStateException If this BundleContext is no + * longer valid. + */ + public File getDataFile(String filename); + + /** + * Creates a Filter object. This Filter object + * may be used to match a ServiceReference object or a + * Dictionary object. + * + *

+ * 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 Filter object encapsulating the filter string. + * @throws InvalidSyntaxException If filter contains an + * invalid filter string that cannot be parsed. + * @throws NullPointerException If filter 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); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/BundleEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleEvent.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,218 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleEvent.java,v 1.19 2007/02/20 00:14:12 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.BundleEvent; +import org.osgi.framework.Bundle; + +import java.util.EventObject; + +/** + * An event from the Framework describing a bundle lifecycle change. + *

+ * BundleEvent objects are delivered to + * SynchronousBundleListeners and BundleListeners + * when a change occurs in a bundle's lifecycle. A type code is used to identify + * the event type for future extendability. + * + *

+ * OSGi Alliance reserves the right to extend the set of types. + * + * @Immutable + * @see BundleListener + * @see SynchronousBundleListener + * @version $Revision: 1.19 $ + */ + +public class BundleEvent : EventObject { + static final long serialVersionUID = 4080640865971756012L; + /** + * Bundle that had a change occur in its lifecycle. + */ + private final Bundle bundle; + + /** + * Type of bundle lifecycle change. + */ + private final int type; + + /** + * The bundle has been installed. + *

+ * The value of INSTALLED is 0x00000001. + * + * @see BundleContext#installBundle(String) + */ + public final static int INSTALLED = 0x00000001; + + /** + * The bundle has been started. + *

+ * The bundle's + * {@link BundleActivator#start(BundleContext) BundleActivator start} method + * has been executed if the bundle has a bundle activator class. + *

+ * The value of STARTED is 0x00000002. + * + * @see Bundle#start() + */ + public final static int STARTED = 0x00000002; + + /** + * The bundle has been stopped. + *

+ * The bundle's + * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method + * has been executed if the bundle has a bundle activator class. + *

+ * The value of STOPPED is 0x00000004. + * + * @see Bundle#stop() + */ + public final static int STOPPED = 0x00000004; + + /** + * The bundle has been updated. + *

+ * The value of UPDATED is 0x00000008. + * + * @see Bundle#update() + */ + public final static int UPDATED = 0x00000008; + + /** + * The bundle has been uninstalled. + *

+ * The value of UNINSTALLED is 0x00000010. + * + * @see Bundle#uninstall + */ + public final static int UNINSTALLED = 0x00000010; + + /** + * The bundle has been resolved. + *

+ * The value of RESOLVED is 0x00000020. + * + * @see Bundle#RESOLVED + * @since 1.3 + */ + public final static int RESOLVED = 0x00000020; + + /** + * The bundle has been unresolved. + *

+ * The value of UNRESOLVED is 0x00000040. + * + * @see Bundle#INSTALLED + * @since 1.3 + */ + public final static int UNRESOLVED = 0x00000040; + + /** + * The bundle is about to be activated. + *

+ * The bundle's + * {@link BundleActivator#start(BundleContext) BundleActivator start} method + * is about to be called if the bundle has a bundle activator class. This + * event is only delivered to {@link SynchronousBundleListener}s. It is not + * delivered to BundleListeners. + *

+ * The value of STARTING is 0x00000080. + * + * @see Bundle#start() + * @since 1.3 + */ + public final static int STARTING = 0x00000080; + + /** + * The bundle is about to deactivated. + *

+ * The bundle's + * {@link BundleActivator#stop(BundleContext) BundleActivator stop} method + * is about to be called if the bundle has a bundle activator class. This + * event is only delivered to {@link SynchronousBundleListener}s. It is not + * delivered to BundleListeners. + *

+ * The value of STOPPING is 0x00000100. + * + * @see Bundle#stop() + * @since 1.3 + */ + public final static int STOPPING = 0x00000100; + + /** + * The bundle will be lazily activated. + *

+ * The bundle has a {@link Constants#ACTIVATION_LAZY lazy activation policy} + * and is waiting to be activated. It is now in the + * {@link Bundle#STARTING STARTING} state and has a valid + * BundleContext. This event is only delivered to + * {@link SynchronousBundleListener}s. It is not delivered to + * BundleListeners. + *

+ * The value of LAZY_ACTIVATION is 0x00000200. + * + * @since 1.4 + */ + public final static int LAZY_ACTIVATION = 0x00000200; + + /** + * Creates a bundle event of the specified type. + * + * @param type The event type. + * @param bundle The bundle which had a lifecycle change. + */ + + public this(int type, Bundle bundle) { + super(cast(Object)bundle); + this.bundle = bundle; + this.type = type; + } + + /** + * Returns the bundle which had a lifecycle change. This bundle is the + * source of the event. + * + * @return The bundle that had a change occur in its lifecycle. + */ + public Bundle getBundle() { + return bundle; + } + + /** + * Returns the type of lifecyle event. The type values are: + *

+ * + * @return The type of lifecycle event. + */ + + public int getType() { + return type; + } +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/BundleListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/BundleListener.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,51 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleListener.java,v 1.13 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.BundleListener; +import org.osgi.framework.BundleEvent; + +import java.lang.all; +import java.util.EventListener; + +/** + * A BundleEvent listener. BundleListener is a + * listener interface that may be implemented by a bundle developer. When a + * BundleEvent is fired, it is asynchronously delivered to a + * BundleListener. The Framework delivers + * BundleEvent objects to a BundleListener in + * order and must not concurrently call a BundleListener. + *

+ * A BundleListener object is registered with the Framework using + * the {@link BundleContext#addBundleListener} method. + * BundleListeners are called with a BundleEvent + * object when a bundle has been installed, resolved, started, stopped, updated, + * unresolved, or uninstalled. + * + * @see BundleEvent + * @NotThreadSafe + * @version $Revision: 1.13 $ + */ + +public interface BundleListener : EventListener { + /** + * Receives notification that a bundle has had a lifecycle change. + * + * @param event The BundleEvent. + */ + public void bundleChanged(BundleEvent event); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/Filter.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/Filter.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,127 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/Filter.java,v 1.16 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +module org.osgi.framework.Filter; +import org.osgi.framework.ServiceReference; + +import java.lang.all; +import java.util.Dictionary; + +/** + * An RFC 1960-based Filter. + *

+ * Filter objects can be created by calling + * {@link BundleContext#createFilter} with the chosen filter string. + *

+ * A Filter object can be used numerous times to determine if the + * match argument matches the filter string that was used to create the + * Filter object. + *

+ * Some examples of LDAP filters are: + * + *

+ *  "(cn=Babs Jensen)"
+ *  "(!(cn=Tim Howes))"
+ *  "(&(" + Constants.OBJECTCLASS + "=Person)(|(sn=Jensen)(cn=Babs J*)))"
+ *  "(o=univ*of*mich*)"
+ * 
+ * + * @since 1.1 + * @see "Core Specification, section 5.5, for a description of the filter string + * syntax." + * @ThreadSafe + * @version $Revision: 1.16 $ + */ +public interface Filter { + /** + * Filter using a service's properties. + *

+ * The filter is executed using the keys and values of the referenced + * service's properties. The keys are case insensitively matched with the + * filter. + * + * @param reference The reference to the service whose properties are used + * in the match. + * + * @return true if the service's properties match this + * filter; false otherwise. + */ + public bool match(ServiceReference reference); + + /** + * Filter using a Dictionary object. The Filter is executed + * using the Dictionary object's keys and values. The keys + * are case insensitively matched with the filter. + * + * @param dictionary The Dictionary object whose keys are + * used in the match. + * + * @return true if the Dictionary object's + * keys and values match this filter; false + * otherwise. + * + * @throws IllegalArgumentException If dictionary contains + * case variants of the same key name. + */ + public bool match(Dictionary dictionary); + + /** + * Returns this Filter object's filter string. + *

+ * The filter string is normalized by removing whitespace which does not + * affect the meaning of the filter. + * + * @return Filter string. + */ + public String toString(); + + /** + * Compares this Filter object to another object. + * + * @param obj The object to compare against this Filter + * object. + * + * @return If the other object is a Filter object, then + * returns this.toString().equals(obj.toString();false + * otherwise. + */ + public bool equals(Object obj); + + /** + * Returns the hashCode for this Filter object. + * + * @return The hashCode of the filter string; that is, + * this.toString().hashCode(). + */ + public int hashCode(); + + /** + * Filter with case sensitivity using a Dictionary object. + * The Filter is executed using the Dictionary object's keys + * and values. The keys are case sensitively matched with the filter. + * + * @param dictionary The Dictionary object whose keys are + * used in the match. + * + * @return true if the Dictionary object's + * keys and values match this filter; false + * otherwise. + * + * @since 1.3 + */ + public bool matchCase(Dictionary dictionary); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/FrameworkListener.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,53 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/FrameworkListener.java,v 1.12 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.FrameworkListener; +import org.osgi.framework.FrameworkEvent; + +import java.lang.all; +import java.util.EventListener; + +/** + * A FrameworkEvent listener. FrameworkListener is + * a listener interface that may be implemented by a bundle developer. When a + * FrameworkEvent is fired, it is asynchronously delivered to a + * FrameworkListener. The Framework delivers + * FrameworkEvent objects to a FrameworkListener + * in order and must not concurrently call a FrameworkListener. + * + *

+ * A FrameworkListener object is registered with the Framework + * using the {@link BundleContext#addFrameworkListener} method. + * FrameworkListener objects are called with a + * FrameworkEvent objects when the Framework starts and when + * asynchronous errors occur. + * + * @see FrameworkEvent + * @NotThreadSafe + * @version $Revision: 1.12 $ + */ + +public interface FrameworkListener : EventListener { + + /** + * Receives notification of a general FrameworkEvent object. + * + * @param event The FrameworkEvent object. + */ + public void frameworkEvent(FrameworkEvent event); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceEvent.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceEvent.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,140 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceEvent.java,v 1.15 2007/02/20 00:14:12 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceReference; + +import java.lang.util; +import java.util.EventObject; + +/** + * An event from the Framework describing a service lifecycle change. + *

+ * ServiceEvent objects are delivered to + * ServiceListeners and AllServiceListeners when + * a change occurs in this service's lifecycle. A type code is used to identify + * the event type for future extendability. + * + *

+ * OSGi Alliance reserves the right to extend the set of types. + * + * @Immutable + * @see ServiceListener + * @see AllServiceListener + * @version $Revision: 1.15 $ + */ + +public class ServiceEvent : EventObject { + static final long serialVersionUID = 8792901483909409299L; + /** + * Reference to the service that had a change occur in its lifecycle. + */ + private final ServiceReference reference; + + /** + * Type of service lifecycle change. + */ + private final int type; + + /** + * This service has been registered. + *

+ * This event is synchronously delivered after the service + * has been registered with the Framework. + * + *

+ * The value of REGISTERED is 0x00000001. + * + * @see BundleContext#registerService(String[],Object,java.util.Dictionary) + */ + public final static int REGISTERED = 0x00000001; + + /** + * The properties of a registered service have been modified. + *

+ * This event is synchronously delivered after the service + * properties have been modified. + * + *

+ * The value of MODIFIED is 0x00000002. + * + * @see ServiceRegistration#setProperties + */ + public final static int MODIFIED = 0x00000002; + + /** + * This service is in the process of being unregistered. + *

+ * This event is synchronously delivered before the + * service has completed unregistering. + * + *

+ * If a bundle is using a service that is UNREGISTERING, the + * bundle should release its use of the service when it receives this event. + * If the bundle does not release its use of the service when it receives + * this event, the Framework will automatically release the bundle's use of + * the service while completing the service unregistration operation. + * + *

+ * The value of UNREGISTERING is 0x00000004. + * + * @see ServiceRegistration#unregister + * @see BundleContext#ungetService + */ + public final static int UNREGISTERING = 0x00000004; + + /** + * Creates a new service event object. + * + * @param type The event type. + * @param reference A ServiceReference object to the service + * that had a lifecycle change. + */ + public this(int type, ServiceReference reference) { + super(cast(Object)reference); + this.reference = reference; + this.type = type; + } + + /** + * Returns a reference to the service that had a change occur in its + * lifecycle. + *

+ * This reference is the source of the event. + * + * @return Reference to the service that had a lifecycle change. + */ + public ServiceReference getServiceReference() { + return reference; + } + + /** + * Returns the type of event. The event type values are: + *

+ * + * @return Type of service lifecycle change. + */ + + public int getType() { + return type; + } +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceListener.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceListener.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,68 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceListener.java,v 1.15 2007/02/20 00:16:30 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceEvent; + +import java.lang.all; +import java.util.EventListener; + +/** + * A ServiceEvent listener. ServiceListener is a + * listener interface that may be implemented by a bundle developer. When a + * ServiceEvent is fired, it is synchronously delivered to a + * ServiceListener. The Framework may deliver + * ServiceEvent objects to a ServiceListener out + * of order and may concurrently call and/or reenter a + * ServiceListener. + * + *

+ * A ServiceListener object is registered with the Framework + * using the BundleContext.addServiceListener method. + * ServiceListener objects are called with a + * ServiceEvent object when a service is registered, modified, or + * is in the process of unregistering. + * + *

+ * ServiceEvent object delivery to ServiceListener + * objects is filtered by the filter specified when the listener was registered. + * If the Java Runtime Environment supports permissions, then additional + * filtering is done. ServiceEvent objects are only delivered to + * the listener if the bundle which defines the listener object's class has the + * appropriate ServicePermission to get the service using at + * least one of the named classes under which the service was registered. + * + *

+ * ServiceEvent object delivery to ServiceListener + * objects is further filtered according to package sources as defined in + * {@link ServiceReference#isAssignableTo(Bundle, String)}. + * + * @see ServiceEvent + * @see ServicePermission + * @ThreadSafe + * @version $Revision: 1.15 $ + */ + +public interface ServiceListener : EventListener { + /** + * Receives notification that a service has had a lifecycle change. + * + * @param event The ServiceEvent object. + */ + public void serviceChanged(ServiceEvent event); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceReference.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,183 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceReference.java,v 1.20 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.ServiceReference; +import org.osgi.framework.Bundle; + +import java.lang.all; + +/** + * A reference to a service. + * + *

+ * The Framework returns ServiceReference objects from the + * BundleContext.getServiceReference and + * BundleContext.getServiceReferences methods. + *

+ * A ServiceReference object may be shared between bundles and + * can be used to examine the properties of the service and to get the service + * object. + *

+ * Every service registered in the Framework has a unique + * ServiceRegistration object and may have multiple, distinct + * ServiceReference objects referring to it. + * ServiceReference objects associated with a + * ServiceRegistration object have the same hashCode + * and are considered equal (more specifically, their equals() + * method will return true when compared). + *

+ * If the same service object is registered multiple times, + * ServiceReference objects associated with different + * ServiceRegistration objects are not equal. + * + * @see BundleContext#getServiceReference + * @see BundleContext#getServiceReferences + * @see BundleContext#getService + * @ThreadSafe + * @version $Revision: 1.20 $ + */ + +public interface ServiceReference : Comparable { + /** + * Returns the property value to which the specified property key is mapped + * in the properties Dictionary object of the service + * referenced by this ServiceReference object. + * + *

+ * Property keys are case-insensitive. + * + *

+ * This method must continue to return property values after the service has + * been unregistered. This is so references to unregistered services (for + * example, ServiceReference objects stored in the log) can + * still be interrogated. + * + * @param key The property key. + * @return The property value to which the key is mapped; null + * if there is no property named after the key. + */ + public Object getProperty(String key); + + /** + * Returns an array of the keys in the properties Dictionary + * object of the service referenced by this ServiceReference + * object. + * + *

+ * This method will continue to return the keys after the service has been + * unregistered. This is so references to unregistered services (for + * example, ServiceReference objects stored in the log) can + * still be interrogated. + * + *

+ * This method is case-preserving ; this means that every key in the + * returned array must have the same case as the corresponding key in the + * properties Dictionary that was passed to the + * {@link BundleContext#registerService(String[],Object,java.util.Dictionary)} + * or {@link ServiceRegistration#setProperties} methods. + * + * @return An array of property keys. + */ + public String[] getPropertyKeys(); + + /** + * Returns the bundle that registered the service referenced by this + * ServiceReference object. + * + *

+ * This method must return null when the service has been + * unregistered. This can be used to determine if the service has been + * unregistered. + * + * @return The bundle that registered the service referenced by this + * ServiceReference object; null if + * that service has already been unregistered. + * @see BundleContext#registerService(String[],Object,java.util.Dictionary) + */ + public Bundle getBundle(); + + /** + * Returns the bundles that are using the service referenced by this + * ServiceReference object. Specifically, this method returns + * the bundles whose usage count for that service is greater than zero. + * + * @return An array of bundles whose usage count for the service referenced + * by this ServiceReference object is greater than + * zero; null if no bundles are currently using that + * service. + * + * @since 1.1 + */ + public Bundle[] getUsingBundles(); + + /** + * Tests if the bundle that registered the service referenced by this + * ServiceReference and the specified bundle use the same + * source for the package of the specified class name. + *

+ * This method performs the following checks: + *

    + *
  1. Get the package name from the specified class name.
  2. + *
  3. For the bundle that registered the service referenced by this + * ServiceReference (registrant bundle); find the source for + * the package. If no source is found then return true if the + * registrant bundle is equal to the specified bundle; otherwise return + * false.
  4. + *
  5. If the package source of the registrant bundle is equal to the + * package source of the specified bundle then return true; + * otherwise return false.
  6. + *
+ * + * @param bundle The Bundle object to check. + * @param className The class name to check. + * @return true if the bundle which registered the service + * referenced by this ServiceReference and the + * specified bundle use the same source for the package of the + * specified class name. Otherwise false is returned. + * + * @since 1.3 + */ + public bool isAssignableTo(Bundle bundle, String className); + + /** + * Compares this ServiceReference with the specified + * ServiceReference for order. + * + *

+ * If this ServiceReference and the specified + * ServiceReference have the same + * {@link Constants#SERVICE_ID service id} they are equal. This + * ServiceReference is less than the specified + * ServiceReference if it has a lower + * {@link Constants#SERVICE_RANKING service ranking} and greater if it has a + * higher service ranking. Otherwise, if this ServiceReference + * and the specified ServiceReference have the same + * {@link Constants#SERVICE_RANKING service ranking}, this + * ServiceReference is less than the specified + * ServiceReference if it has a higher + * {@link Constants#SERVICE_ID service id} and greater if it has a lower + * service id. + * + * @param reference The ServiceReference to be compared. + * @return Returns a negative integer, zero, or a positive integer if this + * ServiceReference is less than, equal to, or + * greater than the specified ServiceReference. + * @since 1.4 + */ + public int compareTo(Object reference); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceRegistration.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceRegistration.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,115 @@ +/* + * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/ServiceRegistration.java,v 1.14 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.framework.ServiceRegistration; +import org.osgi.framework.ServiceReference; + +import java.lang.all; +import java.util.Dictionary; + +/** + * A registered service. + * + *

+ * The Framework returns a ServiceRegistration object when a + * BundleContext.registerService method invocation is successful. + * The ServiceRegistration object is for the private use of the + * registering bundle and should not be shared with other bundles. + *

+ * The ServiceRegistration object may be used to update the + * properties of the service or to unregister the service. + * + * @see BundleContext#registerService(String[],Object,Dictionary) + * @ThreadSafe + * @version $Revision: 1.14 $ + */ + +public interface ServiceRegistration { + /** + * Returns a ServiceReference object for a service being + * registered. + *

+ * The ServiceReference object may be shared with other + * bundles. + * + * @throws java.lang.IllegalStateException If this + * ServiceRegistration object has already been + * unregistered. + * @return ServiceReference object. + */ + public ServiceReference getReference(); + + /** + * Updates the properties associated with a service. + * + *

+ * The {@link Constants#OBJECTCLASS} and {@link Constants#SERVICE_ID} keys + * cannot be modified by this method. These values are set by the Framework + * when the service is registered in the OSGi environment. + * + *

+ * The following steps are required to modify service properties: + *

    + *
  1. The service's properties are replaced with the provided properties. + *
  2. A service event of type {@link ServiceEvent#MODIFIED} is + * fired. + *
+ * + * @param properties The properties for this service. See {@link Constants} + * for a list of standard service property keys. Changes should not + * be made to this object after calling this method. To update the + * service's properties this method should be called again. + * + * @throws IllegalStateException If this ServiceRegistration + * object has already been unregistered. + * @throws IllegalArgumentException If properties contains + * case variants of the same key name. + */ + public void setProperties(Dictionary properties); + + /** + * Unregisters a service. Remove a ServiceRegistration object + * from the Framework service registry. All ServiceReference + * objects associated with this ServiceRegistration object + * can no longer be used to interact with the service. + * + *

+ * The following steps are required to unregister a service: + *

    + *
  1. The service is removed from the Framework service registry so that + * it can no longer be used. ServiceReference objects for the + * service may no longer be used to get a service object for the service. + *
  2. A service event of type {@link ServiceEvent#UNREGISTERING} is + * fired so that bundles using this service can release their + * use of it. + *
  3. For each bundle whose use count for this service is greater than + * zero:
    + * The bundle's use count for this service is set to zero.
    + * If the service was registered with a {@link ServiceFactory} object, the + * ServiceFactory.ungetService method is called to release + * the service object for the bundle. + *
+ * + * @throws java.lang.IllegalStateException If this + * ServiceRegistration object has already been + * unregistered. + * @see BundleContext#ungetService + * @see ServiceFactory#ungetService + */ + public void unregister(); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTracker.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTracker.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,1230 @@ +/* + * $Header: /cvshome/build/org.osgi.util.tracker/src/org/osgi/util/tracker/ServiceTracker.java,v 1.22 2006/07/20 16:14:43 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.util.tracker.ServiceTracker; +import org.osgi.util.tracker.ServiceTrackerCustomizer; + +import java.lang.all; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.LinkedList; + +//FIXME tmp remove: import org.eclipse.osgi.framework.internal.core.FilterImpl; +//FIXME tmp remove: import org.osgi.framework.AllServiceListener; +import org.osgi.framework.BundleContext; +//FIXME tmp remove: import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +//FIXME tmp remove: import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; + +/** + * The ServiceTracker class simplifies using services from the + * Framework's service registry. + *

+ * A ServiceTracker object is constructed with search criteria + * and a ServiceTrackerCustomizer object. A + * ServiceTracker object can use the + * ServiceTrackerCustomizer object to customize the service + * objects to be tracked. The ServiceTracker object can then be + * opened to begin tracking all services in the Framework's service registry + * that match the specified search criteria. The ServiceTracker + * object correctly handles all of the details of listening to + * ServiceEvent objects and getting and ungetting services. + *

+ * The getServiceReferences method can be called to get + * references to the services being tracked. The getService and + * getServices methods can be called to get the service objects + * for the tracked service. + *

+ * The ServiceTracker class is thread-safe. It does not call a + * ServiceTrackerCustomizer object while holding any locks. + * ServiceTrackerCustomizer implementations must also be + * thread-safe. + * + * @ThreadSafe + * @version $Revision: 1.29 $ + */ + +/* + * This implementation has been customized to only work with the Equinox OSGi framework. + * In all cases a filter string containing objectClass is passed to BundleContext.addServiceListener + * to take advantage of the ServiceEvent delivery optimizations. + */ + +public class ServiceTracker : ServiceTrackerCustomizer { + public this(BundleContext context, ServiceReference reference, ServiceTrackerCustomizer customizer) { + implMissing(__FILE__,__LINE__); + } + public this(BundleContext context, String clazz, ServiceTrackerCustomizer customizer) { + implMissing(__FILE__,__LINE__); + } + public this(BundleContext context, Filter filter, ServiceTrackerCustomizer customizer) { + implMissing(__FILE__,__LINE__); + } + public Object addingService(ServiceReference reference){ + implMissing(__FILE__,__LINE__); + return null; + } + public void modifiedService(ServiceReference reference, Object service){ + implMissing(__FILE__,__LINE__); + } + public void removedService(ServiceReference reference, Object service){ + implMissing(__FILE__,__LINE__); + } + public void open() { + implMissing(__FILE__,__LINE__); + } + public void open( bool trackAll) { + implMissing(__FILE__,__LINE__); + } + public synchronized void close() { + implMissing(__FILE__,__LINE__); + } + public Object getService(ServiceReference reference) { + implMissing(__FILE__,__LINE__); + return null; + } + public Object getService() { + implMissing(__FILE__,__LINE__); + return null; + } +} +//FIXME Dummy class +/+++ +public class ServiceTracker : ServiceTrackerCustomizer { + /* set this to true to compile in debug messages */ + static final bool DEBUG = false; + /** + * Bundle context against which this ServiceTracker object is + * tracking. + */ + protected final BundleContext context; + /** + * Filter specifying search criteria for the services to track. + * + * @since 1.1 + */ + protected final Filter filter; + /** + * ServiceTrackerCustomizer object for this tracker. + */ + final ServiceTrackerCustomizer customizer; + /** + * Filter string for use when adding the ServiceListener. + */ + private final String listenerFilter; + /** + * Class name to be tracked. If this field is set, then we are tracking by + * class name. + */ + private final String trackClass; + /** + * Reference to be tracked. If this field is set, then we are tracking a + * single ServiceReference. + */ + private final ServiceReference trackReference; + /** + * True if no Filter object was supplied in a constructor or we are not + * using the supplied filter. + */ + final bool noUserFilter; + /** + * Tracked services: ServiceReference object -> customized + * Object and ServiceListener object + */ + private volatile Tracked tracked; + /** + * Modification count. This field is initialized to zero by open, set to -1 + * by close and incremented by modified. + * + * This field is volatile since it is accessed by multiple threads. + */ + private volatile int trackingCount = -1; + /** + * Cached ServiceReference for getServiceReference. + * + * This field is volatile since it is accessed by multiple threads. + */ + private volatile ServiceReference cachedReference; + /** + * Cached service object for getService. + * + * This field is volatile since it is accessed by multiple threads. + */ + private volatile Object cachedService; + + /** + * Create a ServiceTracker object on the specified + * ServiceReference object. + * + *

+ * The service referenced by the specified ServiceReference + * object will be tracked by this ServiceTracker object. + * + * @param context BundleContext object against which the + * tracking is done. + * @param reference ServiceReference object for the service + * to be tracked. + * @param customizer The customizer object to call when services are added, + * modified, or removed in this ServiceTracker object. + * If customizer is null, then this + * ServiceTracker object will be used as the + * ServiceTrackerCustomizer object and the + * ServiceTracker object will call the + * ServiceTrackerCustomizer methods on itself. + */ + public this(BundleContext context, ServiceReference reference, + ServiceTrackerCustomizer customizer) { + this.context = context; + this.trackReference = reference; + this.trackClass = null; + this.customizer = (customizer == null) ? this : customizer; + this.listenerFilter = "(&(" + Constants.OBJECTCLASS + "=" + ((String[]) reference.getProperty(Constants.OBJECTCLASS))[0] //$NON-NLS-1$ //$NON-NLS-2$ + + ")(" + Constants.SERVICE_ID + "=" + reference.getProperty(Constants.SERVICE_ID).toString() + "))" ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + this.noUserFilter = true; + try { + this.filter = context.createFilter(listenerFilter); + } + catch (InvalidSyntaxException e) { // we could only get this exception + // if the ServiceReference was + // invalid + throw new IllegalArgumentException( + "unexpected InvalidSyntaxException: " + e.getMessage()); //$NON-NLS-1$ + } + } + + /** + * Create a ServiceTracker object on the specified class + * name. + * + *

+ * Services registered under the specified class name will be tracked by + * this ServiceTracker object. + * + * @param context BundleContext object against which the + * tracking is done. + * @param clazz Class name of the services to be tracked. + * @param customizer The customizer object to call when services are added, + * modified, or removed in this ServiceTracker object. + * If customizer is null, then this + * ServiceTracker object will be used as the + * ServiceTrackerCustomizer object and the + * ServiceTracker object will call the + * ServiceTrackerCustomizer methods on itself. + */ + public this(BundleContext context, String clazz, + ServiceTrackerCustomizer customizer) { + this.context = context; + this.trackReference = null; + this.trackClass = clazz; + this.customizer = (customizer == null) ? this : customizer; + this.listenerFilter = "(" + Constants.OBJECTCLASS + "=" + clazz.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + this.noUserFilter = true; + try { + this.filter = context.createFilter(listenerFilter); + } + catch (InvalidSyntaxException e) { // we could only get this exception + // if the clazz argument was + // malformed + throw new IllegalArgumentException( + "unexpected InvalidSyntaxException: " + e.getMessage()); //$NON-NLS-1$ + } + } + + /** + * Create a ServiceTracker object on the specified + * Filter object. + * + *

+ * Services which match the specified Filter object will be + * tracked by this ServiceTracker object. + * + * @param context BundleContext object against which the + * tracking is done. + * @param filter Filter object to select the services to be + * tracked. + * @param customizer The customizer object to call when services are added, + * modified, or removed in this ServiceTracker object. + * If customizer is null, then this ServiceTracker + * object will be used as the ServiceTrackerCustomizer + * object and the ServiceTracker object will call the + * ServiceTrackerCustomizer methods on itself. + * @since 1.1 + */ + public this(BundleContext context, Filter filter, + ServiceTrackerCustomizer customizer) { + this.context = context; + this.trackReference = null; + + // obtain a required objectClass from the user supplied filter + if (filter instanceof FilterImpl) { + this.trackClass = ((FilterImpl)filter).getRequiredObjectClass(); + } else { + this.trackClass = null; + } + + if (this.trackClass != null) { + this.listenerFilter = FilterImpl.getObjectClassFilterString(this.trackClass); + //convert to track by class instead of filter if the user filter is in the form (objectClass=some.Clazz) + this.noUserFilter = this.listenerFilter.equals(filter.toString()); + } else { + this.listenerFilter = null; + this.noUserFilter = false; + } + + this.filter = filter; + this.customizer = (customizer == null) ? this : customizer; + if ((context == null) || (filter == null)) { // we throw a NPE here + // to + // be consistent with the + // other constructors + throw new NullPointerException(); + } + } + + /** + * Open this ServiceTracker object and begin tracking + * services. + * + *

+ * This method calls open(false). + * + * @throws java.lang.IllegalStateException if the BundleContext + * object with which this ServiceTracker object was + * created is no longer valid. + * @see #open(bool) + */ + public void open() { + open(false); + } + + /** + * Open this ServiceTracker object and begin tracking + * services. + * + *

+ * Services which match the search criteria specified when this + * ServiceTracker object was created are now tracked by this + * ServiceTracker object. + * + * @param trackAllServices If true, then this + * ServiceTracker will track all matching services + * regardless of class loader accessibility. If false, + * then this ServiceTracker will only track matching + * services which are class loader accessibile to the bundle whose + * BundleContext is used by this + * ServiceTracker. + * @throws java.lang.IllegalStateException if the BundleContext + * object with which this ServiceTracker object was + * created is no longer valid. + * @since 1.3 + */ + public synchronized void open(bool trackAllServices) { + if (tracked != null) { + return; + } + if (DEBUG) { + System.out.println("ServiceTracker.open: " + filter); //$NON-NLS-1$ + } + tracked = trackAllServices ? new AllTracked() : new Tracked(); + trackingCount = 0; + synchronized (tracked) { + try { + context.addServiceListener(tracked, listenerFilter); + ServiceReference[] references; + + if (trackReference != null) { // tracking a single reference + references = new ServiceReference[] {trackReference}; + } + else { // tracking a set of references + references = getInitialReferences(trackAllServices, trackClass, + noUserFilter ? null: filter.toString()); + } + + tracked.setInitialServices(references); // set tracked with + // the initial + // references + } + catch (InvalidSyntaxException e) { + throw new RuntimeException( + "unexpected InvalidSyntaxException: " + e.getMessage()); //$NON-NLS-1$ + } + } + /* Call tracked outside of synchronized region */ + tracked.trackInitialServices(); // process the initial references + } + + /** + * Returns the list of initial ServiceReference objects that + * will be tracked by this ServiceTracker object. + * + * @param trackAllServices If true, use getAllServiceReferences. + * @param trackClass the class name with which the service was registered, + * or null for all services. + * @param filterString the filter criteria or null for all services. + * @return the list of initial ServiceReference objects. + * @throws InvalidSyntaxException if the filter uses an invalid syntax. + */ + private ServiceReference[] getInitialReferences(bool trackAllServices, + String trackClass, String filterString) + throws InvalidSyntaxException { + if (trackAllServices) { + return context.getAllServiceReferences(trackClass, filterString); + } + else { + return context.getServiceReferences(trackClass, filterString); + } + } + + /** + * Close this ServiceTracker object. + * + *

+ * This method should be called when this ServiceTracker + * object should end the tracking of services. + */ + public synchronized void close() { + if (tracked == null) { + return; + } + if (DEBUG) { + System.out.println("ServiceTracker.close: " + filter); //$NON-NLS-1$ + } + tracked.close(); + ServiceReference[] references = getServiceReferences(); + Tracked outgoing = tracked; + tracked = null; + try { + context.removeServiceListener(outgoing); + } + catch (IllegalStateException e) { + /* In case the context was stopped. */ + } + if (references != null) { + for (int i = 0; i < references.length; i++) { + outgoing.untrack(references[i]); + } + } + trackingCount = -1; + if (DEBUG) { + if ((cachedReference == null) && (cachedService == null)) { + System.out + .println("ServiceTracker.close[cached cleared]: " + filter); //$NON-NLS-1$ + } + } + } + + /** + * Default implementation of the + * ServiceTrackerCustomizer.addingService method. + * + *

+ * This method is only called when this ServiceTracker object + * has been constructed with a null ServiceTrackerCustomizer + * argument. + * + * The default implementation returns the result of calling + * getService, on the BundleContext object + * with which this ServiceTracker object was created, passing + * the specified ServiceReference object. + *

+ * This method can be overridden in a subclass to customize the service + * object to be tracked for the service being added. In that case, take care + * not to rely on the default implementation of removedService that will + * unget the service. + * + * @param reference Reference to service being added to this + * ServiceTracker object. + * @return The service object to be tracked for the service added to this + * ServiceTracker object. + * @see ServiceTrackerCustomizer + */ + public Object addingService(ServiceReference reference) { + return context.getService(reference); + } + + /** + * Default implementation of the + * ServiceTrackerCustomizer.modifiedService method. + * + *

+ * This method is only called when this ServiceTracker object + * has been constructed with a null ServiceTrackerCustomizer + * argument. + * + * The default implementation does nothing. + * + * @param reference Reference to modified service. + * @param service The service object for the modified service. + * @see ServiceTrackerCustomizer + */ + public void modifiedService(ServiceReference reference, Object service) { + } + + /** + * Default implementation of the + * ServiceTrackerCustomizer.removedService method. + * + *

+ * This method is only called when this ServiceTracker object + * has been constructed with a null ServiceTrackerCustomizer + * argument. + * + * The default implementation calls ungetService, on the + * BundleContext object with which this + * ServiceTracker object was created, passing the specified + * ServiceReference object. + *

+ * This method can be overridden in a subclass. If the default + * implementation of addingService method was used, this + * method must unget the service. + * + * @param reference Reference to removed service. + * @param service The service object for the removed service. + * @see ServiceTrackerCustomizer + */ + public void removedService(ServiceReference reference, Object service) { + context.ungetService(reference); + } + + /** + * Wait for at least one service to be tracked by this + * ServiceTracker object. + *

+ * It is strongly recommended that waitForService is not used + * during the calling of the BundleActivator methods. + * BundleActivator methods are expected to complete in a + * short period of time. + * + * @param timeout time interval in milliseconds to wait. If zero, the method + * will wait indefinately. + * @return Returns the result of getService(). + * @throws InterruptedException If another thread has interrupted the + * current thread. + * @throws IllegalArgumentException If the value of timeout is negative. + */ + public Object waitForService(long timeout) throws InterruptedException { + if (timeout < 0) { + throw new IllegalArgumentException("timeout value is negative"); //$NON-NLS-1$ + } + Object object = getService(); + while (object == null) { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return null; + } + synchronized (tracked) { + if (tracked.size() == 0) { + tracked.wait(timeout); + } + } + object = getService(); + if (timeout > 0) { + return object; + } + } + return object; + } + + /** + * Return an array of ServiceReference objects for all + * services being tracked by this ServiceTracker object. + * + * @return Array of ServiceReference objects or + * null if no service are being tracked. + */ + public ServiceReference[] getServiceReferences() { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return null; + } + synchronized (tracked) { + int length = tracked.size(); + if (length == 0) { + return null; + } + ServiceReference[] references = new ServiceReference[length]; + Enumeration keys = tracked.keys(); + for (int i = 0; i < length; i++) { + references[i] = (ServiceReference) keys.nextElement(); + } + return references; + } + } + + /** + * Returns a ServiceReference object for one of the services + * being tracked by this ServiceTracker object. + * + *

+ * If multiple services are being tracked, the service with the highest + * ranking (as specified in its service.ranking property) is + * returned. + * + *

+ * If there is a tie in ranking, the service with the lowest service ID (as + * specified in its service.id property); that is, the + * service that was registered first is returned. + *

+ * This is the same algorithm used by + * BundleContext.getServiceReference. + * + * @return ServiceReference object or null if + * no service is being tracked. + * @since 1.1 + */ + public ServiceReference getServiceReference() { + ServiceReference reference = cachedReference; + if (reference != null) { + if (DEBUG) { + System.out + .println("ServiceTracker.getServiceReference[cached]: " + filter); //$NON-NLS-1$ + } + return reference; + } + if (DEBUG) { + System.out.println("ServiceTracker.getServiceReference: " + filter); //$NON-NLS-1$ + } + ServiceReference[] references = getServiceReferences(); + int length = (references == null) ? 0 : references.length; + if (length == 0) /* if no service is being tracked */ + { + return null; + } + int index = 0; + if (length > 1) /* if more than one service, select highest ranking */ + { + int rankings[] = new int[length]; + int count = 0; + int maxRanking = Integer.MIN_VALUE; + for (int i = 0; i < length; i++) { + Object property = references[i] + .getProperty(Constants.SERVICE_RANKING); + int ranking = (property instanceof Integer) ? ((Integer) property) + .intValue() + : 0; + rankings[i] = ranking; + if (ranking > maxRanking) { + index = i; + maxRanking = ranking; + count = 1; + } + else { + if (ranking == maxRanking) { + count++; + } + } + } + if (count > 1) /* if still more than one service, select lowest id */ + { + long minId = Long.MAX_VALUE; + for (int i = 0; i < length; i++) { + if (rankings[i] == maxRanking) { + long id = ((Long) (references[i] + .getProperty(Constants.SERVICE_ID))) + .longValue(); + if (id < minId) { + index = i; + minId = id; + } + } + } + } + } + return cachedReference = references[index]; + } + + /** + * Returns the service object for the specified + * ServiceReference object if the referenced service is being + * tracked by this ServiceTracker object. + * + * @param reference Reference to the desired service. + * @return Service object or null if the service referenced + * by the specified ServiceReference object is not + * being tracked. + */ + public Object getService(ServiceReference reference) { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return null; + } + synchronized (tracked) { + return tracked.get(reference); + } + } + + /** + * Return an array of service objects for all services being tracked by this + * ServiceTracker object. + * + * @return Array of service objects or null if no service are + * being tracked. + */ + public Object[] getServices() { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return null; + } + synchronized (tracked) { + ServiceReference[] references = getServiceReferences(); + int length = (references == null) ? 0 : references.length; + if (length == 0) { + return null; + } + Object[] objects = new Object[length]; + for (int i = 0; i < length; i++) { + objects[i] = getService(references[i]); + } + return objects; + } + } + + /** + * Returns a service object for one of the services being tracked by this + * ServiceTracker object. + * + *

+ * If any services are being tracked, this method returns the result of + * calling getService(getServiceReference()). + * + * @return Service object or null if no service is being + * tracked. + */ + public Object getService() { + Object service = cachedService; + if (service != null) { + if (DEBUG) { + System.out + .println("ServiceTracker.getService[cached]: " + filter); //$NON-NLS-1$ + } + return service; + } + if (DEBUG) { + System.out.println("ServiceTracker.getService: " + filter); //$NON-NLS-1$ + } + ServiceReference reference = getServiceReference(); + if (reference == null) { + return null; + } + return cachedService = getService(reference); + } + + /** + * Remove a service from this ServiceTracker object. + * + * The specified service will be removed from this + * ServiceTracker object. If the specified service was being + * tracked then the ServiceTrackerCustomizer.removedService + * method will be called for that service. + * + * @param reference Reference to the service to be removed. + */ + public void remove(ServiceReference reference) { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return; + } + tracked.untrack(reference); + } + + /** + * Return the number of services being tracked by this + * ServiceTracker object. + * + * @return Number of services being tracked. + */ + public int size() { + Tracked tracked = this.tracked; /* + * use local var since we are not + * synchronized + */ + if (tracked == null) { /* if ServiceTracker is not open */ + return 0; + } + return tracked.size(); + } + + /** + * Returns the tracking count for this ServiceTracker object. + * + * The tracking count is initialized to 0 when this + * ServiceTracker object is opened. Every time a service is + * added, modified or removed from this ServiceTracker object + * the tracking count is incremented. + * + *

+ * The tracking count can be used to determine if this + * ServiceTracker object has added, modified or removed a + * service by comparing a tracking count value previously collected with the + * current tracking count value. If the value has not changed, then no + * service has been added, modified or removed from this + * ServiceTracker object since the previous tracking count + * was collected. + * + * @since 1.2 + * @return The tracking count for this ServiceTracker object + * or -1 if this ServiceTracker object is not open. + */ + public int getTrackingCount() { + return trackingCount; + } + + /** + * Called by the Tracked object whenever the set of tracked services is + * modified. Increments the tracking count and clears the cache. + * + * @GuardedBy tracked + */ + /* + * This method must not be synchronized since it is called by Tracked while + * Tracked is synchronized. We don't want synchronization interactions + * between the ServiceListener thread and the user thread. + */ + void modified() { + trackingCount++; /* increment modification count */ + cachedReference = null; /* clear cached value */ + cachedService = null; /* clear cached value */ + if (DEBUG) { + System.out.println("ServiceTracker.modified: " + filter); //$NON-NLS-1$ + } + } + + + /** + * Inner class to track services. If a ServiceTracker object + * is reused (closed then reopened), then a new Tracked object is used. This + * class is a hashtable mapping ServiceReference object -> + * customized Object. This class is the ServiceListener + * object for the tracker. This class is used to synchronize access to the + * tracked services. This is not a public class. It is only for use by the + * implementation of the ServiceTracker class. + * + * @ThreadSafe + */ + class Tracked extends Hashtable implements ServiceListener { + static final long serialVersionUID = -7420065199791006079L; + /** + * List of ServiceReferences in the process of being added. This is used + * to deal with nesting of ServiceEvents. Since ServiceEvents are + * synchronously delivered, ServiceEvents can be nested. For example, + * when processing the adding of a service and the customizer causes the + * service to be unregistered, notification to the nested call to + * untrack that the service was unregistered can be made to the track + * method. + * + * Since the ArrayList implementation is not synchronized, all access to + * this list must be protected by the same synchronized object for + * thread-safety. + * + * @GuardedBy this + */ + private final ArrayList adding; + + /** + * true if the tracked object is closed. + * + * This field is volatile because it is set by one thread and read by + * another. + */ + private volatile bool closed; + + /** + * Initial list of ServiceReferences for the tracker. This is used to + * correctly process the initial services which could become + * unregistered before they are tracked. This is necessary since the + * initial set of tracked services are not "announced" by ServiceEvents + * and therefore the ServiceEvent for unregistration could be delivered + * before we track the service. + * + * A service must not be in both the initial and adding lists at the + * same time. A service must be moved from the initial list to the + * adding list "atomically" before we begin tracking it. + * + * Since the LinkedList implementation is not synchronized, all access + * to this list must be protected by the same synchronized object for + * thread-safety. + * + * @GuardedBy this + */ + private final LinkedList initial; + + /** + * Tracked constructor. + */ + protected Tracked() { + super(); + closed = false; + adding = new ArrayList(6); + initial = new LinkedList(); + } + + /** + * Set initial list of services into tracker before ServiceEvents begin + * to be received. + * + * This method must be called from ServiceTracker.open while + * synchronized on this object in the same synchronized block as the + * addServiceListener call. + * + * @param references The initial list of services to be tracked. + * @GuardedBy this + */ + protected void setInitialServices(ServiceReference[] references) { + if (references == null) { + return; + } + int size = references.length; + for (int i = 0; i < size; i++) { + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.setInitialServices: " + references[i]); //$NON-NLS-1$ + } + initial.add(references[i]); + } + } + + /** + * Track the initial list of services. This is called after + * ServiceEvents can begin to be received. + * + * This method must be called from ServiceTracker.open while not + * synchronized on this object after the addServiceListener call. + * + */ + protected void trackInitialServices() { + while (true) { + ServiceReference reference; + synchronized (this) { + if (initial.size() == 0) { + /* + * if there are no more inital services + */ + return; /* we are done */ + } + /* + * move the first service from the initial list to the + * adding list within this synchronized block. + */ + reference = (ServiceReference) initial.removeFirst(); + if (this.get(reference) != null) { + /* if we are already tracking this service */ + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.trackInitialServices[already tracked]: " + reference); //$NON-NLS-1$ + } + continue; /* skip this service */ + } + if (adding.contains(reference)) { + /* + * if this service is already in the process of being + * added. + */ + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.trackInitialServices[already adding]: " + reference); //$NON-NLS-1$ + } + continue; /* skip this service */ + } + adding.add(reference); + } + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.trackInitialServices: " + reference); //$NON-NLS-1$ + } + trackAdding(reference); /* + * Begin tracking it. We call + * trackAdding since we have already put + * the reference in the adding list. + */ + } + } + + /** + * Called by the owning ServiceTracker object when it is + * closed. + */ + protected void close() { + closed = true; + } + + /** + * ServiceListener method for the + * ServiceTracker class. This method must NOT be + * synchronized to avoid deadlock potential. + * + * @param event ServiceEvent object from the framework. + */ + public void serviceChanged(ServiceEvent event) { + /* + * Check if we had a delayed call (which could happen when we + * close). + */ + if (closed) { + return; + } + ServiceReference reference = event.getServiceReference(); + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference); //$NON-NLS-1$ //$NON-NLS-2$ + } + + switch (event.getType()) { + case ServiceEvent.REGISTERED : + case ServiceEvent.MODIFIED : + if (noUserFilter) { // no user supplied filter to be checked + track(reference); + /* + * If the customizer throws an unchecked exception, it + * is safe to let it propagate + */ + } + else { // filter supplied by user must be checked + if (filter.match(reference)) { + track(reference); + /* + * If the customizer throws an unchecked exception, + * it is safe to let it propagate + */ + } + else { + untrack(reference); + /* + * If the customizer throws an unchecked exception, + * it is safe to let it propagate + */ + } + } + break; + case ServiceEvent.UNREGISTERING : + untrack(reference); + /* + * If the customizer throws an unchecked exception, it is + * safe to let it propagate + */ + break; + } + } + + /** + * Begin to track the referenced service. + * + * @param reference Reference to a service to be tracked. + */ + private void track(ServiceReference reference) { + Object object; + synchronized (this) { + object = this.get(reference); + } + if (object != null) /* we are already tracking the service */ + { + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.track[modified]: " + reference); //$NON-NLS-1$ + } + synchronized (this) { + modified(); /* increment modification count */ + } + /* Call customizer outside of synchronized region */ + customizer.modifiedService(reference, object); + /* + * If the customizer throws an unchecked exception, it is safe + * to let it propagate + */ + return; + } + synchronized (this) { + if (adding.contains(reference)) { /* + * if this service is + * already in the process of + * being added. + */ + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.track[already adding]: " + reference); //$NON-NLS-1$ + } + return; + } + adding.add(reference); /* mark this service is being added */ + } + + trackAdding(reference); /* + * call trackAdding now that we have put the + * reference in the adding list + */ + } + + /** + * Common logic to add a service to the tracker used by track and + * trackInitialServices. The specified reference must have been placed + * in the adding list before calling this method. + * + * @param reference Reference to a service to be tracked. + */ + private void trackAdding(ServiceReference reference) { + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.trackAdding: " + reference); //$NON-NLS-1$ + } + Object object = null; + bool becameUntracked = false; + /* Call customizer outside of synchronized region */ + try { + object = customizer.addingService(reference); + /* + * If the customizer throws an unchecked exception, it will + * propagate after the finally + */ + } + finally { + synchronized (this) { + if (adding.remove(reference)) { /* + * if the service was not + * untracked during the + * customizer callback + */ + if (object != null) { + this.put(reference, object); + modified(); /* increment modification count */ + notifyAll(); /* + * notify any waiters in + * waitForService + */ + } + } + else { + becameUntracked = true; + } + } + } + /* + * The service became untracked during the customizer callback. + */ + if (becameUntracked) { + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.trackAdding[removed]: " + reference); //$NON-NLS-1$ + } + /* Call customizer outside of synchronized region */ + customizer.removedService(reference, object); + /* + * If the customizer throws an unchecked exception, it is safe + * to let it propagate + */ + } + } + + /** + * Discontinue tracking the referenced service. + * + * @param reference Reference to the tracked service. + */ + protected void untrack(ServiceReference reference) { + Object object; + synchronized (this) { + if (initial.remove(reference)) { /* + * if this service is + * already in the list of + * initial references to + * process + */ + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.untrack[removed from initial]: " + reference); //$NON-NLS-1$ + } + return; /* + * we have removed it from the list and it will not + * be processed + */ + } + + if (adding.remove(reference)) { /* + * if the service is in the + * process of being added + */ + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.untrack[being added]: " + reference); //$NON-NLS-1$ + } + return; /* + * in case the service is untracked while in the + * process of adding + */ + } + object = this.remove(reference); /* + * must remove from tracker + * before calling customizer + * callback + */ + if (object == null) { /* are we actually tracking the service */ + return; + } + modified(); /* increment modification count */ + } + if (DEBUG) { + System.out + .println("ServiceTracker.Tracked.untrack[removed]: " + reference); //$NON-NLS-1$ + } + /* Call customizer outside of synchronized region */ + customizer.removedService(reference, object); + /* + * If the customizer throws an unchecked exception, it is safe to + * let it propagate + */ + } + } + + /** + * Subclass of Tracked which implements the AllServiceListener interface. + * This class is used by the ServiceTracker if open is called with true. + * + * @since 1.3 + * @ThreadSafe + */ + class AllTracked extends Tracked implements AllServiceListener { + static final long serialVersionUID = 4050764875305137716L; + + /** + * AllTracked constructor. + */ + protected AllTracked() { + super(); + } + } +} ++++/ + + diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTrackerCustomizer.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTrackerCustomizer.d Sat Apr 18 13:58:35 2009 +0200 @@ -0,0 +1,98 @@ +/* + * $Header: /cvshome/build/org.osgi.util.tracker/src/org/osgi/util/tracker/ServiceTrackerCustomizer.java,v 1.13 2007/02/19 19:04:33 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +module org.osgi.util.tracker.ServiceTrackerCustomizer; + +import java.lang.all; +import org.osgi.framework.ServiceReference; + +/** + * The ServiceTrackerCustomizer interface allows a + * ServiceTracker object to customize the service objects that + * are tracked. The ServiceTrackerCustomizer object is called + * when a service is being added to the ServiceTracker object. + * The ServiceTrackerCustomizer can then return an object for the + * tracked service. The ServiceTrackerCustomizer object is also + * called when a tracked service is modified or has been removed from the + * ServiceTracker object. + * + *

+ * The methods in this interface may be called as the result of a + * ServiceEvent being received by a ServiceTracker + * object. Since ServiceEvent s are synchronously delivered by + * the Framework, it is highly recommended that implementations of these methods + * do not register (BundleContext.registerService), modify ( + * ServiceRegistration.setProperties) or unregister ( + * ServiceRegistration.unregister) a service while being + * synchronized on any object. + * + *

+ * The ServiceTracker class is thread-safe. It does not call a + * ServiceTrackerCustomizer object while holding any locks. + * ServiceTrackerCustomizer implementations must also be + * thread-safe. + * + * @ThreadSafe + * @version $Revision: 1.13 $ + */ +public interface ServiceTrackerCustomizer { + /** + * A service is being added to the ServiceTracker object. + * + *

+ * This method is called before a service which matched the search + * parameters of the ServiceTracker object is added to it. + * This method should return the service object to be tracked for this + * ServiceReference object. The returned service object is + * stored in the ServiceTracker object and is available from + * the getService and getServices methods. + * + * @param reference Reference to service being added to the + * ServiceTracker object. + * @return The service object to be tracked for the + * ServiceReference object or null if + * the ServiceReference object should not be tracked. + */ + public Object addingService(ServiceReference reference); + + /** + * A service tracked by the ServiceTracker object has been + * modified. + * + *

+ * This method is called when a service being tracked by the + * ServiceTracker object has had it properties modified. + * + * @param reference Reference to service that has been modified. + * @param service The service object for the modified service. + */ + public void modifiedService(ServiceReference reference, Object service); + + /** + * A service tracked by the ServiceTracker object has been + * removed. + * + *

+ * This method is called after a service is no longer being tracked by the + * ServiceTracker object. + * + * @param reference Reference to service that has been removed. + * @param service The service object for the removed service. + */ + public void removedService(ServiceReference reference, Object service); +} diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d --- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d Sat Apr 18 13:58:35 2009 +0200 @@ -231,7 +231,7 @@ /* Determine the desktop for the given display. */ static int getDesktop(Display display) { if (display is null) return DESKTOP_UNKNOWN; - ValueWrapperInt desktopValue = cast(ValueWrapperInt)display.getData(DESKTOP_DATA); + Integer desktopValue = cast(Integer)display.getData(DESKTOP_DATA); if (desktopValue !is null) return desktopValue.value; int desktop = DESKTOP_UNKNOWN; @@ -263,12 +263,12 @@ if (gnome !is OS.None && (OS.GTK_VERSION >= OS.buildVERSION (2, 2, 0)) && gnome_init()) { desktop = DESKTOP_GNOME; int icon_theme = cast(int)GNOME.gnome_icon_theme_new(); - display.setData(ICON_THEME_DATA, new ValueWrapperInt(icon_theme)); + display.setData(ICON_THEME_DATA, new Integer(icon_theme)); display.addListener(SWT.Dispose, new class(display) Listener { Display display; this( Display display ){ this.display = display; } public void handleEvent(Event event) { - ValueWrapperInt gnomeIconTheme = cast(ValueWrapperInt)display.getData(ICON_THEME_DATA); + Integer gnomeIconTheme = cast(Integer)display.getData(ICON_THEME_DATA); if (gnomeIconTheme is null) return; display.setData(ICON_THEME_DATA, null); /* @@ -306,7 +306,7 @@ } +/ - display.setData(DESKTOP_DATA, new ValueWrapperInt(desktop)); + display.setData(DESKTOP_DATA, new Integer(desktop)); return desktop; } @@ -688,7 +688,7 @@ program.gnomeExpectUri = application.expects_uris is GNOME.GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS; buffer = (fromStringz( application.id) ~ '\0')._idup(); - ValueWrapperInt gnomeIconTheme = cast(ValueWrapperInt)display.getData(ICON_THEME_DATA); + Integer gnomeIconTheme = cast(Integer)display.getData(ICON_THEME_DATA); char* icon_name = GNOME.gnome_icon_lookup( cast(GtkIconTheme*) gnomeIconTheme.value, null, null, cast(char*)buffer.ptr, null, mimeTypeBuffer, GNOME.GNOME_ICON_LOOKUP_FLAGS_NONE, null); char* path = null; diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/accessibility/Accessible.d --- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/accessibility/Accessible.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/accessibility/Accessible.d Sat Apr 18 13:58:35 2009 +0200 @@ -1141,8 +1141,8 @@ nextItems = new Object[endIndex - enumIndex + 1]; for (int i = 0; i < nextItems.length; i++) { Object child = variants[enumIndex]; - if (auto val = cast(ValueWrapperInt)child ) { - nextItems[i] = new ValueWrapperInt(childIDToOs(val.value)); + if (auto val = cast(Integer)child ) { + nextItems[i] = new Integer(childIDToOs(val.intValue())); } else { nextItems[i] = child; } @@ -1153,8 +1153,8 @@ if (nextItems !is null) { for (int i = 0; i < nextItems.length; i++) { Object nextItem = nextItems[i]; - if (auto val = cast(ValueWrapperInt)nextItem ) { - int item = val.value; + if (auto val = cast(Integer)nextItem ) { + int item = val.intValue(); rgvar[i].vt = COM.VT_I4; rgvar[i].byRef = cast(void*)item; COM.MoveMemory(rgvar + i * VARIANT.sizeof + 8, &item, 4); diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/printing/PrintDialog.d --- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/printing/PrintDialog.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/printing/PrintDialog.d Sat Apr 18 13:58:35 2009 +0200 @@ -300,7 +300,7 @@ PrinterData data = null; String key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ Object oldValue = display.getData(key); - display.setData(key, new ValueWrapperBool(true)); + display.setData(key, new Boolean(true)); bool success = cast(bool)OS.PrintDlg(&pd); display.setData(key, oldValue); if ((getStyle() & (SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) !is 0) { diff -r 6be48cf9f95c -r 12b890a6392a org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Display.d --- a/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Display.d Sat Apr 18 13:54:50 2009 +0200 +++ b/org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Display.d Sat Apr 18 13:58:35 2009 +0200 @@ -1654,7 +1654,7 @@ // SWT extension: allow null string //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { - return new ValueWrapperBool(runMessagesInIdle); + return new Boolean(runMessagesInIdle); } if (key.equals (RUN_MESSAGES_IN_MESSAGE_PROC_KEY)) { return new Boolean (runMessagesInMessageProc); @@ -4130,7 +4130,7 @@ //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { - auto data = cast(ValueWrapperBool) value; + auto data = cast(Boolean) value; runMessagesInIdle = data !is null && data.value; return; } diff -r 6be48cf9f95c -r 12b890a6392a rakefile --- a/rakefile Sat Apr 18 13:54:50 2009 +0200 +++ b/rakefile Sat Apr 18 13:58:35 2009 +0200 @@ -70,7 +70,7 @@ end LIBNAMES_SWT = [ BASEDIR_SWT ] -LIBNAMES_EQUINOX = [ "org.eclipse.osgi", +LIBNAMES_EQUINOX = [ "org.eclipse.osgi.osgi", "org.eclipse.osgi.supplement", "org.eclipse.equinox.common" ] @@ -306,7 +306,7 @@ desc "Build Equinox" task :equinox do - buildTree( "org.eclipse.osgi", "src", "res" ) + buildTree( "org.eclipse.osgi", "osgi/src" , "res", nil, "org.eclipse.osgi.osgi" ) buildTree( "org.eclipse.osgi", "supplement/src", "res", nil, "org.eclipse.osgi.supplement") buildTree( "org.eclipse.equinox.common", "src", "res" ) end @@ -318,8 +318,13 @@ buildTree( "org.eclipse.core.jobs", "src", "res" ) end +desc "Build Jface Databinding" +task :jfacebind do + buildTree( "org.eclipse.jface.databinding", "src", "res" ) +end desc "Build Databinding" task :bind do + buildTree( "com.ibm.icu", "src", "res" ) buildTree( "org.eclipse.core.databinding", "src", "res" ) buildTree( "org.eclipse.jface.databinding", "src", "res" ) end