diff options
author | John Arthorne | 2010-09-22 17:04:02 +0000 |
---|---|---|
committer | John Arthorne | 2010-09-22 17:04:02 +0000 |
commit | 85e7415ae9453071f23dc73359f765674c3260d1 (patch) | |
tree | b4077e70ace90970ce82c94c470f975c84fef83f /bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox | |
parent | 02c8edd288911cf42675debbb593120b56e0b8e2 (diff) | |
download | rt.equinox.p2-85e7415ae9453071f23dc73359f765674c3260d1.tar.gz rt.equinox.p2-85e7415ae9453071f23dc73359f765674c3260d1.tar.xz rt.equinox.p2-85e7415ae9453071f23dc73359f765674c3260d1.zip |
fixed generics compiler warnings
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox')
5 files changed, 35 insertions, 34 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java index 8571bc6b4..bfa77c33d 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java @@ -45,9 +45,9 @@ public class Activator implements BundleActivator { private static final String VAR_USER_HOME = "@user.home"; //$NON-NLS-1$ private IProvisioningAgent agent; - private ServiceRegistration agentLocationRegistration = null; + private ServiceRegistration<IAgentLocation> agentLocationRegistration = null; - ServiceTracker logTracker; + ServiceTracker<FrameworkLog, FrameworkLog> logTracker; /** * NOTE: This method is copied from LocationHelper in org.eclipse.osgi @@ -106,10 +106,10 @@ public class Activator implements BundleActivator { Activator a = instance; if (a == null) return null; - ServiceTracker tracker = a.getLogTracker(); + ServiceTracker<FrameworkLog, FrameworkLog> tracker = a.getLogTracker(); if (tracker == null) return null; - return (FrameworkLog) tracker.getService(); + return tracker.getService(); } private static String substituteVar(String source, String var, String prop) { @@ -147,13 +147,13 @@ public class Activator implements BundleActivator { return result; } - private ServiceTracker getLogTracker() { + private ServiceTracker<FrameworkLog, FrameworkLog> getLogTracker() { if (logTracker != null) return logTracker; //lazy init if the bundle has been started if (context == null) return null; - logTracker = new ServiceTracker(context, FrameworkLog.class.getName(), null); + logTracker = new ServiceTracker<FrameworkLog, FrameworkLog>(context, FrameworkLog.class, null); logTracker.open(); return logTracker; } @@ -167,10 +167,10 @@ public class Activator implements BundleActivator { //no need to register an agent if there is no agent location if (agentDataLocation == null) return; - ServiceReference agentProviderRef = context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME); + ServiceReference<IProvisioningAgentProvider> agentProviderRef = context.getServiceReference(IProvisioningAgentProvider.class); IProvisioningAgentProvider provider = null; if (agentProviderRef != null) - provider = (IProvisioningAgentProvider) context.getService(agentProviderRef); + provider = context.getService(agentProviderRef); if (provider == null) { // If we don't have a provider, which could happen if the p2.core bundle is @@ -195,7 +195,7 @@ public class Activator implements BundleActivator { Dictionary<String, Object> locationProperties = new Hashtable<String, Object>(); if (agentDataLocation != null) { locationProperties.put("type", PROP_AGENT_DATA_AREA); //$NON-NLS-1$ - agentLocationRegistration = aContext.registerService(IAgentLocation.SERVICE_NAME, agentDataLocation, locationProperties); + agentLocationRegistration = aContext.registerService(IAgentLocation.class, agentDataLocation, locationProperties); } registerAgent(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java index 158e28177..3d0f4bc60 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/DefaultAgentProvider.java @@ -39,7 +39,7 @@ public class DefaultAgentProvider implements IProvisioningAgentProvider { properties.put(Constants.SERVICE_RANKING, new Integer(100)); properties.put(IProvisioningAgent.SERVICE_CURRENT, Boolean.TRUE.toString()); } - ServiceRegistration reg = context.registerService(IProvisioningAgent.SERVICE_NAME, result, properties); + ServiceRegistration<IProvisioningAgent> reg = context.registerService(IProvisioningAgent.class, result, properties); result.setServiceRegistration(reg); return result; } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java index 20df0d9a5..32a6a30ef 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java @@ -23,13 +23,13 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; /** * Represents a p2 agent instance. */ -public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCustomizer { +public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCustomizer<IAgentServiceFactory, Object> { private final Map<String, Object> agentServices = Collections.synchronizedMap(new HashMap<String, Object>()); private BundleContext context; private volatile boolean stopped = false; - private ServiceRegistration reg; - private final Map<ServiceReference, ServiceTracker> trackers = Collections.synchronizedMap(new HashMap<ServiceReference, ServiceTracker>()); + private ServiceRegistration<IProvisioningAgent> reg; + private final Map<ServiceReference<IAgentServiceFactory>, ServiceTracker<IAgentServiceFactory, Object>> trackers = Collections.synchronizedMap(new HashMap<ServiceReference<IAgentServiceFactory>, ServiceTracker<IAgentServiceFactory, Object>>()); /** * Instantiates a provisioning agent. @@ -51,17 +51,18 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust if (service != null) return service; //attempt to get factory service from service registry - ServiceReference[] refs; + Collection<ServiceReference<IAgentServiceFactory>> refs; try { - refs = context.getServiceReferences(IAgentServiceFactory.SERVICE_NAME, "(" + IAgentServiceFactory.PROP_CREATED_SERVICE_NAME + '=' + serviceName + ')'); //$NON-NLS-1$ + refs = context.getServiceReferences(IAgentServiceFactory.class, "(" + IAgentServiceFactory.PROP_CREATED_SERVICE_NAME + '=' + serviceName + ')'); //$NON-NLS-1$ } catch (InvalidSyntaxException e) { e.printStackTrace(); return null; } - if (refs == null || refs.length == 0) + if (refs == null || refs.isEmpty()) return null; + ServiceReference<IAgentServiceFactory> firstRef = refs.iterator().next(); //track the factory so that we can automatically remove the service when the factory goes away - ServiceTracker tracker = new ServiceTracker(context, refs[0], this); + ServiceTracker<IAgentServiceFactory, Object> tracker = new ServiceTracker<IAgentServiceFactory, Object>(context, firstRef, this); tracker.open(); IAgentServiceFactory factory = (IAgentServiceFactory) tracker.getService(); if (factory == null) { @@ -74,7 +75,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust return null; } registerService(serviceName, service); - trackers.put(refs[0], tracker); + trackers.put(firstRef, tracker); return service; } } @@ -99,9 +100,9 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust //treat a null location as using the currently running platform IAgentLocation agentLocation = null; if (location == null) { - ServiceReference ref = context.getServiceReference(IAgentLocation.SERVICE_NAME); + ServiceReference<IAgentLocation> ref = context.getServiceReference(IAgentLocation.class); if (ref != null) { - agentLocation = (IAgentLocation) context.getService(ref); + agentLocation = context.getService(ref); context.ungetService(ref); } } else { @@ -135,7 +136,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust stopped = true; //close all service trackers synchronized (trackers) { - for (ServiceTracker t : trackers.values()) + for (ServiceTracker<IAgentServiceFactory, Object> t : trackers.values()) t.close(); trackers.clear(); } @@ -145,14 +146,14 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust } } - public void setServiceRegistration(ServiceRegistration reg) { + public void setServiceRegistration(ServiceRegistration<IProvisioningAgent> reg) { this.reg = reg; } /*(non-Javadoc) * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference) */ - public Object addingService(ServiceReference reference) { + public Object addingService(ServiceReference<IAgentServiceFactory> reference) { if (stopped) return null; return context.getService(reference); @@ -161,14 +162,14 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust /*(non-Javadoc) * @see org.osgi.util.tracker.ServiceTrackerCustomizer#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object) */ - public void modifiedService(ServiceReference reference, Object service) { + public void modifiedService(ServiceReference<IAgentServiceFactory> reference, Object service) { //nothing to do } /*(non-Javadoc) * @see org.osgi.util.tracker.ServiceTrackerCustomizer#removedService(org.osgi.framework.ServiceReference, java.lang.Object) */ - public void removedService(ServiceReference reference, Object factoryService) { + public void removedService(ServiceReference<IAgentServiceFactory> reference, Object factoryService) { if (stopped) return; String serviceName = (String) reference.getProperty(IAgentServiceFactory.PROP_CREATED_SERVICE_NAME); @@ -180,7 +181,7 @@ public class ProvisioningAgent implements IProvisioningAgent, ServiceTrackerCust if (FrameworkUtil.getBundle(registered.getClass()) == FrameworkUtil.getBundle(factoryService.getClass())) { //the service we are holding is going away unregisterService(serviceName, registered); - ServiceTracker toRemove = trackers.remove(reference); + ServiceTracker<IAgentServiceFactory, Object> toRemove = trackers.remove(reference); if (toRemove != null) toRemove.close(); } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java index eff68815c..883b95243 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java @@ -21,9 +21,9 @@ import org.eclipse.osgi.framework.eventmgr.*; /** * Default implementation of the {@link IProvisioningEventBus} service. */ -public class ProvisioningEventBus implements EventDispatcher, IProvisioningEventBus, IAgentService { - private final CopyOnWriteIdentityMap syncListeners = new CopyOnWriteIdentityMap(); - private final CopyOnWriteIdentityMap asyncListeners = new CopyOnWriteIdentityMap(); +public class ProvisioningEventBus implements EventDispatcher<ProvisioningListener, ProvisioningListener, EventObject>, IProvisioningEventBus, IAgentService { + private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> syncListeners = new CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener>(); + private final CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener> asyncListeners = new CopyOnWriteIdentityMap<ProvisioningListener, ProvisioningListener>(); private EventManager eventManager = new EventManager("Provisioning Event Dispatcher"); //$NON-NLS-1$ private Object dispatchEventLock = new Object(); @@ -75,7 +75,7 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent return; } /* queue to hold set of listeners */ - ListenerQueue listeners = new ListenerQueue(eventManager); + ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject> listeners = new ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject>(eventManager); /* synchronize while building the listener list */ synchronized (syncListeners) { @@ -85,7 +85,7 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent listeners.dispatchEventSynchronous(0, event); } - listeners = new ListenerQueue(eventManager); + listeners = new ListenerQueue<ProvisioningListener, ProvisioningListener, EventObject>(eventManager); synchronized (asyncListeners) { listeners.queueListeners(asyncListeners.entrySet(), this); synchronized (dispatchEventLock) { @@ -98,14 +98,14 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent /* (non-Javadoc) * @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#dispatchEvent(java.lang.Object, java.lang.Object, int, java.lang.Object) */ - public void dispatchEvent(Object eventListener, Object listenerObject, int eventAction, Object eventObject) { + public void dispatchEvent(ProvisioningListener eventListener, ProvisioningListener listenerObject, int eventAction, EventObject eventObject) { synchronized (dispatchEventLock) { if (closed) return; dispatchingEvents++; } try { - ((ProvisioningListener) eventListener).notify((EventObject) eventObject); + eventListener.notify(eventObject); } catch (Exception e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Exception during event notification", e)); //$NON-NLS-1$ } finally { diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus.java index ee4d7d3e4..32b6d45cd 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/eventbus/IProvisioningEventBus.java @@ -17,7 +17,7 @@ import org.eclipse.osgi.framework.eventmgr.EventDispatcher; * The bus for events related to provisioning. This service can be used to register * a listener to receive provisioning events, or to broadcast events. */ -public interface IProvisioningEventBus extends EventDispatcher { +public interface IProvisioningEventBus extends EventDispatcher<ProvisioningListener, ProvisioningListener, EventObject> { /** * The name used for obtaining a reference to the event bus service. */ |