FELIX-4590 : [Core R6] Update to R6 API
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1614569 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/osgi/util/tracker/ServiceTracker.java b/framework/src/main/java/org/osgi/util/tracker/ServiceTracker.java
index 0c8022d..3ba97ab 100644
--- a/framework/src/main/java/org/osgi/util/tracker/ServiceTracker.java
+++ b/framework/src/main/java/org/osgi/util/tracker/ServiceTracker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2000, 2012). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2000, 2014). 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.
@@ -52,7 +52,7 @@
* @param <S> The type of the service being tracked.
* @param <T> The type of the tracked object.
* @ThreadSafe
- * @version $Id: 21926ad8717a91633face6bbf570febfcd23b1c7 $
+ * @author $Id: a0af979aa9c88a89f220c1b2d8d7c060ced41006 $
*/
public class ServiceTracker<S, T> implements ServiceTrackerCustomizer<S, T> {
/* set this to true to compile in debug messages */
@@ -298,6 +298,7 @@
} else {
if (trackReference != null) {
if (trackReference.getBundle() != null) {
+ @SuppressWarnings("unchecked")
ServiceReference<S>[] single = new ServiceReference[] {trackReference};
references = single;
}
@@ -331,6 +332,7 @@
* invalid syntax.
*/
private ServiceReference<S>[] getInitialReferences(boolean trackAllServices, String className, String filterString) throws InvalidSyntaxException {
+ @SuppressWarnings("unchecked")
ServiceReference<S>[] result = (ServiceReference<S>[]) ((trackAllServices) ? context.getAllServiceReferences(className, filterString) : context.getServiceReferences(className, filterString));
return result;
}
@@ -408,6 +410,7 @@
* @see ServiceTrackerCustomizer#addingService(ServiceReference)
*/
public T addingService(ServiceReference<S> reference) {
+ @SuppressWarnings("unchecked")
T result = (T) context.getService(reference);
return result;
}
@@ -527,6 +530,7 @@
if (length == 0) {
return null;
}
+ @SuppressWarnings("unchecked")
ServiceReference<S>[] result = new ServiceReference[length];
return t.copyKeys(result);
}
@@ -540,7 +544,7 @@
* If multiple services are being tracked, the service with the highest
* ranking (as specified in its {@code service.ranking} property) is
* returned. If there is a tie in ranking, the service with the lowest
- * service ID (as specified in its {@code service.id} property); that is,
+ * service id (as specified in its {@code service.id} property); that is,
* the service that was registered first is returned. This is the same
* algorithm used by {@code BundleContext.getServiceReference}.
*
@@ -843,7 +847,9 @@
return array;
}
if (length > array.length) {
- array = (T[]) Array.newInstance(array.getClass().getComponentType(), length);
+ @SuppressWarnings("unchecked")
+ T[] newInstance = (T[]) Array.newInstance(array.getClass().getComponentType(), length);
+ array = newInstance;
}
for (int i = 0; i < length; i++) {
array[i] = getService(references[i]);
@@ -883,6 +889,7 @@
if (closed) {
return;
}
+ @SuppressWarnings("unchecked")
final ServiceReference<S> reference = (ServiceReference<S>) event.getServiceReference();
if (DEBUG) {
System.out.println("ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference);
@@ -914,6 +921,7 @@
*
* @GuardedBy this
*/
+ @Override
final void modified() {
super.modified(); /* increment the modification count */
ServiceTracker.this.modified();
@@ -928,6 +936,7 @@
* @return Customized object for the tracked item or {@code null} if the
* item is not to be tracked.
*/
+ @Override
final T customizerAdding(final ServiceReference<S> item, final ServiceEvent related) {
return customizer.addingService(item);
}
@@ -940,6 +949,7 @@
* @param related Action related object.
* @param object Customized object for the tracked item.
*/
+ @Override
final void customizerModified(final ServiceReference<S> item, final ServiceEvent related, final T object) {
customizer.modifiedService(item, object);
}
@@ -952,6 +962,7 @@
* @param related Action related object.
* @param object Customized object for the tracked item.
*/
+ @Override
final void customizerRemoved(final ServiceReference<S> item, final ServiceEvent related, final T object) {
customizer.removedService(item, object);
}