Removes some generics warnings in SpringUtils, CoreBundleActivator and ServiceReferenceTracker
diff --git a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/CoreBundleActivator.java b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/CoreBundleActivator.java
index b20dff6..c25ca63 100644
--- a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/CoreBundleActivator.java
+++ b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/CoreBundleActivator.java
@@ -142,7 +142,7 @@
BundleStartTracker asynchronousStartTracker = new BundleStartTracker(executor);
asynchronousStartTracker.initialize(context);
- Dictionary properties = new Hashtable();
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put(EventConstants.EVENT_TOPIC, new String[] {EVENT_TOPIC_BLUEPRINT_CONTAINER, EVENT_TOPIC_REGION});
this.tracker.track(context.registerService(new String[] {EventHandler.class.getName()}, asynchronousStartTracker, properties));
@@ -154,7 +154,7 @@
private BundleStarter createAndRegisterBundleStarter(BundleStartTracker asynchronousStartTracker, BundleContext bundleContext) {
StandardBundleStarter bundleStarter = new StandardBundleStarter(asynchronousStartTracker);
- Dictionary properties = new Hashtable();
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put(PROPERTY_NAME_SERVICE_SCOPE, SERVICE_SCOPE_GLOBAL);
this.tracker.track(bundleContext.registerService(new String[] {BundleStarter.class.getName()}, bundleStarter, properties));
@@ -223,12 +223,11 @@
this.tracker.track(context.registerService(TracingService.class.getName(), tracingService, null));
}
- @SuppressWarnings("unchecked")
private <T> T getRequiredService(BundleContext context, Class<T> clazz) {
T result = null;
- ServiceReference ref = context.getServiceReference(clazz.getName());
+ ServiceReference<T> ref = context.getServiceReference(clazz);
if (ref != null) {
- result = (T) context.getService(ref);
+ result = context.getService(ref);
}
if (result == null) {
throw new IllegalStateException("Unable to access required service of type '" + clazz.getName() + "' from bundle '"
diff --git a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/ServiceReferenceTracker.java b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/ServiceReferenceTracker.java
index db7b159..2db665d 100644
--- a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/ServiceReferenceTracker.java
+++ b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/ServiceReferenceTracker.java
@@ -35,7 +35,7 @@
private final Object monitor = new Object();
- private Set<ServiceReference> references; // protected by monitor.
+ private Set<ServiceReference<?>> references; // protected by monitor.
ServiceReferenceTracker(BundleContext context) {
@@ -49,10 +49,10 @@
* @param reference the <code>ServiceReference</code> to track.
* @return the reference itself
*/
- public ServiceReference track(ServiceReference reference) {
+ public ServiceReference<?> track(ServiceReference<?> reference) {
synchronized (this.monitor) {
if (this.references == null) {
- this.references = new HashSet<ServiceReference>();
+ this.references = new HashSet<ServiceReference<?>>();
}
this.references.add(reference);
}
@@ -63,13 +63,13 @@
* Safely unregisters all the tracked <code>ServiceRegistrations</code>.
*/
public void ungetAll() {
- Set<ServiceReference> toUnget = null;
+ Set<ServiceReference<?>> toUnget = null;
synchronized (this.monitor) {
toUnget = this.references;
this.references = null;
}
if (toUnget != null) {
- for (ServiceReference serviceReference : toUnget) {
+ for (ServiceReference<?> serviceReference : toUnget) {
try {
this.context.ungetService(serviceReference);
} catch (IllegalStateException e) {
diff --git a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/SpringUtils.java b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/SpringUtils.java
index ce6f528..228734a 100644
--- a/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/SpringUtils.java
+++ b/org.eclipse.virgo.nano.core/src/main/java/org/eclipse/virgo/nano/core/internal/SpringUtils.java
@@ -1,6 +1,7 @@
package org.eclipse.virgo.nano.core.internal;
+import java.net.URL;
import java.util.Dictionary;
import java.util.Enumeration;
@@ -44,7 +45,7 @@
// if no location is specified in the header, try the defaults
if (isArrayEmpty(locations)) {
// check the default locations if the manifest doesn't provide any info
- Enumeration defaultConfig = bundle.findEntries(SPRING_DM_CONTEXT_DIR, CONTEXT_FILES, false);
+ Enumeration<URL> defaultConfig = bundle.findEntries(SPRING_DM_CONTEXT_DIR, CONTEXT_FILES, false);
if (defaultConfig != null && defaultConfig.hasMoreElements()) {
return new String[] { SPRING_DM_DEFAULT_CONFIG };
} else {
@@ -67,7 +68,7 @@
* @param headers bundle headers
* @return array of locations specified (if any)
*/
- static String[] getSpringContextHeaderLocations(Dictionary headers) {
+ static String[] getSpringContextHeaderLocations(Dictionary<String, String> headers) {
String header = getSpringContextHeader(headers);
String[] ctxEntries;
if (StringUtils.hasText(header) && !(';' == header.charAt(0))) {
diff --git a/org.eclipse.virgo.nano.core/src/test/java/org/eclipse/virgo/nano/core/internal/SpringUtilsTests.java b/org.eclipse.virgo.nano.core/src/test/java/org/eclipse/virgo/nano/core/internal/SpringUtilsTests.java
index ddc4d9f..34d9248 100644
--- a/org.eclipse.virgo.nano.core/src/test/java/org/eclipse/virgo/nano/core/internal/SpringUtilsTests.java
+++ b/org.eclipse.virgo.nano.core/src/test/java/org/eclipse/virgo/nano/core/internal/SpringUtilsTests.java
@@ -16,7 +16,7 @@
import static org.junit.Assert.assertTrue;
import java.util.Dictionary;
-import java.util.Properties;
+import java.util.Hashtable;
import org.eclipse.virgo.test.stubs.framework.StubBundle;
import org.junit.Test;
@@ -26,7 +26,7 @@
@Test
public void successfulGetSpringContextHeader() throws Exception {
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("Spring-Context", "testValue");
dict.put("aHeader", "aValue");
@@ -38,7 +38,7 @@
@Test
public void failedGetSpringContextHeader() {
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("aHeader", "aValue");
String result = SpringUtils.getSpringContextHeader(dict);
@@ -48,7 +48,7 @@
@Test
public void successfulGetBundleBlueprintHeader() throws Exception {
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("Bundle-Blueprint", "testValue");
dict.put("aHeader", "aValue");
@@ -60,7 +60,7 @@
@Test
public void failedGetBundleBlueprintHeader() {
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("aHeader", "aValue");
String result = SpringUtils.getBundleBlueprintHeader(dict);
@@ -83,7 +83,7 @@
@Test
public void testGetSpringContextHeaderLocations() {
//try single location
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("Spring-Context", "testValue");
dict.put("aHeader", "aValue");
@@ -92,7 +92,7 @@
assertEquals("testValue", locations[0]);
//try with 1+ locations
- dict = new Properties();
+ dict = new Hashtable<String, String>();
dict.put("Spring-Context", "testValue1,testValue2");
dict.put("aHeader", "aValue");
@@ -105,16 +105,16 @@
@Test
public void testGetBundleBlueprintHeaderLocations() {
//try single location
- Dictionary dict = new Properties();
+ Dictionary<String, String> dict = new Hashtable<String, String>();
dict.put("Bundle-Blueprint", "testValue");
dict.put("aHeader", "aValue");
-
+
String[] locations = SpringUtils.getSpringContextHeaderLocations(dict);
assertEquals(1, locations.length);
assertEquals("testValue", locations[0]);
//try with 1+ locations
- dict = new Properties();
+ dict = new Hashtable<String, String>();
dict.put("Bundle-Blueprint", "testValue1,testValue2");
dict.put("aHeader", "aValue");