Mercurial > projects > dwt2
diff org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTracker.d @ 105:bbe49769ec18
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 08 Nov 2009 12:42:30 +0100 |
parents | 12b890a6392a |
children |
line wrap: on
line diff
--- a/org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTracker.d Sat May 02 11:27:24 2009 +0200 +++ b/org.eclipse.osgi/osgi/src/org/osgi/util/tracker/ServiceTracker.d Sun Nov 08 12:42:30 2009 +0100 @@ -1,8 +1,8 @@ /* * $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 @@ -16,21 +16,25 @@ * limitations under the License. */ +// Port to the D programming language: +// Frank Benoit <benoit@tionex.de> module org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; import java.lang.all; + +import org.osgi.util.tracker.ServiceTrackerCustomizer; // packageimport + 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.eclipse.osgi.framework.internal.core.FilterImpl; +import org.osgi.framework.AllServiceListener; import org.osgi.framework.BundleContext; -//FIXME tmp remove: import org.osgi.framework.Constants; +import org.osgi.framework.Constants; import org.osgi.framework.Filter; -//FIXME tmp remove: import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; @@ -58,7 +62,7 @@ * <code>ServiceTrackerCustomizer</code> object while holding any locks. * <code>ServiceTrackerCustomizer</code> implementations must also be * thread-safe. - * + * * @ThreadSafe * @version $Revision: 1.29 $ */ @@ -70,48 +74,8 @@ */ 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; + /* set this to true to compile in_ debug_ messages */ + static final bool DEBUG = false; /** * Bundle context against which this <code>ServiceTracker</code> object is * tracking. @@ -119,7 +83,7 @@ protected final BundleContext context; /** * Filter specifying search criteria for the services to track. - * + * * @since 1.1 */ protected final Filter filter; @@ -145,40 +109,40 @@ * True if no Filter object was supplied in a constructor or we are not * using the supplied filter. */ - final bool noUserFilter; + final bool noUserFilter; /** * Tracked services: <code>ServiceReference</code> object -> customized * Object and <code>ServiceListener</code> object */ - private volatile Tracked tracked; + 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; + private /+volatile+/ int trackingCount = -1; /** * Cached ServiceReference for getServiceReference. - * + * * This field is volatile since it is accessed by multiple threads. */ - private volatile ServiceReference cachedReference; + private /+volatile+/ ServiceReference cachedReference; /** * Cached service object for getService. - * + * * This field is volatile since it is accessed by multiple threads. */ - private volatile Object cachedService; + private /+volatile+/ Object cachedService; /** * Create a <code>ServiceTracker</code> object on the specified * <code>ServiceReference</code> object. - * + * * <p> * The service referenced by the specified <code>ServiceReference</code> * object will be tracked by this <code>ServiceTracker</code> object. - * + * * @param context <code>BundleContext</code> object against which the * tracking is done. * @param reference <code>ServiceReference</code> object for the service @@ -196,8 +160,8 @@ 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$ + this.customizer = (customizer is null) ? this : customizer; + this.listenerFilter = "(&(" + Constants.OBJECTCLASS + "=" + (stringcast( 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 { @@ -214,11 +178,11 @@ /** * Create a <code>ServiceTracker</code> object on the specified class * name. - * + * * <p> * Services registered under the specified class name will be tracked by * this <code>ServiceTracker</code> object. - * + * * @param context <code>BundleContext</code> object against which the * tracking is done. * @param clazz Class name of the services to be tracked. @@ -235,7 +199,7 @@ this.context = context; this.trackReference = null; this.trackClass = clazz; - this.customizer = (customizer == null) ? this : customizer; + this.customizer = (customizer is null) ? this : customizer; this.listenerFilter = "(" + Constants.OBJECTCLASS + "=" + clazz.toString() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ this.noUserFilter = true; try { @@ -252,11 +216,11 @@ /** * Create a <code>ServiceTracker</code> object on the specified * <code>Filter</code> object. - * + * * <p> * Services which match the specified <code>Filter</code> object will be * tracked by this <code>ServiceTracker</code> object. - * + * * @param context <code>BundleContext</code> object against which the * tracking is done. * @param filter <code>Filter</code> object to select the services to be @@ -275,24 +239,24 @@ this.trackReference = null; // obtain a required objectClass from the user supplied filter - if (filter instanceof FilterImpl) { - this.trackClass = ((FilterImpl)filter).getRequiredObjectClass(); + if ( null !is cast(FilterImpl)filter ) { + this.trackClass = (cast(FilterImpl)filter).getRequiredObjectClass(); } else { this.trackClass = null; } - - if (this.trackClass != null) { + + if (this.trackClass !is 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()); + //convert to track by class instead of filter if the user filter is in the form (objectClass=some.Clazz) + this.noUserFilter = this.listenerFilter.opEquals(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 + this.customizer = (customizer is null) ? this : customizer; + if ((context is null) || (filter is null)) { // we throw a NPE here // to // be consistent with the // other constructors @@ -303,14 +267,14 @@ /** * Open this <code>ServiceTracker</code> object and begin tracking * services. - * + * * <p> * This method calls <code>open(false)</code>. - * + * * @throws java.lang.IllegalStateException if the <code>BundleContext</code> * object with which this <code>ServiceTracker</code> object was * created is no longer valid. - * @see #open(bool) + * @see #open(boolean) */ public void open() { open(false); @@ -319,12 +283,12 @@ /** * Open this <code>ServiceTracker</code> object and begin tracking * services. - * + * * <p> * Services which match the search criteria specified when this * <code>ServiceTracker</code> object was created are now tracked by this * <code>ServiceTracker</code> object. - * + * * @param trackAllServices If <code>true</code>, then this * <code>ServiceTracker</code> will track all matching services * regardless of class loader accessibility. If <code>false</code>, @@ -338,11 +302,11 @@ * @since 1.3 */ public synchronized void open(bool trackAllServices) { - if (tracked != null) { + if (tracked !is null) { return; } if (DEBUG) { - System.out.println("ServiceTracker.open: " + filter); //$NON-NLS-1$ + System.out_.println("ServiceTracker.open: " + filter); //$NON-NLS-1$ } tracked = trackAllServices ? new AllTracked() : new Tracked(); trackingCount = 0; @@ -350,16 +314,16 @@ try { context.addServiceListener(tracked, listenerFilter); ServiceReference[] references; - - if (trackReference != null) { // tracking a single reference - references = new ServiceReference[] {trackReference}; + + if (trackReference !is null) { // tracking a single reference + references = [ cast(ServiceReference)trackReference]; } else { // tracking a set of references references = getInitialReferences(trackAllServices, trackClass, noUserFilter ? null: filter.toString()); } - tracked.setInitialServices(references); // set tracked with + tracked.setInitialServices(references); // set tracked with_ // the initial // references } @@ -375,7 +339,7 @@ /** * Returns the list of initial <code>ServiceReference</code> objects that * will be tracked by this <code>ServiceTracker</code> object. - * + * * @param trackAllServices If true, use getAllServiceReferences. * @param trackClass the class name with which the service was registered, * or null for all services. @@ -384,8 +348,7 @@ * @throws InvalidSyntaxException if the filter uses an invalid syntax. */ private ServiceReference[] getInitialReferences(bool trackAllServices, - String trackClass, String filterString) - throws InvalidSyntaxException { + String trackClass, String filterString) { if (trackAllServices) { return context.getAllServiceReferences(trackClass, filterString); } @@ -396,17 +359,17 @@ /** * Close this <code>ServiceTracker</code> object. - * + * * <p> * This method should be called when this <code>ServiceTracker</code> * object should end the tracking of services. */ public synchronized void close() { - if (tracked == null) { + if (tracked is null) { return; } if (DEBUG) { - System.out.println("ServiceTracker.close: " + filter); //$NON-NLS-1$ + System.out_.println("ServiceTracker.close: " + filter); //$NON-NLS-1$ } tracked.close(); ServiceReference[] references = getServiceReferences(); @@ -418,15 +381,15 @@ catch (IllegalStateException e) { /* In case the context was stopped. */ } - if (references != null) { - for (int i = 0; i < references.length; i++) { + if (references !is null) { + for (int i = 0; i < references.length_; i++) { outgoing.untrack(references[i]); } } trackingCount = -1; if (DEBUG) { - if ((cachedReference == null) && (cachedService == null)) { - System.out + if ((cachedReference is null) && (cachedService is null)) { + System.out_ .println("ServiceTracker.close[cached cleared]: " + filter); //$NON-NLS-1$ } } @@ -435,12 +398,12 @@ /** * Default implementation of the * <code>ServiceTrackerCustomizer.addingService</code> method. - * + * * <p> * This method is only called when this <code>ServiceTracker</code> object * has been constructed with a <code>null ServiceTrackerCustomizer</code> * argument. - * + * * The default implementation returns the result of calling * <code>getService</code>, on the <code>BundleContext</code> object * with which this <code>ServiceTracker</code> object was created, passing @@ -450,7 +413,7 @@ * 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 * <code>ServiceTracker</code> object. * @return The service object to be tracked for the service added to this @@ -464,14 +427,14 @@ /** * Default implementation of the * <code>ServiceTrackerCustomizer.modifiedService</code> method. - * + * * <p> * This method is only called when this <code>ServiceTracker</code> object * has been constructed with a <code>null ServiceTrackerCustomizer</code> * argument. - * + * * The default implementation does nothing. - * + * * @param reference Reference to modified service. * @param service The service object for the modified service. * @see ServiceTrackerCustomizer @@ -482,12 +445,12 @@ /** * Default implementation of the * <code>ServiceTrackerCustomizer.removedService</code> method. - * + * * <p> * This method is only called when this <code>ServiceTracker</code> object * has been constructed with a <code>null ServiceTrackerCustomizer</code> * argument. - * + * * The default implementation calls <code>ungetService</code>, on the * <code>BundleContext</code> object with which this * <code>ServiceTracker</code> object was created, passing the specified @@ -496,7 +459,7 @@ * This method can be overridden in a subclass. If the default * implementation of <code>addingService</code> 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 @@ -513,7 +476,7 @@ * during the calling of the <code>BundleActivator</code> methods. * <code>BundleActivator</code> 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 <code>getService()</code>. @@ -521,21 +484,21 @@ * current thread. * @throws IllegalArgumentException If the value of timeout is negative. */ - public Object waitForService(long timeout) throws InterruptedException { + public Object waitForService(long timeout) { if (timeout < 0) { - throw new IllegalArgumentException("timeout value is negative"); //$NON-NLS-1$ + throw new IllegalArgumentException("timeout value is_ negative"); //$NON-NLS-1$ } Object object = getService(); - while (object == null) { + while (object is null) { Tracked tracked = this.tracked; /* * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return null; } synchronized (tracked) { - if (tracked.size() == 0) { + if (tracked.size() is 0) { tracked.wait(timeout); } } @@ -550,7 +513,7 @@ /** * Return an array of <code>ServiceReference</code> objects for all * services being tracked by this <code>ServiceTracker</code> object. - * + * * @return Array of <code>ServiceReference</code> objects or * <code>null</code> if no service are being tracked. */ @@ -559,18 +522,18 @@ * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return null; } synchronized (tracked) { - int length = tracked.size(); - if (length == 0) { + int length_ = tracked.size(); + if (length_ is 0) { return null; } - ServiceReference[] references = new ServiceReference[length]; + ServiceReference[] references = new ServiceReference[length_]; Enumeration keys = tracked.keys(); - for (int i = 0; i < length; i++) { - references[i] = (ServiceReference) keys.nextElement(); + for (int i = 0; i < length_; i++) { + references[i] = cast(ServiceReference) keys.nextElement(); } return references; } @@ -579,12 +542,12 @@ /** * Returns a <code>ServiceReference</code> object for one of the services * being tracked by this <code>ServiceTracker</code> object. - * + * * <p> * If multiple services are being tracked, the service with the highest * ranking (as specified in its <code>service.ranking</code> property) is * returned. - * + * * <p> * If there is a tie in ranking, the service with the lowest service ID (as * specified in its <code>service.id</code> property); that is, the @@ -592,39 +555,39 @@ * <p> * This is the same algorithm used by * <code>BundleContext.getServiceReference</code>. - * + * * @return <code>ServiceReference</code> object or <code>null</code> if * no service is being tracked. * @since 1.1 */ public ServiceReference getServiceReference() { ServiceReference reference = cachedReference; - if (reference != null) { + if (reference !is null) { if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.getServiceReference[cached]: " + filter); //$NON-NLS-1$ } return reference; } if (DEBUG) { - System.out.println("ServiceTracker.getServiceReference: " + filter); //$NON-NLS-1$ + 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 */ + int length_ = (references is null) ? 0 : references.length_; + if (length_ is 0) /* if no service is_ being tracked */ { return null; } int index = 0; - if (length > 1) /* if more than one service, select highest ranking */ + if (length_ > 1) /* if more than one service, select highest ranking */ { - int rankings[] = new int[length]; + int rankings[] = new int[length_]; int count = 0; int maxRanking = Integer.MIN_VALUE; - for (int i = 0; i < length; i++) { + for (int i = 0; i < length_; i++) { Object property = references[i] .getProperty(Constants.SERVICE_RANKING); - int ranking = (property instanceof Integer) ? ((Integer) property) + int ranking = ( null !is cast(Integer)property ) ? (cast(Integer) property) .intValue() : 0; rankings[i] = ranking; @@ -634,7 +597,7 @@ count = 1; } else { - if (ranking == maxRanking) { + if (ranking is maxRanking) { count++; } } @@ -642,9 +605,9 @@ 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] + for (int i = 0; i < length_; i++) { + if (rankings[i] is maxRanking) { + long id = (cast(Long) (references[i] .getProperty(Constants.SERVICE_ID))) .longValue(); if (id < minId) { @@ -662,7 +625,7 @@ * Returns the service object for the specified * <code>ServiceReference</code> object if the referenced service is being * tracked by this <code>ServiceTracker</code> object. - * + * * @param reference Reference to the desired service. * @return Service object or <code>null</code> if the service referenced * by the specified <code>ServiceReference</code> object is not @@ -673,7 +636,7 @@ * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return null; } synchronized (tracked) { @@ -684,7 +647,7 @@ /** * Return an array of service objects for all services being tracked by this * <code>ServiceTracker</code> object. - * + * * @return Array of service objects or <code>null</code> if no service are * being tracked. */ @@ -693,17 +656,17 @@ * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return null; } synchronized (tracked) { ServiceReference[] references = getServiceReferences(); - int length = (references == null) ? 0 : references.length; - if (length == 0) { + int length_ = (references is null) ? 0 : references.length_; + if (length_ is 0) { return null; } - Object[] objects = new Object[length]; - for (int i = 0; i < length; i++) { + Object[] objects = new Object[length_]; + for (int i = 0; i < length_; i++) { objects[i] = getService(references[i]); } return objects; @@ -713,28 +676,28 @@ /** * Returns a service object for one of the services being tracked by this * <code>ServiceTracker</code> object. - * + * * <p> * If any services are being tracked, this method returns the result of * calling <code>getService(getServiceReference())</code>. - * + * * @return Service object or <code>null</code> if no service is being * tracked. */ public Object getService() { Object service = cachedService; - if (service != null) { + if (service !is null) { if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.getService[cached]: " + filter); //$NON-NLS-1$ } return service; } if (DEBUG) { - System.out.println("ServiceTracker.getService: " + filter); //$NON-NLS-1$ + System.out_.println("ServiceTracker.getService: " + filter); //$NON-NLS-1$ } ServiceReference reference = getServiceReference(); - if (reference == null) { + if (reference is null) { return null; } return cachedService = getService(reference); @@ -742,12 +705,12 @@ /** * Remove a service from this <code>ServiceTracker</code> object. - * + * * The specified service will be removed from this * <code>ServiceTracker</code> object. If the specified service was being * tracked then the <code>ServiceTrackerCustomizer.removedService</code> * method will be called for that service. - * + * * @param reference Reference to the service to be removed. */ public void remove(ServiceReference reference) { @@ -755,7 +718,7 @@ * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return; } tracked.untrack(reference); @@ -764,7 +727,7 @@ /** * Return the number of services being tracked by this * <code>ServiceTracker</code> object. - * + * * @return Number of services being tracked. */ public int size() { @@ -772,7 +735,7 @@ * use local var since we are not * synchronized */ - if (tracked == null) { /* if ServiceTracker is not open */ + if (tracked is null) { /* if ServiceTracker is_ not open */ return 0; } return tracked.size(); @@ -780,12 +743,12 @@ /** * Returns the tracking count for this <code>ServiceTracker</code> object. - * + * * The tracking count is initialized to 0 when this * <code>ServiceTracker</code> object is opened. Every time a service is * added, modified or removed from this <code>ServiceTracker</code> object * the tracking count is incremented. - * + * * <p> * The tracking count can be used to determine if this * <code>ServiceTracker</code> object has added, modified or removed a @@ -794,7 +757,7 @@ * service has been added, modified or removed from this * <code>ServiceTracker</code> object since the previous tracking count * was collected. - * + * * @since 1.2 * @return The tracking count for this <code>ServiceTracker</code> object * or -1 if this <code>ServiceTracker</code> object is not open. @@ -806,7 +769,7 @@ /** * Called by the Tracked object whenever the set of tracked services is * modified. Increments the tracking count and clears the cache. - * + * * @GuardedBy tracked */ /* @@ -819,7 +782,7 @@ cachedReference = null; /* clear cached value */ cachedService = null; /* clear cached value */ if (DEBUG) { - System.out.println("ServiceTracker.modified: " + filter); //$NON-NLS-1$ + System.out_.println("ServiceTracker.modified: " + filter); //$NON-NLS-1$ } } @@ -832,10 +795,10 @@ * 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 <code>ServiceTracker</code> class. - * + * * @ThreadSafe */ - class Tracked extends Hashtable implements ServiceListener { + class Tracked : Hashtable , ServiceListener { static final long serialVersionUID = -7420065199791006079L; /** * List of ServiceReferences in the process of being added. This is used @@ -845,22 +808,22 @@ * 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; + private /+volatile+/ bool closed; /** * Initial list of ServiceReferences for the tracker. This is used to @@ -869,15 +832,15 @@ * 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; @@ -885,7 +848,7 @@ /** * Tracked constructor. */ - protected Tracked() { + protected this() { super(); closed = false; adding = new ArrayList(6); @@ -895,22 +858,22 @@ /** * 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) { + if (references is null) { return; } - int size = references.length; + int size = references.length_; for (int i = 0; i < size; i++) { if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.setInitialServices: " + references[i]); //$NON-NLS-1$ } initial.add(references[i]); @@ -920,16 +883,16 @@ /** * 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 (initial.size() is 0) { /* * if there are no more inital services */ @@ -939,11 +902,11 @@ * 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) { + reference = cast(ServiceReference) initial.removeFirst(); + if (this.get(reference) !is null) { /* if we are already tracking this service */ if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.trackInitialServices[already tracked]: " + reference); //$NON-NLS-1$ } continue; /* skip this service */ @@ -954,7 +917,7 @@ * added. */ if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.trackInitialServices[already adding]: " + reference); //$NON-NLS-1$ } continue; /* skip this service */ @@ -962,7 +925,7 @@ adding.add(reference); } if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.trackInitialServices: " + reference); //$NON-NLS-1$ } trackAdding(reference); /* @@ -985,7 +948,7 @@ * <code>ServiceListener</code> method for the * <code>ServiceTracker</code> class. This method must NOT be * synchronized to avoid deadlock potential. - * + * * @param event <code>ServiceEvent</code> object from the framework. */ public void serviceChanged(ServiceEvent event) { @@ -998,7 +961,7 @@ } ServiceReference reference = event.getServiceReference(); if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -1041,7 +1004,7 @@ /** * Begin to track the referenced service. - * + * * @param reference Reference to a service to be tracked. */ private void track(ServiceReference reference) { @@ -1049,10 +1012,10 @@ synchronized (this) { object = this.get(reference); } - if (object != null) /* we are already tracking the service */ + if (object !is null) /* we are already tracking the service */ { if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.track[modified]: " + reference); //$NON-NLS-1$ } synchronized (this) { @@ -1073,12 +1036,12 @@ * being added. */ if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.track[already adding]: " + reference); //$NON-NLS-1$ } return; } - adding.add(reference); /* mark this service is being added */ + adding.add(reference); /* mark this service is_ being added */ } trackAdding(reference); /* @@ -1091,12 +1054,12 @@ * 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 + System.out_ .println("ServiceTracker.Tracked.trackAdding: " + reference); //$NON-NLS-1$ } Object object = null; @@ -1116,7 +1079,7 @@ * untracked during the * customizer callback */ - if (object != null) { + if (object !is null) { this.put(reference, object); modified(); /* increment modification count */ notifyAll(); /* @@ -1135,7 +1098,7 @@ */ if (becameUntracked) { if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.trackAdding[removed]: " + reference); //$NON-NLS-1$ } /* Call customizer outside of synchronized region */ @@ -1149,7 +1112,7 @@ /** * Discontinue tracking the referenced service. - * + * * @param reference Reference to the tracked service. */ protected void untrack(ServiceReference reference) { @@ -1162,7 +1125,7 @@ * process */ if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.untrack[removed from initial]: " + reference); //$NON-NLS-1$ } return; /* @@ -1176,7 +1139,7 @@ * process of being added */ if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.untrack[being added]: " + reference); //$NON-NLS-1$ } return; /* @@ -1189,13 +1152,13 @@ * before calling customizer * callback */ - if (object == null) { /* are we actually tracking the service */ + if (object is null) { /* are we actually tracking the service */ return; } modified(); /* increment modification count */ } if (DEBUG) { - System.out + System.out_ .println("ServiceTracker.Tracked.untrack[removed]: " + reference); //$NON-NLS-1$ } /* Call customizer outside of synchronized region */ @@ -1210,21 +1173,18 @@ /** * 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 { + class AllTracked : Tracked , AllServiceListener { static final long serialVersionUID = 4050764875305137716L; /** * AllTracked constructor. */ - protected AllTracked() { + protected this() { super(); } } } -+++/ - -