diff options
author | Lars Vogel | 2020-05-19 14:52:29 +0000 |
---|---|---|
committer | Lars Vogel | 2020-06-10 14:59:14 +0000 |
commit | 4d30e4b471b3d87ccbf91bf5b087539e18b24546 (patch) | |
tree | 52b1c3399469eb0c2d0c3f63e8f8f739ec19d210 | |
parent | f1a06ee83cd9bbc35a8ed6c88fab1389f3e884ce (diff) | |
download | eclipse.platform.ua-4d30e4b471b3d87ccbf91bf5b087539e18b24546.tar.gz eclipse.platform.ua-4d30e4b471b3d87ccbf91bf5b087539e18b24546.tar.xz eclipse.platform.ua-4d30e4b471b3d87ccbf91bf5b087539e18b24546.zip |
Bug 563347 - Remove HelpWebappPlugin#getDefault method to reduce theI20200610-1800
usage of Activator
This helps to remove the activator in the future, e.g. by moving the
debug check out of it.
Conflicts:
org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/HelpWebappPlugin.java
Change-Id: Idc54ab1fb383159182eea03e2a3030469f9d2d33
5 files changed, 12 insertions, 47 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/HelpWebappPlugin.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/HelpWebappPlugin.java index c37ca6f38..29963224b 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/HelpWebappPlugin.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/HelpWebappPlugin.java @@ -34,46 +34,15 @@ public class HelpWebappPlugin extends Plugin { protected static HelpWebappPlugin plugin; /** - * Logs an Error message with an exception. - */ - public static synchronized void logError(String message, Throwable ex) { - if (message == null) - message = ""; //$NON-NLS-1$ - Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, - message, ex); - HelpWebappPlugin.getDefault().getLog().log(errorStatus); - } - - /** - * Logs a Warning message with an exception. Note that the message should - * already be localized to proper locale. ie: WebappResources.getString() - * should already have been called - */ - public static synchronized void logWarning(String message) { - if (HelpWebappPlugin.DEBUG) { - if (message == null) - message = ""; //$NON-NLS-1$ - Status warningStatus = new Status(IStatus.WARNING, PLUGIN_ID, - IStatus.OK, message, null); - HelpWebappPlugin.getDefault().getLog().log(warningStatus); - } - } - - /** * @return the singleton instance of the help webapp plugin */ public static HelpWebappPlugin getDefault() { return plugin; } - private static BundleContext bundleContext; - @Override public void start(BundleContext context) throws Exception { super.start(context); - plugin = this; - bundleContext = context; - // Setup debugging options // Setup debugging options DEBUG = isDebugging(); if (DEBUG) { @@ -81,14 +50,4 @@ public class HelpWebappPlugin extends Plugin { } } - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - //bundleContext = null; - super.stop(context); - } - - public static BundleContext getContext() { - return bundleContext; - } } diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java index 5e3775818..cb08680ea 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/WebappResources.java @@ -26,6 +26,7 @@ import java.util.StringTokenizer; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; /** * Uses a resource bundle to load images and strings from a property file in a @@ -155,8 +156,9 @@ public class WebappResources { private static ResourceBundle getResourceBundle(String key) { ResourceBundle bundle; - Bundle hostBundle = Platform.getBundle(HelpWebappPlugin.getDefault() - .getBundle().getSymbolicName()); + + ; + Bundle hostBundle = Platform.getBundle(FrameworkUtil.getBundle(HelpWebappPlugin.class).getSymbolicName()); if (hostBundle == null) return null; diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java index 83967b746..d84b14314 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/LayoutData.java @@ -29,10 +29,12 @@ import org.eclipse.help.internal.base.BaseHelpSystem; import org.eclipse.help.internal.base.MissingContentManager; import org.eclipse.help.internal.base.remote.RemoteStatusData; import org.eclipse.help.internal.webapp.HelpWebappPlugin; +import org.eclipse.help.internal.webapp.servlet.AboutServlet; import org.eclipse.help.webapp.AbstractView; import org.eclipse.osgi.service.localization.BundleLocalization; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; public class LayoutData extends RequestData { @@ -219,7 +221,8 @@ public class LayoutData extends RequestData { String resource = titlePref.substring(slash + 1); try { Bundle bundle = Platform.getBundle(resourceContainer); - BundleContext bundleContext = HelpWebappPlugin.getContext(); + + BundleContext bundleContext = FrameworkUtil.getBundle(LayoutData.class).getBundleContext(); ServiceReference<?> ref = bundleContext.getServiceReference(BundleLocalization.class.getName()); BundleLocalization localization = (BundleLocalization) bundleContext.getService(ref); return localization.getLocalization(bundle, locale).getString(resource); diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/AboutService.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/AboutService.java index 1133e467d..3662ebe28 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/AboutService.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/service/AboutService.java @@ -34,6 +34,7 @@ import org.eclipse.help.internal.webapp.servlet.PreferenceWriter; import org.eclipse.help.internal.webapp.servlet.XMLGenerator; import org.eclipse.help.internal.webapp.utils.Utils; import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; /** * Generates either xml, json or html page having informations about either @@ -184,7 +185,7 @@ public class AboutService extends AboutServlet { List<PluginDetails> plugins = new ArrayList<>(); - Bundle[] bundles = HelpWebappPlugin.getContext().getBundles(); + Bundle[] bundles = FrameworkUtil.getBundle(AboutServlet.class).getBundleContext().getBundles(); for (Bundle bundle : bundles) { plugins.add(pluginDetails(bundle)); } diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java index f2b6aaca3..f051e46cf 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/AboutServlet.java @@ -32,6 +32,7 @@ import org.eclipse.help.internal.webapp.WebappResources; import org.eclipse.help.internal.webapp.data.UrlUtil; import org.osgi.framework.Bundle; import org.osgi.framework.Constants; +import org.osgi.framework.FrameworkUtil; /** * A servlet that provides an informational page about the plugins that make up @@ -123,8 +124,7 @@ public class AboutServlet extends HttpServlet { buf.append("<table>"); //$NON-NLS-1$ List<PluginDetails> plugins = new ArrayList<>(); - - Bundle[] bundles = HelpWebappPlugin.getContext().getBundles(); + Bundle[] bundles = FrameworkUtil.getBundle(AboutServlet.class).getBundleContext().getBundles(); for (Bundle bundle : bundles) { plugins.add(pluginDetails(bundle)); } |