diff options
author | Alexander Kurtakov | 2015-02-26 17:13:10 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2015-02-26 17:13:10 +0000 |
commit | 66c9297a230aeb57eb49d07f77eebf9c68d5b9ad (patch) | |
tree | 8ef9f1148e3aed53501cfca5f613b03940007956 /bundles/org.eclipse.equinox.p2.ui.sdk.scheduler | |
parent | f92c74ac081d929a7ce96a85b26bf60b5364a101 (diff) | |
download | rt.equinox.p2-66c9297a230aeb57eb49d07f77eebf9c68d5b9ad.tar.gz rt.equinox.p2-66c9297a230aeb57eb49d07f77eebf9c68d5b9ad.tar.xz rt.equinox.p2-66c9297a230aeb57eb49d07f77eebf9c68d5b9ad.zip |
Bug 460967 - Use type safe service retrievingI20150303-0800
Instead of retrieving services based on their String class name there is
newer implementation that takes the class directly and returns the
correct class preventing casts.
Change-Id: I8b26f4d294b927f4c28a6ba4e68e35bd401df4ec
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk.scheduler')
4 files changed, 17 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java index c55d00019..7cca4956a 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2015 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Inc. - Bug 460967 *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler; @@ -84,7 +85,7 @@ public class AutomaticUpdatePlugin extends AbstractUIPlugin { super.start(bundleContext); plugin = this; context = bundleContext; - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(getContext(), IProvisioningAgent.class); session = new ProvisioningSession(agent); PreferenceInitializer.migratePreferences(); diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java index 65ae0346d..d58bb5224 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2015 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 @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Ericsson AB - (Pascal Rapicault) * Ericsson AB (Hamdan Msheik) - Bug 398833 + * Red Hat Inc. - Bug 460967 *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler; @@ -71,7 +72,7 @@ public class AutomaticUpdateScheduler implements IStartup { */ public AutomaticUpdateScheduler() { AutomaticUpdatePlugin.getDefault().setScheduler(this); - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class); checker = (IUpdateChecker) agent.getService(IUpdateChecker.SERVICE_NAME); if (checker == null) { // Something did not initialize properly @@ -83,7 +84,7 @@ public class AutomaticUpdateScheduler implements IStartup { } public void earlyStartup() { - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IProfile currentProfile = registry.getProfile(profileId); if (currentProfile != null && new MigrationSupport().performMigration(agent, registry, currentProfile)) @@ -105,7 +106,7 @@ public class AutomaticUpdateScheduler implements IStartup { IPreferenceStore pref = AutomaticUpdatePlugin.getDefault().getPreferenceStore(); if (!pref.getBoolean(PreferenceConstants.PREF_GC_ON_STARTUP)) return; - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class); GarbageCollector collector = (GarbageCollector) agent.getService(GarbageCollector.SERVICE_NAME); if (collector == null) return; diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java index 092844154..7e18f4bac 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationSupport.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Ericsson AB and others. All rights reserved. This + * Copyright (c) 2013, 2015 Ericsson AB 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 http://www.eclipse.org/legal/epl-v10.html @@ -7,7 +7,8 @@ * Contributors: * Ericsson AB - initial API and implementation * Ericsson AB (Pascal Rapicault) - * Ericsson AB (Hamdan Msheik) + * Ericsson AB (Hamdan Msheik) + * Red Hat Inc. - Bug 460967 ******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration; @@ -97,7 +98,7 @@ public class MigrationSupport { } private File getInstallFolder() { - Location configurationLocation = (Location) ServiceHelper.getService(EngineActivator.getContext(), Location.class.getName(), Location.INSTALL_FILTER); + Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class, Location.INSTALL_FILTER); return new File(configurationLocation.getURL().getPath()); } @@ -110,7 +111,7 @@ public class MigrationSupport { } private File getConfigurationLocation() { - Location configurationLocation = (Location) ServiceHelper.getService(EngineActivator.getContext(), Location.class.getName(), Location.CONFIGURATION_FILTER); + Location configurationLocation = ServiceHelper.getService(EngineActivator.getContext(), Location.class, Location.CONFIGURATION_FILTER); File configurationFolder = new File(configurationLocation.getURL().getPath()); return configurationFolder; } diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java index 9fe09528f..a49ac5429 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 WindRiver Corporation and others. + * Copyright (c) 2011, 2015 WindRiver 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 @@ -10,6 +10,7 @@ * Ericsson AB - Ongoing development * Ericsson AB (Pascal Rapicault) * Ericsson AB (Hamdan Msheik) + * Red Hat Inc. - Bug 460967 *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler.migration; @@ -95,7 +96,7 @@ public class MigrationWizard extends InstallWizard implements IImportWizard { } private void addRepos() { - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class); IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); List<URI> currentMetaRepos = Arrays.asList(metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)); @@ -112,7 +113,7 @@ public class MigrationWizard extends InstallWizard implements IImportWizard { } private void removeRepos() { - IProvisioningAgent agent = (IProvisioningAgent) ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.SERVICE_NAME); + IProvisioningAgent agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class); IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME); IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); |