Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2013-06-25 19:45:50 +0000
committerThomas Watson2013-08-09 20:31:13 +0000
commitbb85ea1fe005e4e2e33c486929f70c0c8bcdd46e (patch)
tree13a1fd2e76d96181941e337095b7dbca0dd77fe7 /bundles/org.eclipse.equinox.cm/src
parent6d0fcdf21a9911cbadaef844b344fdc383c57969 (diff)
downloadrt.equinox.bundles-bb85ea1fe005e4e2e33c486929f70c0c8bcdd46e.tar.gz
rt.equinox.bundles-bb85ea1fe005e4e2e33c486929f70c0c8bcdd46e.tar.xz
rt.equinox.bundles-bb85ea1fe005e4e2e33c486929f70c0c8bcdd46e.zip
Update CM impl to use Java 5.
Diffstat (limited to 'bundles/org.eclipse.equinox.cm/src')
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java18
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java13
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java49
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java23
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java24
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java39
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java23
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java23
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java45
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java45
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java40
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java6
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java20
-rw-r--r--bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java4
15 files changed, 184 insertions, 194 deletions
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java
index eef6f41be..0edeaab51 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Cognos Incorporated, IBM Corporation
+ * Copyright (c) 2006, 2013 Cognos Incorporated, IBM Corporation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,7 @@ import org.osgi.service.cm.ConfigurationAdmin;
public class Activator implements BundleActivator {
private static final String EVENT_ADMIN_CLASS = "org.osgi.service.event.EventAdmin"; //$NON-NLS-1$
private LogTracker logTracker;
- private ServiceRegistration registration;
+ private ServiceRegistration<ConfigurationAdmin> registration;
private ConfigurationAdminFactory factory;
private ConfigurationEventAdapter eventAdapter;
private static BundleContext bundleContext;
@@ -50,7 +50,7 @@ public class Activator implements BundleActivator {
factory = new ConfigurationAdminFactory(context, logTracker);
factory.start();
context.addBundleListener(factory);
- registration = context.registerService(ConfigurationAdmin.class.getName(), factory, null);
+ registration = context.registerService(ConfigurationAdmin.class, factory, null);
}
public void stop(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java
index a90d1ac10..d116c4454 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,25 +14,25 @@ package org.eclipse.equinox.internal.cm;
import java.security.Permission;
import java.util.Dictionary;
import org.osgi.framework.*;
+import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationPermission;
-import org.osgi.service.log.LogService;
/**
* ConfigurationAdminFactory provides a Configuration Admin ServiceFactory but more significantly
* launches the whole implementation.
*/
-public class ConfigurationAdminFactory implements ServiceFactory, BundleListener {
+public class ConfigurationAdminFactory implements ServiceFactory<ConfigurationAdmin>, BundleListener {
private final Permission configurationPermission = new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE); //$NON-NLS-1$
private final EventDispatcher eventDispatcher;
private final PluginManager pluginManager;
- private final LogService log;
+ private final LogTracker log;
private final ManagedServiceTracker managedServiceTracker;
private final ManagedServiceFactoryTracker managedServiceFactoryTracker;
private final ConfigurationStore configurationStore;
- public ConfigurationAdminFactory(BundleContext context, LogService log) {
+ public ConfigurationAdminFactory(BundleContext context, LogTracker log) {
this.log = log;
configurationStore = new ConfigurationStore(this, context);
eventDispatcher = new EventDispatcher(context, log);
@@ -55,13 +55,13 @@ public class ConfigurationAdminFactory implements ServiceFactory, BundleListener
pluginManager.stop();
}
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- ServiceReference reference = registration.getReference();
+ public ConfigurationAdmin getService(Bundle bundle, ServiceRegistration<ConfigurationAdmin> registration) {
+ ServiceReference<ConfigurationAdmin> reference = registration.getReference();
eventDispatcher.setServiceReference(reference);
return new ConfigurationAdminImpl(this, configurationStore, bundle);
}
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ public void ungetService(Bundle bundle, ServiceRegistration<ConfigurationAdmin> registration, ConfigurationAdmin service) {
// do nothing
}
@@ -102,7 +102,7 @@ public class ConfigurationAdminFactory implements ServiceFactory, BundleListener
managedServiceTracker.notifyDeleted(config);
}
- void modifyConfiguration(ServiceReference reference, Dictionary properties) {
+ void modifyConfiguration(ServiceReference<?> reference, Dictionary<String, Object> properties) {
pluginManager.modifyConfiguration(reference, properties);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
index 0b552cea1..38e85d2bd 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others..
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others..
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.cm;
-import java.io.IOException;
import org.osgi.framework.*;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -31,18 +30,18 @@ class ConfigurationAdminImpl implements ConfigurationAdmin {
this.bundle = bundle;
}
- public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
+ public Configuration createFactoryConfiguration(String factoryPid) {
checkPID(factoryPid);
return configurationStore.createFactoryConfiguration(factoryPid, bundle.getLocation());
}
- public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
+ public Configuration createFactoryConfiguration(String factoryPid, String location) {
checkPID(factoryPid);
this.configurationAdminFactory.checkConfigurationPermission();
return configurationStore.createFactoryConfiguration(factoryPid, location);
}
- public Configuration getConfiguration(String pid) throws IOException {
+ public Configuration getConfiguration(String pid) {
checkPID(pid);
ConfigurationImpl config = configurationStore.getConfiguration(pid, bundle.getLocation());
if (config.getBundleLocation(false) != null && !config.getBundleLocation(false).equals(bundle.getLocation()))
@@ -51,13 +50,13 @@ class ConfigurationAdminImpl implements ConfigurationAdmin {
return config;
}
- public Configuration getConfiguration(String pid, String location) throws IOException {
+ public Configuration getConfiguration(String pid, String location) {
checkPID(pid);
this.configurationAdminFactory.checkConfigurationPermission();
return configurationStore.getConfiguration(pid, location);
}
- public Configuration[] listConfigurations(String filterString) throws IOException, InvalidSyntaxException {
+ public Configuration[] listConfigurations(String filterString) throws InvalidSyntaxException {
if (filterString == null)
filterString = "(" + Constants.SERVICE_PID + "=*)"; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
index 380e0fb78..0c9e61117 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,25 +21,25 @@ import java.util.Map.Entry;
* requirements of the Configuration Admin Service specification.
*/
-public class ConfigurationDictionary extends Dictionary implements Serializable {
+public class ConfigurationDictionary extends Dictionary<String, Object> implements Serializable {
private static final long serialVersionUID = -3583299578203095532L;
- private static final Collection simples = Arrays.asList(new Class[] {String.class, Integer.class, Long.class, Float.class, Double.class, Byte.class, Short.class, Character.class, Boolean.class});
- private static final Collection simpleArrays = Arrays.asList(new Class[] {String[].class, Integer[].class, Long[].class, Float[].class, Double[].class, Byte[].class, Short[].class, Character[].class, Boolean[].class});
- private static final Collection primitiveArrays = Arrays.asList(new Class[] {long[].class, int[].class, short[].class, char[].class, byte[].class, double[].class, float[].class, boolean[].class});
+ private static final Collection<Class<?>> simples = Arrays.asList(new Class<?>[] {String.class, Integer.class, Long.class, Float.class, Double.class, Byte.class, Short.class, Character.class, Boolean.class});
+ private static final Collection<Class<?>> simpleArrays = Arrays.asList(new Class<?>[] {String[].class, Integer[].class, Long[].class, Float[].class, Double[].class, Byte[].class, Short[].class, Character[].class, Boolean[].class});
+ private static final Collection<Class<?>> primitiveArrays = Arrays.asList(new Class<?>[] {long[].class, int[].class, short[].class, char[].class, byte[].class, double[].class, float[].class, boolean[].class});
- static class CaseInsensitiveStringComparator implements Comparator, Serializable {
+ static class CaseInsensitiveStringComparator implements Comparator<String>, Serializable {
private static final long serialVersionUID = 6501536810492374044L;
- public int compare(Object o1, Object o2) {
- return ((String) o1).compareToIgnoreCase((String) o2);
+ public int compare(String s1, String s2) {
+ return (s1).compareToIgnoreCase(s2);
}
}
- protected final Map configurationProperties = Collections.synchronizedMap(new TreeMap(new CaseInsensitiveStringComparator()));
+ protected final Map<String, Object> configurationProperties = Collections.synchronizedMap(new TreeMap<String, Object>(new CaseInsensitiveStringComparator()));
private static void validateValue(Object value) {
- Class clazz = value.getClass();
+ Class<?> clazz = value.getClass();
// Is it in the set of simple types
if (simples.contains(clazz))
@@ -51,9 +51,9 @@ public class ConfigurationDictionary extends Dictionary implements Serializable
// Is it a Collection of simples
if (value instanceof Collection) {
- Collection valueCollection = (Collection) value;
- for (Iterator it = valueCollection.iterator(); it.hasNext();) {
- Class containedClazz = it.next().getClass();
+ Collection<?> valueCollection = (Collection<?>) value;
+ for (Iterator<?> it = valueCollection.iterator(); it.hasNext();) {
+ Class<?> containedClazz = it.next().getClass();
if (!simples.contains(containedClazz)) {
throw new IllegalArgumentException(containedClazz.getName() + " in " + clazz.getName()); //$NON-NLS-1$
}
@@ -63,9 +63,9 @@ public class ConfigurationDictionary extends Dictionary implements Serializable
throw new IllegalArgumentException(clazz.getName());
}
- public Enumeration elements() {
- return new Enumeration() {
- final Iterator valuesIterator = configurationProperties.values().iterator();
+ public Enumeration<Object> elements() {
+ return new Enumeration<Object>() {
+ final Iterator<Object> valuesIterator = configurationProperties.values().iterator();
public boolean hasMoreElements() {
return valuesIterator.hasNext();
@@ -87,21 +87,21 @@ public class ConfigurationDictionary extends Dictionary implements Serializable
return configurationProperties.isEmpty();
}
- public Enumeration keys() {
- return new Enumeration() {
- Iterator keysIterator = configurationProperties.keySet().iterator();
+ public Enumeration<String> keys() {
+ return new Enumeration<String>() {
+ Iterator<String> keysIterator = configurationProperties.keySet().iterator();
public boolean hasMoreElements() {
return keysIterator.hasNext();
}
- public Object nextElement() {
+ public String nextElement() {
return keysIterator.next();
}
};
}
- public Object put(Object key, Object value) {
+ public Object put(String key, Object value) {
if (key == null || value == null)
throw new NullPointerException();
@@ -123,9 +123,8 @@ public class ConfigurationDictionary extends Dictionary implements Serializable
ConfigurationDictionary copy() {
ConfigurationDictionary result = new ConfigurationDictionary();
- for (Iterator it = configurationProperties.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- Object key = entry.getKey();
+ for (Entry<String, Object> entry : configurationProperties.entrySet()) {
+ String key = entry.getKey();
Object value = entry.getValue();
if (value.getClass().isArray()) {
int arrayLength = Array.getLength(value);
@@ -133,7 +132,7 @@ public class ConfigurationDictionary extends Dictionary implements Serializable
System.arraycopy(value, 0, copyOfArray, 0, arrayLength);
result.configurationProperties.put(key, copyOfArray);
} else if (value instanceof Vector)
- result.configurationProperties.put(key, ((Vector) value).clone());
+ result.configurationProperties.put(key, ((Vector<?>) value).clone());
else
result.configurationProperties.put(key, value);
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java
index ee0c81541..64bda8e03 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 IBM Corporation.
+ * Copyright (c) 2007, 2013 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,7 @@ package org.eclipse.equinox.internal.cm;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.*;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
+import org.osgi.service.cm.*;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.util.tracker.ServiceTracker;
@@ -35,17 +34,17 @@ public class ConfigurationEventAdapter implements ConfigurationListener {
public static final String SERVICE_PID = "service.pid"; //$NON-NLS-1$
private final BundleContext context;
- private ServiceRegistration configListenerRegistration;
- private final ServiceTracker eventAdminTracker;
+ private ServiceRegistration<ConfigurationListener> configListenerRegistration;
+ private final ServiceTracker<EventAdmin, EventAdmin> eventAdminTracker;
public ConfigurationEventAdapter(BundleContext context) {
this.context = context;
- eventAdminTracker = new ServiceTracker(context, EventAdmin.class.getName(), null);
+ eventAdminTracker = new ServiceTracker<EventAdmin, EventAdmin>(context, EventAdmin.class, null);
}
public void start() throws Exception {
eventAdminTracker.open();
- configListenerRegistration = context.registerService(ConfigurationListener.class.getName(), this, null);
+ configListenerRegistration = context.registerService(ConfigurationListener.class, this, null);
}
public void stop() throws Exception {
@@ -55,7 +54,7 @@ public class ConfigurationEventAdapter implements ConfigurationListener {
}
public void configurationEvent(ConfigurationEvent event) {
- EventAdmin eventAdmin = (EventAdmin) eventAdminTracker.getService();
+ EventAdmin eventAdmin = eventAdminTracker.getService();
if (eventAdmin == null) {
return;
}
@@ -71,21 +70,21 @@ public class ConfigurationEventAdapter implements ConfigurationListener {
return;
}
String topic = TOPIC + TOPIC_SEPARATOR + typename;
- ServiceReference ref = event.getReference();
+ ServiceReference<ConfigurationAdmin> ref = event.getReference();
if (ref == null) {
throw new RuntimeException("ServiceEvent.getServiceReference() is null"); //$NON-NLS-1$
}
- Hashtable properties = new Hashtable();
+ Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(CM_PID, event.getPid());
if (event.getFactoryPid() != null) {
properties.put(CM_FACTORY_PID, event.getFactoryPid());
}
putServiceReferenceProperties(properties, ref);
- Event convertedEvent = new Event(topic, (Dictionary) properties);
+ Event convertedEvent = new Event(topic, (Dictionary<String, Object>) properties);
eventAdmin.postEvent(convertedEvent);
}
- public void putServiceReferenceProperties(Hashtable properties, ServiceReference ref) {
+ private void putServiceReferenceProperties(Hashtable<String, Object> properties, ServiceReference<?> ref) {
properties.put(SERVICE, ref);
properties.put(SERVICE_ID, ref.getProperty(org.osgi.framework.Constants.SERVICE_ID));
Object o = ref.getProperty(org.osgi.framework.Constants.SERVICE_PID);
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java
index 11b6ab947..f580921a8 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,7 +49,7 @@ class ConfigurationImpl implements Configuration {
this.bundleLocation = bundleLocation;
}
- public ConfigurationImpl(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, Dictionary dictionary) {
+ public ConfigurationImpl(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, Dictionary<String, ?> dictionary) {
this.configurationAdminFactory = configurationAdminFactory;
this.configurationStore = configurationStore;
pid = (String) dictionary.get(Constants.SERVICE_PID);
@@ -119,7 +119,7 @@ class ConfigurationImpl implements Configuration {
}
}
- public void delete() throws IOException {
+ public void delete() {
try {
lock();
checkDeleted();
@@ -187,14 +187,14 @@ class ConfigurationImpl implements Configuration {
return getPid(true);
}
- public Dictionary getProperties() {
+ public Dictionary<String, Object> getProperties() {
try {
lock();
checkDeleted();
if (dictionary == null)
return null;
- Dictionary copy = dictionary.copy();
+ Dictionary<String, Object> copy = dictionary.copy();
copy.put(Constants.SERVICE_PID, pid);
if (factoryPid != null)
copy.put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid);
@@ -205,12 +205,12 @@ class ConfigurationImpl implements Configuration {
}
}
- protected Dictionary getAllProperties() {
+ protected Dictionary<String, Object> getAllProperties() {
try {
lock();
if (deleted)
return null;
- Dictionary copy = getProperties();
+ Dictionary<String, Object> copy = getProperties();
if (copy == null)
return null;
String boundLocation = getBundleLocation(false);
@@ -247,7 +247,7 @@ class ConfigurationImpl implements Configuration {
}
}
- public void update(Dictionary properties) throws IOException {
+ public void update(Dictionary<String, ?> properties) throws IOException {
try {
lock();
checkDeleted();
@@ -260,11 +260,11 @@ class ConfigurationImpl implements Configuration {
}
}
- private void updateDictionary(Dictionary properties) {
+ private void updateDictionary(Dictionary<String, ?> properties) {
ConfigurationDictionary newDictionary = new ConfigurationDictionary();
- Enumeration keys = properties.keys();
+ Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
+ String key = keys.nextElement();
if (newDictionary.get(key) == null) {
Object value = properties.get(key);
if (value.getClass().isArray()) {
@@ -273,7 +273,7 @@ class ConfigurationImpl implements Configuration {
System.arraycopy(value, 0, copyOfArray, 0, arrayLength);
newDictionary.put(key, copyOfArray);
} else if (value instanceof Collection)
- newDictionary.put(key, new Vector((Collection) value));
+ newDictionary.put(key, new Vector<Object>((Collection<?>) value));
else
newDictionary.put(key, properties.get(key));
} else
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
index 41fca515f..4026b77ee 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,7 @@ class ConfigurationStore {
private final ConfigurationAdminFactory configurationAdminFactory;
private static final String STORE_DIR = "store"; //$NON-NLS-1$
private static final String PID_EXT = ".pid"; //$NON-NLS-1$
- private final Map configurations = new HashMap();
+ private final Map<String, ConfigurationImpl> configurations = new HashMap<String, ConfigurationImpl>();
private int createdPidCount = 0;
private final File store;
@@ -52,7 +52,8 @@ class ConfigurationStore {
try {
ris = new ReliableFileInputStream(configurationFiles[i]);
ois = new ObjectInputStream(ris);
- Dictionary dictionary = (Dictionary) ois.readObject();
+ @SuppressWarnings("unchecked")
+ Dictionary<String, Object> dictionary = (Dictionary<String, Object>) ois.readObject();
ConfigurationImpl config = new ConfigurationImpl(configurationAdminFactory, this, dictionary);
configurations.put(config.getPid(), config);
} catch (IOException e) {
@@ -92,9 +93,9 @@ class ConfigurationStore {
config.checkLocked();
final File configFile = new File(store, pid + PID_EXT);
- final Dictionary configProperties = config.getAllProperties();
+ final Dictionary<String, Object> configProperties = config.getAllProperties();
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
writeConfigurationFile(configFile, configProperties);
return null;
@@ -105,7 +106,7 @@ class ConfigurationStore {
}
}
- void writeConfigurationFile(File configFile, Dictionary configProperties) throws IOException {
+ void writeConfigurationFile(File configFile, Dictionary<String, Object> configProperties) throws IOException {
OutputStream ros = null;
ObjectOutputStream oos = null;
try {
@@ -136,7 +137,7 @@ class ConfigurationStore {
if (store == null)
return; // no persistent store
final File configFile = new File(store, pid + PID_EXT);
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
deleteConfigurationFile(configFile);
return null;
@@ -150,7 +151,7 @@ class ConfigurationStore {
}
public synchronized ConfigurationImpl getConfiguration(String pid, String location) {
- ConfigurationImpl config = (ConfigurationImpl) configurations.get(pid);
+ ConfigurationImpl config = configurations.get(pid);
if (config == null) {
config = new ConfigurationImpl(configurationAdminFactory, this, null, pid, location);
configurations.put(pid, config);
@@ -166,25 +167,25 @@ class ConfigurationStore {
}
public synchronized ConfigurationImpl findConfiguration(String pid) {
- return (ConfigurationImpl) configurations.get(pid);
+ return configurations.get(pid);
}
public synchronized ConfigurationImpl[] getFactoryConfigurations(String factoryPid) {
- List resultList = new ArrayList();
- for (Iterator it = configurations.values().iterator(); it.hasNext();) {
- ConfigurationImpl config = (ConfigurationImpl) it.next();
+ List<ConfigurationImpl> resultList = new ArrayList<ConfigurationImpl>();
+ for (Iterator<ConfigurationImpl> it = configurations.values().iterator(); it.hasNext();) {
+ ConfigurationImpl config = it.next();
String otherFactoryPid = config.getFactoryPid();
if (otherFactoryPid != null && otherFactoryPid.equals(factoryPid))
resultList.add(config);
}
- return (ConfigurationImpl[]) resultList.toArray(new ConfigurationImpl[0]);
+ return resultList.toArray(new ConfigurationImpl[resultList.size()]);
}
public synchronized ConfigurationImpl[] listConfigurations(Filter filter) {
- List resultList = new ArrayList();
- for (Iterator it = configurations.values().iterator(); it.hasNext();) {
- ConfigurationImpl config = (ConfigurationImpl) it.next();
- Dictionary properties = config.getAllProperties();
+ List<ConfigurationImpl> resultList = new ArrayList<ConfigurationImpl>();
+ for (Iterator<ConfigurationImpl> it = configurations.values().iterator(); it.hasNext();) {
+ ConfigurationImpl config = it.next();
+ Dictionary<String, Object> properties = config.getAllProperties();
if (properties != null && filter.match(properties))
resultList.add(config);
}
@@ -193,8 +194,8 @@ class ConfigurationStore {
}
public synchronized void unbindConfigurations(Bundle bundle) {
- for (Iterator it = configurations.values().iterator(); it.hasNext();) {
- ConfigurationImpl config = (ConfigurationImpl) it.next();
+ for (Iterator<ConfigurationImpl> it = configurations.values().iterator(); it.hasNext();) {
+ ConfigurationImpl config = it.next();
config.unbind(bundle);
}
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
index ad829622c..696725d81 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,7 @@ package org.eclipse.equinox.internal.cm;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.ConfigurationListener;
+import org.osgi.service.cm.*;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
@@ -25,15 +24,15 @@ import org.osgi.util.tracker.ServiceTracker;
*/
public class EventDispatcher {
- final ServiceTracker tracker;
+ final ServiceTracker<ConfigurationListener, ConfigurationListener> tracker;
private final SerializedTaskQueue queue = new SerializedTaskQueue("ConfigurationListener Event Queue"); //$NON-NLS-1$
/** @GuardedBy this */
- private ServiceReference configAdminReference;
- final LogService log;
+ private ServiceReference<ConfigurationAdmin> configAdminReference;
+ final LogTracker log;
- public EventDispatcher(BundleContext context, LogService log) {
+ public EventDispatcher(BundleContext context, LogTracker log) {
this.log = log;
- tracker = new ServiceTracker(context, ConfigurationListener.class.getName(), null);
+ tracker = new ServiceTracker<ConfigurationListener, ConfigurationListener>(context, ConfigurationListener.class, null);
}
public void start() {
@@ -47,7 +46,7 @@ public class EventDispatcher {
}
}
- synchronized void setServiceReference(ServiceReference reference) {
+ synchronized void setServiceReference(ServiceReference<ConfigurationAdmin> reference) {
if (configAdminReference == null)
configAdminReference = reference;
}
@@ -57,15 +56,15 @@ public class EventDispatcher {
if (event == null)
return;
- ServiceReference[] refs = tracker.getServiceReferences();
+ ServiceReference<ConfigurationListener>[] refs = tracker.getServiceReferences();
if (refs == null)
return;
for (int i = 0; i < refs.length; ++i) {
- final ServiceReference ref = refs[i];
+ final ServiceReference<ConfigurationListener> ref = refs[i];
queue.put(new Runnable() {
public void run() {
- ConfigurationListener listener = (ConfigurationListener) tracker.getService(ref);
+ ConfigurationListener listener = tracker.getService(ref);
if (listener == null) {
return;
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java
index 7e213a936..d3fd371aa 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2008 IBM Corporation and others.
+ * Copyright (c) 1998, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@ package org.eclipse.equinox.internal.cm;
import java.io.PrintStream;
import java.util.Calendar;
import java.util.Date;
-
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
@@ -24,7 +23,7 @@ import org.osgi.util.tracker.ServiceTracker;
* and handles all issues such as the service coming and going.
*/
-public class LogTracker extends ServiceTracker implements LogService {
+public class LogTracker extends ServiceTracker<LogService, LogService> {
/** LogService interface class name */
protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$
@@ -56,18 +55,18 @@ public class LogTracker extends ServiceTracker implements LogService {
log(null, level, message, exception);
}
- public void log(ServiceReference reference, int level, String message) {
+ public void log(ServiceReference<?> reference, int level, String message) {
log(reference, level, message, null);
}
- public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) {
- ServiceReference[] references = getServiceReferences();
+ public synchronized void log(ServiceReference<?> reference, int level, String message, Throwable exception) {
+ ServiceReference<LogService>[] references = getServiceReferences();
if (references != null) {
int size = references.length;
for (int i = 0; i < size; i++) {
- LogService service = (LogService) getService(references[i]);
+ LogService service = getService(references[i]);
if (service != null) {
try {
service.log(reference, level, message, exception);
@@ -91,7 +90,7 @@ public class LogTracker extends ServiceTracker implements LogService {
* @param throwable Log exception or null if none.
* @param reference ServiceReference associated with message or null if none.
*/
- protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) {
+ protected void noLogService(int level, String message, Throwable throwable, ServiceReference<?> reference) {
if (out != null) {
synchronized (out) {
// Bug #113286. If no log service present and messages are being
@@ -100,19 +99,19 @@ public class LogTracker extends ServiceTracker implements LogService {
out.print(timestamp + " "); //$NON-NLS-1$
switch (level) {
- case LOG_DEBUG : {
+ case LogService.LOG_DEBUG : {
out.print("Debug"); //$NON-NLS-1$
break;
}
- case LOG_INFO : {
+ case LogService.LOG_INFO : {
out.print("Info"); //$NON-NLS-1$
break;
}
- case LOG_WARNING : {
+ case LogService.LOG_WARNING : {
out.print("Warning"); //$NON-NLS-1$
break;
}
- case LOG_ERROR : {
+ case LogService.LOG_ERROR : {
out.print("Error"); //$NON-NLS-1$
break;
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
index 67b378d68..73bd09493 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,14 +22,14 @@ import org.osgi.util.tracker.ServiceTracker;
/**
* ManagedServiceFactoryTracker tracks... ManagedServiceFactory(s) and notifies them about related configuration changes
*/
-class ManagedServiceFactoryTracker extends ServiceTracker {
+class ManagedServiceFactoryTracker extends ServiceTracker<ManagedServiceFactory, ManagedServiceFactory> {
final ConfigurationAdminFactory configurationAdminFactory;
private final ConfigurationStore configurationStore;
// managedServiceFactoryReferences guards both managedServiceFactories and managedServiceFactoryReferences
- private final Map managedServiceFactories = new HashMap();
- private final Map managedServiceFactoryReferences = new HashMap();
+ private final Map<String, ManagedServiceFactory> managedServiceFactories = new HashMap<String, ManagedServiceFactory>();
+ private final Map<String, ServiceReference<ManagedServiceFactory>> managedServiceFactoryReferences = new HashMap<String, ServiceReference<ManagedServiceFactory>>();
private final SerializedTaskQueue queue = new SerializedTaskQueue("ManagedServiceFactory Update Queue"); //$NON-NLS-1$
@@ -42,7 +42,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
protected void notifyDeleted(ConfigurationImpl config) {
config.checkLocked();
String factoryPid = config.getFactoryPid(false);
- ServiceReference reference = getManagedServiceFactoryReference(factoryPid);
+ ServiceReference<ManagedServiceFactory> reference = getManagedServiceFactoryReference(factoryPid);
if (reference != null && config.bind(reference.getBundle()))
asynchDeleted(getManagedServiceFactory(factoryPid), config.getPid(false));
}
@@ -50,20 +50,20 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
protected void notifyUpdated(ConfigurationImpl config) {
config.checkLocked();
String factoryPid = config.getFactoryPid();
- ServiceReference reference = getManagedServiceFactoryReference(factoryPid);
+ ServiceReference<ManagedServiceFactory> reference = getManagedServiceFactoryReference(factoryPid);
if (reference != null && config.bind(reference.getBundle())) {
- Dictionary properties = config.getProperties();
+ Dictionary<String, Object> properties = config.getProperties();
configurationAdminFactory.modifyConfiguration(reference, properties);
asynchUpdated(getManagedServiceFactory(factoryPid), config.getPid(), properties);
}
}
- public Object addingService(ServiceReference reference) {
+ public ManagedServiceFactory addingService(ServiceReference<ManagedServiceFactory> reference) {
String factoryPid = (String) reference.getProperty(Constants.SERVICE_PID);
if (factoryPid == null)
return null;
- ManagedServiceFactory service = (ManagedServiceFactory) context.getService(reference);
+ ManagedServiceFactory service = context.getService(reference);
if (service == null)
return null;
@@ -73,7 +73,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
return service;
}
- public void modifiedService(ServiceReference reference, Object service) {
+ public void modifiedService(ServiceReference<ManagedServiceFactory> reference, ManagedServiceFactory service) {
String factoryPid = (String) reference.getProperty(Constants.SERVICE_PID);
synchronized (configurationStore) {
if (getManagedServiceFactory(factoryPid) == service)
@@ -84,7 +84,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
}
}
- public void removedService(ServiceReference reference, Object service) {
+ public void removedService(ServiceReference<ManagedServiceFactory> reference, ManagedServiceFactory service) {
String factoryPid = (String) reference.getProperty(Constants.SERVICE_PID);
synchronized (configurationStore) {
remove(reference, factoryPid);
@@ -92,7 +92,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
context.ungetService(reference);
}
- private void add(ServiceReference reference, String factoryPid, ManagedServiceFactory service) {
+ private void add(ServiceReference<ManagedServiceFactory> reference, String factoryPid, ManagedServiceFactory service) {
ConfigurationImpl[] configs = configurationStore.getFactoryConfigurations(factoryPid);
try {
for (int i = 0; i < configs.length; ++i)
@@ -103,7 +103,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
if (configs[i].isDeleted()) {
// ignore this config
} else if (configs[i].bind(reference.getBundle())) {
- Dictionary properties = configs[i].getProperties();
+ Dictionary<String, Object> properties = configs[i].getProperties();
configurationAdminFactory.modifyConfiguration(reference, properties);
asynchUpdated(service, configs[i].getPid(), properties);
} else {
@@ -117,7 +117,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
}
}
- private void remove(ServiceReference reference, String factoryPid) {
+ private void remove(ServiceReference<ManagedServiceFactory> reference, String factoryPid) {
ConfigurationImpl[] configs = configurationStore.getFactoryConfigurations(factoryPid);
try {
for (int i = 0; i < configs.length; ++i)
@@ -129,7 +129,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
}
}
- private boolean trackManagedServiceFactory(String factoryPid, ServiceReference reference, ManagedServiceFactory service) {
+ private boolean trackManagedServiceFactory(String factoryPid, ServiceReference<ManagedServiceFactory> reference, ManagedServiceFactory service) {
synchronized (managedServiceFactoryReferences) {
if (managedServiceFactoryReferences.containsKey(factoryPid)) {
configurationAdminFactory.log(LogService.LOG_WARNING, ManagedServiceFactory.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + factoryPid); //$NON-NLS-1$ //$NON-NLS-2$
@@ -141,7 +141,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
}
}
- private void untrackManagedServiceFactory(String factoryPid, ServiceReference reference) {
+ private void untrackManagedServiceFactory(String factoryPid, ServiceReference<ManagedServiceFactory> reference) {
synchronized (managedServiceFactoryReferences) {
managedServiceFactoryReferences.remove(factoryPid);
managedServiceFactories.remove(factoryPid);
@@ -150,22 +150,21 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
private ManagedServiceFactory getManagedServiceFactory(String factoryPid) {
synchronized (managedServiceFactoryReferences) {
- return (ManagedServiceFactory) managedServiceFactories.get(factoryPid);
+ return managedServiceFactories.get(factoryPid);
}
}
- private ServiceReference getManagedServiceFactoryReference(String factoryPid) {
+ private ServiceReference<ManagedServiceFactory> getManagedServiceFactoryReference(String factoryPid) {
synchronized (managedServiceFactoryReferences) {
- return (ServiceReference) managedServiceFactoryReferences.get(factoryPid);
+ return managedServiceFactoryReferences.get(factoryPid);
}
}
private String getPidForManagedServiceFactory(Object service) {
synchronized (managedServiceFactoryReferences) {
- for (Iterator it = managedServiceFactories.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
+ for (Entry<String, ManagedServiceFactory> entry : managedServiceFactories.entrySet()) {
if (entry.getValue() == service)
- return (String) entry.getKey();
+ return entry.getKey();
}
return null;
}
@@ -183,7 +182,7 @@ class ManagedServiceFactoryTracker extends ServiceTracker {
});
}
- private void asynchUpdated(final ManagedServiceFactory service, final String pid, final Dictionary properties) {
+ private void asynchUpdated(final ManagedServiceFactory service, final String pid, final Dictionary<String, Object> properties) {
queue.put(new Runnable() {
public void run() {
try {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
index cf10b6828..7fef34aa0 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2012 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,14 +21,14 @@ import org.osgi.util.tracker.ServiceTracker;
/**
* ManagedServiceTracker tracks... ManagedServices and notifies them about related configuration changes
*/
-class ManagedServiceTracker extends ServiceTracker {
+class ManagedServiceTracker extends ServiceTracker<ManagedService, ManagedService> {
final ConfigurationAdminFactory configurationAdminFactory;
private final ConfigurationStore configurationStore;
// managedServiceReferences guards both managedServices and managedServiceReferences
- private final Map managedServices = new HashMap();
- private final Map managedServiceReferences = new HashMap();
+ private final Map<String, ManagedService> managedServices = new HashMap<String, ManagedService>();
+ private final Map<String, ServiceReference<ManagedService>> managedServiceReferences = new HashMap<String, ServiceReference<ManagedService>>();
private final SerializedTaskQueue queue = new SerializedTaskQueue("ManagedService Update Queue"); //$NON-NLS-1$
@@ -41,7 +41,7 @@ class ManagedServiceTracker extends ServiceTracker {
protected void notifyDeleted(ConfigurationImpl config) {
config.checkLocked();
String pid = config.getPid(false);
- ServiceReference reference = getManagedServiceReference(pid);
+ ServiceReference<ManagedService> reference = getManagedServiceReference(pid);
if (reference != null && config.bind(reference.getBundle()))
asynchUpdated(getManagedService(pid), null);
}
@@ -49,20 +49,20 @@ class ManagedServiceTracker extends ServiceTracker {
protected void notifyUpdated(ConfigurationImpl config) {
config.checkLocked();
String pid = config.getPid();
- ServiceReference reference = getManagedServiceReference(pid);
+ ServiceReference<ManagedService> reference = getManagedServiceReference(pid);
if (reference != null && config.bind(reference.getBundle())) {
- Dictionary properties = config.getProperties();
+ Dictionary<String, Object> properties = config.getProperties();
configurationAdminFactory.modifyConfiguration(reference, properties);
asynchUpdated(getManagedService(pid), properties);
}
}
- public Object addingService(ServiceReference reference) {
+ public ManagedService addingService(ServiceReference<ManagedService> reference) {
String pid = (String) reference.getProperty(Constants.SERVICE_PID);
if (pid == null)
return null;
- ManagedService service = (ManagedService) context.getService(reference);
+ ManagedService service = context.getService(reference);
if (service == null)
return null;
@@ -72,7 +72,7 @@ class ManagedServiceTracker extends ServiceTracker {
return service;
}
- public void modifiedService(ServiceReference reference, Object service) {
+ public void modifiedService(ServiceReference<ManagedService> reference, ManagedService service) {
String pid = (String) reference.getProperty(Constants.SERVICE_PID);
synchronized (configurationStore) {
if (getManagedService(pid) == service)
@@ -83,7 +83,7 @@ class ManagedServiceTracker extends ServiceTracker {
}
}
- public void removedService(ServiceReference reference, Object service) {
+ public void removedService(ServiceReference<ManagedService> reference, ManagedService service) {
String pid = (String) reference.getProperty(Constants.SERVICE_PID);
synchronized (configurationStore) {
remove(reference, pid);
@@ -91,7 +91,7 @@ class ManagedServiceTracker extends ServiceTracker {
context.ungetService(reference);
}
- private void add(ServiceReference reference, String pid, ManagedService service) {
+ private void add(ServiceReference<ManagedService> reference, String pid, ManagedService service) {
ConfigurationImpl config = configurationStore.findConfiguration(pid);
if (config == null) {
if (trackManagedService(pid, reference, service)) {
@@ -106,7 +106,7 @@ class ManagedServiceTracker extends ServiceTracker {
} else if (config.isDeleted()) {
asynchUpdated(service, null);
} else if (config.bind(reference.getBundle())) {
- Dictionary properties = config.getProperties();
+ Dictionary<String, Object> properties = config.getProperties();
configurationAdminFactory.modifyConfiguration(reference, properties);
asynchUpdated(service, properties);
} else {
@@ -119,7 +119,7 @@ class ManagedServiceTracker extends ServiceTracker {
}
}
- private void remove(ServiceReference reference, String pid) {
+ private void remove(ServiceReference<ManagedService> reference, String pid) {
ConfigurationImpl config = configurationStore.findConfiguration(pid);
if (config == null) {
untrackManagedService(pid, reference);
@@ -133,7 +133,7 @@ class ManagedServiceTracker extends ServiceTracker {
}
}
- private boolean trackManagedService(String pid, ServiceReference reference, ManagedService service) {
+ private boolean trackManagedService(String pid, ServiceReference<ManagedService> reference, ManagedService service) {
synchronized (managedServiceReferences) {
if (managedServiceReferences.containsKey(pid)) {
String message = ManagedService.class.getName() + " already registered for " + Constants.SERVICE_PID + "=" + pid; //$NON-NLS-1$ //$NON-NLS-2$
@@ -146,7 +146,7 @@ class ManagedServiceTracker extends ServiceTracker {
}
}
- private void untrackManagedService(String pid, ServiceReference reference) {
+ private void untrackManagedService(String pid, ServiceReference<ManagedService> reference) {
synchronized (managedServiceReferences) {
managedServiceReferences.remove(pid);
managedServices.remove(pid);
@@ -155,28 +155,27 @@ class ManagedServiceTracker extends ServiceTracker {
private ManagedService getManagedService(String pid) {
synchronized (managedServiceReferences) {
- return (ManagedService) managedServices.get(pid);
+ return managedServices.get(pid);
}
}
- private ServiceReference getManagedServiceReference(String pid) {
+ private ServiceReference<ManagedService> getManagedServiceReference(String pid) {
synchronized (managedServiceReferences) {
- return (ServiceReference) managedServiceReferences.get(pid);
+ return managedServiceReferences.get(pid);
}
}
private String getPidForManagedService(Object service) {
synchronized (managedServiceReferences) {
- for (Iterator it = managedServices.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
+ for (Entry<String, ManagedService> entry : managedServices.entrySet()) {
if (entry.getValue() == service)
- return (String) entry.getKey();
+ return entry.getKey();
}
return null;
}
}
- private void asynchUpdated(final ManagedService service, final Dictionary properties) {
+ private void asynchUpdated(final ManagedService service, final Dictionary<String, ?> properties) {
queue.put(new Runnable() {
public void run() {
try {
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
index 68cfbd36c..eaf1424ac 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Cognos Incorporated, IBM Corporation and others.
+ * Copyright (c) 2005, 2013 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,14 +11,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.cm;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Dictionary;
-import java.util.TreeSet;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
+import java.util.*;
+import org.osgi.framework.*;
import org.osgi.service.cm.ConfigurationPlugin;
import org.osgi.util.tracker.ServiceTracker;
@@ -40,11 +34,11 @@ public class PluginManager {
pluginTracker.close();
}
- public void modifyConfiguration(ServiceReference managedReference, Dictionary properties) {
+ public void modifyConfiguration(ServiceReference<?> managedReference, Dictionary<String, Object> properties) {
if (properties == null)
return;
- ServiceReference[] references = pluginTracker.getServiceReferences();
+ ServiceReference<ConfigurationPlugin>[] references = pluginTracker.getServiceReferences();
for (int i = 0; i < references.length; ++i) {
String[] pids = (String[]) references[i].getProperty(ConfigurationPlugin.CM_TARGET);
if (pids != null) {
@@ -52,20 +46,21 @@ public class PluginManager {
if (!Arrays.asList(pids).contains(pid))
continue;
}
- ConfigurationPlugin plugin = (ConfigurationPlugin) pluginTracker.getService(references[i]);
+ ConfigurationPlugin plugin = pluginTracker.getService(references[i]);
if (plugin != null)
plugin.modifyConfiguration(managedReference, properties);
}
}
- private static class PluginTracker extends ServiceTracker {
+ private static class PluginTracker extends ServiceTracker<ConfigurationPlugin, ConfigurationPlugin> {
final Integer ZERO = new Integer(0);
- private TreeSet serviceReferences = new TreeSet(new Comparator() {
- public int compare(Object o1, Object o2) {
- return getRank((ServiceReference) o1).compareTo(getRank((ServiceReference) o2));
+ private TreeSet<ServiceReference<ConfigurationPlugin>> serviceReferences = new TreeSet<ServiceReference<ConfigurationPlugin>>(new Comparator<ServiceReference<ConfigurationPlugin>>() {
+ public int compare(ServiceReference<ConfigurationPlugin> s1, ServiceReference<ConfigurationPlugin> s2) {
+
+ return getRank(s1).compareTo(getRank(s2));
}
- private Integer getRank(ServiceReference ref) {
+ private Integer getRank(ServiceReference<ConfigurationPlugin> ref) {
Object ranking = ref.getProperty(ConfigurationPlugin.CM_RANKING);
if (ranking == null || !(ranking instanceof Integer))
return ZERO;
@@ -81,24 +76,25 @@ public class PluginManager {
* Rather than returning null if no references are present, it
* returns an empty array.
*/
- public ServiceReference[] getServiceReferences() {
+ @SuppressWarnings("unchecked")
+ public ServiceReference<ConfigurationPlugin>[] getServiceReferences() {
synchronized (serviceReferences) {
- return (ServiceReference[]) serviceReferences.toArray(new ServiceReference[0]);
+ return serviceReferences.toArray(new ServiceReference[serviceReferences.size()]);
}
}
- public Object addingService(ServiceReference reference) {
+ public ConfigurationPlugin addingService(ServiceReference<ConfigurationPlugin> reference) {
synchronized (serviceReferences) {
serviceReferences.add(reference);
}
return context.getService(reference);
}
- public void modifiedService(ServiceReference reference, Object service) {
+ public void modifiedService(ServiceReference<ConfigurationPlugin> reference, ConfigurationPlugin service) {
// nothing to do
}
- public void removedService(ServiceReference reference, Object service) {
+ public void removedService(ServiceReference<ConfigurationPlugin> reference, ConfigurationPlugin service) {
synchronized (serviceReferences) {
serviceReferences.remove(reference);
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java
index 7e221adfe..0e53b8c78 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Cognos Incorporated
+ * Copyright (c) 2006, 2013 Cognos Incorporated
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,7 +18,7 @@ import java.util.LinkedList;
public class SerializedTaskQueue {
private static final int MAX_WAIT = 5000;
- private final LinkedList tasks = new LinkedList();
+ private final LinkedList<Runnable> tasks = new LinkedList<Runnable>();
private Thread thread;
private final String queueName;
@@ -56,6 +56,6 @@ public class SerializedTaskQueue {
return null;
}
}
- return (Runnable) tasks.removeFirst();
+ return tasks.removeFirst();
}
}
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
index cb14d60aa..80a7308ce 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -128,7 +128,7 @@ public class ReliableFile {
private File referenceFile;
/** List of checksum file objects: File => specific ReliableFile generation */
- private static Hashtable cacheFiles = new Hashtable(20);
+ private static Hashtable<File, CacheInfo> cacheFiles = new Hashtable<File, CacheInfo>(20);
private File inputFile = null;
private File outputFile = null;
@@ -195,7 +195,7 @@ public class ReliableFile {
String[] files = parent.list();
if (files == null)
return null;
- ArrayList list = new ArrayList(defaultMaxGenerations);
+ List<Integer> list = new ArrayList<Integer>(defaultMaxGenerations);
if (file.exists())
list.add(new Integer(0)); //base file exists
for (int i = 0; i < files.length; i++) {
@@ -265,7 +265,7 @@ public class ReliableFile {
InputStream is = null;
CacheInfo info;
synchronized (cacheFiles) {
- info = (CacheInfo) cacheFiles.get(file);
+ info = cacheFiles.get(file);
long timeStamp = file.lastModified();
if (info == null || timeStamp != info.timeStamp) {
try {
@@ -356,7 +356,7 @@ public class ReliableFile {
}
try {
- CacheInfo info = (CacheInfo) cacheFiles.get(inputFile);
+ CacheInfo info = cacheFiles.get(inputFile);
appendChecksum = info.checksum;
OutputStream os = new FileOutputStream(tmpFile);
if (info.filetype == FILETYPE_NOSIGNATURE) {
@@ -445,7 +445,7 @@ public class ReliableFile {
// backup files.
for (int idx = 0, count = generationCount - rmCount; idx < count; idx++) {
File file = new File(parent, name + '.' + generations[idx]);
- CacheInfo info = (CacheInfo) cacheFiles.get(file);
+ CacheInfo info = cacheFiles.get(file);
if (info != null) {
if (info.filetype == FILETYPE_CORRUPT)
rmCount--;
@@ -625,7 +625,7 @@ public class ReliableFile {
if (!directory.isDirectory())
throw new IOException("Not a valid directory"); //$NON-NLS-1$
String files[] = directory.list();
- HashSet list = new HashSet(files.length / 2);
+ Set<String> list = new HashSet<String>(files.length / 2);
for (int idx = 0; idx < files.length; idx++) {
String file = files[idx];
int pos = file.lastIndexOf('.');
@@ -644,8 +644,8 @@ public class ReliableFile {
}
files = new String[list.size()];
int idx = 0;
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- files[idx++] = (String) iter.next();
+ for (Iterator<String> iter = list.iterator(); iter.hasNext();) {
+ files[idx++] = iter.next();
}
return files;
}
@@ -697,7 +697,7 @@ public class ReliableFile {
*/
int getSignatureSize() throws IOException {
if (inputFile != null) {
- CacheInfo info = (CacheInfo) cacheFiles.get(inputFile);
+ CacheInfo info = cacheFiles.get(inputFile);
if (info != null) {
switch (info.filetype) {
case FILETYPE_VALID :
diff --git a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java
index 1a3b4b77f..c28d399ac 100644
--- a/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java
+++ b/bundles/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -167,7 +167,7 @@ public class ReliableFileInputStream extends FilterInputStream {
* Override default available method.
* @see FilterInputStream#available()
*/
- public synchronized int available() throws IOException {
+ public synchronized int available() {
if (readPos < length) // just in case
return (length - readPos);
return 0;

Back to the top