Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Kuntz2020-01-24 08:39:13 +0000
committerBenedikt Kuntz2020-01-24 08:39:13 +0000
commit670c23261f89d6d311e7c99f23aef8c726bb6897 (patch)
treea3b6f91d28ec108c6169e8e1a235ffe5af257d6a /bundles
parentc715305e806ebae77689bbec207e4925a8573e98 (diff)
downloadeclipse.platform.ui.tools-670c23261f89d6d311e7c99f23aef8c726bb6897.tar.gz
eclipse.platform.ui.tools-670c23261f89d6d311e7c99f23aef8c726bb6897.tar.xz
eclipse.platform.ui.tools-670c23261f89d6d311e7c99f23aef8c726bb6897.zip
org.eclipse.e4.tools.services removed methods and resulting unused constants and comments Change-Id: I7cee212db46e6dad56e84edc3332291f3ca04710 Signed-off-by: Benedikt Kuntz <benedikt.kuntz@airbus.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/ToolsServicesActivator.java18
-rw-r--r--bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/impl/ResourceBundleHelper.java162
2 files changed, 0 insertions, 180 deletions
diff --git a/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/ToolsServicesActivator.java b/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/ToolsServicesActivator.java
index 10a2ed22..706d15d7 100644
--- a/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/ToolsServicesActivator.java
+++ b/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/ToolsServicesActivator.java
@@ -3,15 +3,12 @@ package org.eclipse.e4.tools.services;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
-import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
-@SuppressWarnings("deprecation")
public class ToolsServicesActivator implements BundleActivator {
static private ToolsServicesActivator defaultInstance;
private BundleContext bundleContext;
- private ServiceTracker<PackageAdmin, PackageAdmin> pkgAdminTracker;
private ServiceTracker<LogService, LogService> logTracker;
public static final String PLUGIN_ID = "org.eclipse.e4.tools.services"; //$NON-NLS-1$
@@ -30,10 +27,6 @@ public class ToolsServicesActivator implements BundleActivator {
@Override
public void stop(BundleContext context) throws Exception {
- if (pkgAdminTracker != null) {
- pkgAdminTracker.close();
- pkgAdminTracker = null;
- }
if (logTracker != null) {
logTracker.close();
logTracker = null;
@@ -41,17 +34,6 @@ public class ToolsServicesActivator implements BundleActivator {
bundleContext = null;
}
- public PackageAdmin getPackageAdmin() {
- if (pkgAdminTracker == null) {
- if (bundleContext == null) {
- return null;
- }
- pkgAdminTracker = new ServiceTracker<>(bundleContext,
- PackageAdmin.class, null);
- pkgAdminTracker.open();
- }
- return pkgAdminTracker.getService();
- }
public LogService getLogService() {
if (logTracker == null) {
diff --git a/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/impl/ResourceBundleHelper.java b/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/impl/ResourceBundleHelper.java
index daca617d..df38aa8e 100644
--- a/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/impl/ResourceBundleHelper.java
+++ b/bundles/org.eclipse.e4.tools.services/src/org/eclipse/e4/tools/services/impl/ResourceBundleHelper.java
@@ -15,8 +15,6 @@ package org.eclipse.e4.tools.services.impl;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
@@ -29,153 +27,16 @@ import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.ResourceBundle.Control;
-import org.eclipse.e4.tools.services.ToolsServicesActivator;
-import org.eclipse.osgi.service.localization.BundleLocalization;
import org.osgi.framework.Bundle;
-import org.osgi.service.log.LogService;
-import org.osgi.service.packageadmin.PackageAdmin;
/**
* Helper class for retrieving {@link ResourceBundle}s out of OSGi {@link Bundle}s.
*
* @author Dirk Fauth
*/
-// There is no replacement for PackageAdmin#getBundles()
-@SuppressWarnings("deprecation")
public class ResourceBundleHelper {
/**
- * The schema identifier used for Eclipse platform references
- */
- private static final String PLATFORM_SCHEMA = "platform"; //$NON-NLS-1$
- /**
- * The schema identifier used for Eclipse bundle class references
- */
- private static final String BUNDLECLASS_SCHEMA = "bundleclass"; //$NON-NLS-1$
- /**
- * Identifier part of the Eclipse platform schema to point to a plugin
- */
- private static final String PLUGIN_SEGMENT = "/plugin/"; //$NON-NLS-1$
- /**
- * Identifier part of the Eclipse platform schema to point to a fragment
- */
- private static final String FRAGMENT_SEGMENT = "/fragment/"; //$NON-NLS-1$
- /**
- * The separator character for paths in the platform schema
- */
- private static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
-
- /**
- * Parses the specified contributor URI and loads the {@link ResourceBundle} for the specified {@link Locale} out of
- * an OSGi {@link Bundle}.
- * <p>
- * Following URIs are supported:
- * <ul>
- * <li>platform:/[plugin|fragment]/[Bundle-SymbolicName]<br>
- * Load the OSGi resource bundle out of the bundle/fragment named [Bundle-SymbolicName]</li>
- * <li>platform:/[plugin|fragment]/[Bundle-SymbolicName]/[Path]/[Basename]<br>
- * Load the resource bundle specified by [Path] and [Basename] out of the bundle/fragment named
- * [Bundle-SymbolicName].</li>
- * <li>bundleclass://[plugin|fragment]/[Full-Qualified-Classname]<br>
- * Instantiate the class specified by [Full-Qualified-Classname] out of the bundle/fragment named
- * [Bundle-SymbolicName]. Note that the class needs to be a subtype of {@link ResourceBundle}.</li>
- * </ul>
- * </p>
- *
- * @param contributorURI The URI that points to a {@link ResourceBundle}
- * @param locale The {@link Locale} to use for loading the {@link ResourceBundle}
- * @param localization The service for retrieving a {@link ResourceBundle} for a given {@link Locale} out of
- * the given {@link Bundle} which is specified by URI.
- * @return the resource bundle
- */
- public static ResourceBundle getResourceBundleForUri(String contributorURI, Locale locale,
- BundleLocalization localization) {
- if (contributorURI == null) {
- return null;
- }
-
- final LogService logService = ToolsServicesActivator.getDefault().getLogService();
-
- URI uri;
- try {
- uri = new URI(contributorURI);
- } catch (final URISyntaxException e) {
- if (logService != null)
- {
- logService.log(LogService.LOG_ERROR, "Invalid contributor URI: " + contributorURI); //$NON-NLS-1$
- }
- return null;
- }
-
- String bundleName = null;
- Bundle bundle = null;
- String resourcePath = null;
- String classPath = null;
-
- // the uri follows the platform schema, so we search for .properties files in the bundle
- if (PLATFORM_SCHEMA.equals(uri.getScheme())) {
- bundleName = uri.getPath();
- if (bundleName.startsWith(PLUGIN_SEGMENT)) {
- bundleName = bundleName.substring(PLUGIN_SEGMENT.length());
- } else if (bundleName.startsWith(FRAGMENT_SEGMENT)) {
- bundleName = bundleName.substring(FRAGMENT_SEGMENT.length());
- }
-
- resourcePath = ""; //$NON-NLS-1$
- if (bundleName.contains(PATH_SEPARATOR)) {
- resourcePath = bundleName.substring(bundleName.indexOf(PATH_SEPARATOR) + 1);
- bundleName = bundleName.substring(0, bundleName.indexOf(PATH_SEPARATOR));
- }
- } else if (BUNDLECLASS_SCHEMA.equals(uri.getScheme())) {
- if (uri.getAuthority() == null) {
- if (logService != null)
- {
- logService.log(LogService.LOG_ERROR, "Failed to get bundle for: " + contributorURI); //$NON-NLS-1$
- }
- }
- bundleName = uri.getAuthority();
- // remove the leading /
- classPath = uri.getPath().substring(1);
- }
-
- ResourceBundle result = null;
-
- if (bundleName != null) {
- bundle = getBundleForName(bundleName);
-
- if (bundle != null) {
- if (resourcePath == null && classPath != null) {
- // the URI points to a class within the bundle classpath
- // therefore we are trying to instantiate the class
- try {
- final Class<?> resourceBundleClass = bundle.loadClass(classPath);
- result = getEquinoxResourceBundle(classPath, locale, resourceBundleClass.getClassLoader());
- } catch (final Exception e) {
- if (logService != null)
- {
- logService.log(LogService.LOG_ERROR,
- "Failed to load specified ResourceBundle: " + contributorURI, e); //$NON-NLS-1$
- }
- }
- }
- else if (resourcePath.length() > 0) {
- // the specified URI points to a resource
- // therefore we try to load the .properties files into a ResourceBundle
- result = getEquinoxResourceBundle(resourcePath.replace('.', '/'), locale, bundle);
- }
- else {
- // there is no class and no special resource specified within the URI
- // therefore we load the OSGi resource bundle out of the specified Bundle
- // for the current Locale
- result = localization.getLocalization(bundle, locale.toString());
- }
- }
- }
-
- return result;
- }
-
- /**
* This method searches for the {@link ResourceBundle} in a modified way by inspecting the configuration option
* <code>equinox.root.locale</code>.
* <p>
@@ -408,29 +269,6 @@ public class ResourceBundleHelper {
}
/**
- * This method is copied out of org.eclipse.e4.ui.internal.workbench.Activator
- * because as it is a internal resource, it is not accessible for us.
- *
- * @param bundleName
- * the bundle id
- * @return A bundle if found, or <code>null</code>
- */
- public static Bundle getBundleForName(String bundleName) {
- final PackageAdmin packageAdmin = ToolsServicesActivator.getDefault().getPackageAdmin();
- final Bundle[] bundles = packageAdmin.getBundles(bundleName, null);
- if (bundles == null) {
- return null;
- }
- // Return the first bundle that is not installed or uninstalled
- for (int i = 0; i < bundles.length; i++) {
- if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
- return bundles[i];
- }
- }
- return null;
- }
-
- /**
* <p>
* Converts a String to a Locale.
* </p>

Back to the top