diff options
author | Mat Booth | 2016-05-19 16:05:32 +0000 |
---|---|---|
committer | Mat Booth | 2016-05-19 17:52:21 +0000 |
commit | 44690c98d0b67ef16c79d0940ede19021fa3dcdc (patch) | |
tree | 9825005ea148a0ea92c318c0877a8eda48afaf7c /man | |
parent | d4c08f4fb852279c6fffe2507eaec4017151efad (diff) | |
download | org.eclipse.linuxtools-44690c98d0b67ef16c79d0940ede19021fa3dcdc.tar.gz org.eclipse.linuxtools-44690c98d0b67ef16c79d0940ede19021fa3dcdc.tar.xz org.eclipse.linuxtools-44690c98d0b67ef16c79d0940ede19021fa3dcdc.zip |
Eliminate need for bundle activators in man page bundles.
They were doing nothing that couldn't be done by directly interrogating
the Framework and Platform APIs directly. Eliminating pointless
activators helps to improve the start up performance of the platform.
Change-Id: I6eb15686a10ee894ee2c70ca8b0b5d4b4c62f714
Signed-off-by: Mat Booth <mat.booth@redhat.com>
Reviewed-on: https://git.eclipse.org/r/73202
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
Tested-by: Hudson CI
Diffstat (limited to 'man')
14 files changed, 64 insertions, 153 deletions
diff --git a/man/org.eclipse.linuxtools.man.core/META-INF/MANIFEST.MF b/man/org.eclipse.linuxtools.man.core/META-INF/MANIFEST.MF index 28a35aca02..835c7e995f 100644 --- a/man/org.eclipse.linuxtools.man.core/META-INF/MANIFEST.MF +++ b/man/org.eclipse.linuxtools.man.core/META-INF/MANIFEST.MF @@ -2,14 +2,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.linuxtools.man.core;singleton:=true -Bundle-Version: 1.3.0.qualifier -Bundle-Activator: org.eclipse.linuxtools.internal.man.Activator +Bundle-Version: 1.4.0.qualifier Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.jface.text, org.eclipse.linuxtools.tools.launch.core, com.jcraft.jsch -Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: org.eclipse.linuxtools.internal.man.parser;x-friends:="org.eclipse.linuxtools.man.help", org.eclipse.linuxtools.man.parser, diff --git a/man/org.eclipse.linuxtools.man.core/pom.xml b/man/org.eclipse.linuxtools.man.core/pom.xml index a50f9ee842..fba592cdad 100644 --- a/man/org.eclipse.linuxtools.man.core/pom.xml +++ b/man/org.eclipse.linuxtools.man.core/pom.xml @@ -23,7 +23,7 @@ </parent> <artifactId>org.eclipse.linuxtools.man.core</artifactId> - <version>1.3.0-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <name>Linux Tools Man Plug-in</name> diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java deleted file mode 100644 index a1b4655f71..0000000000 --- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/Activator.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2015 Red Hat Inc. 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 - * - * Contributors: - * Alexander Kurtakov - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.internal.man; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The shared instance - private static Activator plugin; - - private BundleContext context; - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - this.context = context; - plugin = this; - } - - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - this.context = null; - super.stop(context); - } - - /** - * Returns the shared instance of the bundle activator. - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns the bundle symbolic name of the plug-in. - * - * @return an ID unique to this plug-in - */ - public String getPluginId() { - return context.getBundle().getSymbolicName(); - } -} diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java index da07515366..c64c0d72b8 100644 --- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java +++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/parser/ManParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 Red Hat Inc. and others. + * Copyright (c) 2009, 2015-2016 Red Hat Inc. 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 @@ -23,10 +23,14 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.linuxtools.internal.man.Activator; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.linuxtools.internal.man.preferences.PreferenceConstants; import org.eclipse.linuxtools.tools.launch.core.factory.LinuxtoolsProcessFactory; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; import com.jcraft.jsch.JSchException; @@ -62,9 +66,10 @@ public class ManParser { manPaths.add(Paths.get(path)); } } catch (IOException e) { + Bundle bundle = FrameworkUtil.getBundle(ManParser.class); Status status = new Status(IStatus.ERROR, e.getMessage(), - Activator.getDefault().getPluginId()); - Activator.getDefault().getLog().log(status); + bundle.getSymbolicName()); + Platform.getLog(bundle).log(status); } return manPaths; } @@ -111,9 +116,10 @@ public class ManParser { Process process = builder.start(); stdout = process.getInputStream(); } catch (IOException e) { + Bundle bundle = FrameworkUtil.getBundle(this.getClass()); Status status = new Status(IStatus.ERROR, e.getMessage(), - Activator.getDefault().getPluginId()); - Activator.getDefault().getLog().log(status); + bundle.getSymbolicName()); + Platform.getLog(bundle).log(status); } return stdout; } @@ -136,9 +142,10 @@ public class ManParser { sb.append(line + "\n"); //$NON-NLS-1$ } } catch (IOException e) { + Bundle bundle = FrameworkUtil.getBundle(this.getClass()); Status status = new Status(IStatus.ERROR, e.getMessage(), - Activator.getDefault().getPluginId()); - Activator.getDefault().getLog().log(status); + bundle.getSymbolicName()); + Platform.getLog(bundle).log(status); } return sb; } @@ -178,7 +185,9 @@ public class ManParser { } private static String getManExecutable() { - return Activator.getDefault().getPreferenceStore() - .getString(PreferenceConstants.P_PATH); + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( + FrameworkUtil.getBundle(ManParser.class).getSymbolicName()); + return prefs.get(PreferenceConstants.P_PATH, + PreferenceConstants.P_PATH_DEFAULT); } } diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/ManPathPage.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/ManPathPage.java index 051473fac0..7fe1a19401 100644 --- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/ManPathPage.java +++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/ManPathPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat Inc. and others. + * Copyright (c) 2009, 2016 Red Hat Inc. 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,11 +10,14 @@ *******************************************************************************/ package org.eclipse.linuxtools.internal.man.preferences; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FileFieldEditor; -import org.eclipse.linuxtools.internal.man.Activator; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.preferences.ScopedPreferenceStore; +import org.osgi.framework.FrameworkUtil; /** * Man page preferences. @@ -28,7 +31,10 @@ public class ManPathPage extends FieldEditorPreferencePage */ public ManPathPage() { super(GRID); - setPreferenceStore(Activator.getDefault().getPreferenceStore()); + IPreferenceStore prefs = new ScopedPreferenceStore( + InstanceScope.INSTANCE, + FrameworkUtil.getBundle(this.getClass()).getSymbolicName()); + setPreferenceStore(prefs); setDescription(Messages.ManPathPage_0); } diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java index 12cbcdbc37..de3bbec024 100644 --- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java +++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat Inc. and others. + * Copyright (c) 2009, 2016 Red Hat Inc. 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 @@ -20,4 +20,5 @@ public class PreferenceConstants { */ public static final String P_PATH = "pathPreference"; //$NON-NLS-1$ + public static final String P_PATH_DEFAULT = "/usr/bin/man"; //$NON-NLS-1$ } diff --git a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceInitializer.java b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceInitializer.java index a6974b46ac..0558069d70 100644 --- a/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceInitializer.java +++ b/man/org.eclipse.linuxtools.man.core/src/org/eclipse/linuxtools/internal/man/preferences/PreferenceInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Red Hat Inc. and others. + * Copyright (c) 2009, 2016 Red Hat Inc. 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,8 +11,9 @@ package org.eclipse.linuxtools.internal.man.preferences; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.linuxtools.internal.man.Activator; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.osgi.framework.FrameworkUtil; /** * Class used to initialize default preference values. @@ -21,8 +22,9 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { - IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.P_PATH, "/usr/bin/man"); //$NON-NLS-1$ + IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode( + FrameworkUtil.getBundle(this.getClass()).getSymbolicName()); + prefs.put(PreferenceConstants.P_PATH, + PreferenceConstants.P_PATH_DEFAULT); } - } diff --git a/man/org.eclipse.linuxtools.man.help/META-INF/MANIFEST.MF b/man/org.eclipse.linuxtools.man.help/META-INF/MANIFEST.MF index bb8a24d48f..2e9d7387cb 100644 --- a/man/org.eclipse.linuxtools.man.help/META-INF/MANIFEST.MF +++ b/man/org.eclipse.linuxtools.man.help/META-INF/MANIFEST.MF @@ -2,12 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.linuxtools.man.help;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.linuxtools.internal.man.Activator +Bundle-Version: 1.1.0.qualifier Require-Bundle: org.eclipse.core.runtime, org.eclipse.help, org.eclipse.help.base, org.eclipse.linuxtools.man.core;bundle-version="1.3.0" -Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Vendor: %Bundle-Vendor diff --git a/man/org.eclipse.linuxtools.man.help/pom.xml b/man/org.eclipse.linuxtools.man.help/pom.xml index 7057e0a248..23ee2afc28 100644 --- a/man/org.eclipse.linuxtools.man.help/pom.xml +++ b/man/org.eclipse.linuxtools.man.help/pom.xml @@ -23,7 +23,7 @@ </parent> <artifactId>org.eclipse.linuxtools.man.help</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <name>Linux Tools Man Help Center Integration Plug-in</name> diff --git a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/Activator.java b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/Activator.java deleted file mode 100644 index 6a2513b214..0000000000 --- a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/Activator.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2015 Red Hat Inc. 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 - * - * Contributors: - * Red Hat - initial API and implementation - *******************************************************************************/ -package org.eclipse.linuxtools.internal.man; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * Plug-in activator. - */ -public class Activator extends Plugin { - - // The shared instance - private static Activator plugin; - - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance of the bundle activator. - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns the bundle symbolic name of the plug-in. - * - * @return an ID unique to this plug-in - */ - public String getPluginId() { - return getBundle().getSymbolicName(); - } -} diff --git a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualToc.java b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualToc.java index 2acd190621..346e1b5622 100644 --- a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualToc.java +++ b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualToc.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat Inc. and others. + * Copyright (c) 2015-2016 Red Hat Inc. 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 @@ -24,12 +24,14 @@ import java.util.regex.Pattern; import org.eclipse.core.expressions.IEvaluationContext; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.help.IToc; import org.eclipse.help.ITopic; import org.eclipse.help.IUAElement; -import org.eclipse.linuxtools.internal.man.Activator; import org.eclipse.linuxtools.internal.man.parser.ManParser; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; /** * A table of contents that will have one topic for every manual section that @@ -92,9 +94,10 @@ public class ManualToc implements IToc { } } } catch (IOException e) { + Bundle bundle = FrameworkUtil.getBundle(this.getClass()); Status status = new Status(IStatus.ERROR, e.getMessage(), - Activator.getDefault().getPluginId()); - Activator.getDefault().getLog().log(status); + bundle.getSymbolicName()); + Platform.getLog(bundle).log(status); } } } diff --git a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualTocProvider.java b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualTocProvider.java index df99f704ad..8de3ae3f1c 100644 --- a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualTocProvider.java +++ b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/ManualTocProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat Inc. and others. + * Copyright (c) 2015-2016 Red Hat Inc. 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,7 @@ package org.eclipse.linuxtools.internal.man.help; import org.eclipse.help.AbstractTocProvider; import org.eclipse.help.IToc; import org.eclipse.help.ITocContribution; -import org.eclipse.linuxtools.internal.man.Activator; +import org.osgi.framework.FrameworkUtil; /** * Provider for help system table of contents. @@ -62,7 +62,8 @@ public class ManualTocProvider extends AbstractTocProvider { @Override public String getContributorId() { - return Activator.getDefault().getPluginId(); + return FrameworkUtil.getBundle(this.getClass()) + .getSymbolicName(); } }; return new ITocContribution[] { contribution }; diff --git a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageProducer.java b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageProducer.java index 58d437eac0..628133b774 100644 --- a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageProducer.java +++ b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageProducer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat Inc. and others. + * Copyright (c) 2015-2016 Red Hat Inc. 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,10 +14,12 @@ import java.io.InputStream; import java.util.Locale; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.help.IHelpContentProducer; -import org.eclipse.linuxtools.internal.man.Activator; import org.eclipse.linuxtools.internal.man.parser.ManParser; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; /** * Content producer that renders manual pages in HTML format. @@ -37,10 +39,11 @@ public class PageProducer implements IHelpContentProducer { parts = href.split("/"); //$NON-NLS-1$ } if (parts == null || parts.length < 2) { + Bundle bundle = FrameworkUtil.getBundle(this.getClass()); Status status = new Status(IStatus.ERROR, Messages.ManPageProducer_ParseError, - Activator.getDefault().getPluginId()); - Activator.getDefault().getLog().log(status); + bundle.getSymbolicName()); + Platform.getLog(bundle).log(status); return null; } diff --git a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageTopic.java b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageTopic.java index 728a86f460..6260d15758 100644 --- a/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageTopic.java +++ b/man/org.eclipse.linuxtools.man.help/src/org/eclipse/linuxtools/internal/man/help/PageTopic.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Red Hat Inc. and others. + * Copyright (c) 2015-2016 Red Hat Inc. 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,7 @@ package org.eclipse.linuxtools.internal.man.help; import org.eclipse.core.expressions.IEvaluationContext; import org.eclipse.help.ITopic; import org.eclipse.help.IUAElement; -import org.eclipse.linuxtools.internal.man.Activator; +import org.osgi.framework.FrameworkUtil; /** * A topic for an individual manual page. @@ -55,8 +55,8 @@ public class PageTopic implements ITopic, Comparable<PageTopic> { pageUrl = pageUrl.replaceAll("\\[", "LBRACKET"); //$NON-NLS-1$ //$NON-NLS-2$ pageUrl = pageUrl.replaceAll("\\]", "RBRACKET"); //$NON-NLS-1$ //$NON-NLS-2$ - return "/" + Activator.getDefault().getPluginId() + "/" //$NON-NLS-1$ //$NON-NLS-2$ - + sectionId + "/" + pageUrl + ".html"; //$NON-NLS-1$ //$NON-NLS-2$ + return "/" + FrameworkUtil.getBundle(this.getClass()).getSymbolicName() //$NON-NLS-1$ + + "/" + sectionId + "/" + pageUrl + ".html"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } @Override |