*** empty log message ***
diff --git a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/compatibility/PluginActivator.java b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/compatibility/PluginActivator.java index 806db3d..61e8811 100644 --- a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/compatibility/PluginActivator.java +++ b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/compatibility/PluginActivator.java
@@ -12,6 +12,7 @@ import org.eclipse.core.internal.plugins.PluginDescriptor; import org.eclipse.core.internal.registry.Extension; +import org.eclipse.core.internal.runtime.*; import org.eclipse.core.internal.runtime.InternalPlatform; import org.eclipse.core.internal.runtime.Policy; import org.eclipse.core.runtime.*; @@ -36,7 +37,7 @@ this.context = context; - PluginDescriptor pd = (PluginDescriptor) Extension.getPluginDescriptor(context.getBundle().getGlobalName()); + PluginDescriptor pd = (PluginDescriptor) CompatibilityHelper.getPluginDescriptor(context.getBundle().getGlobalName()); plugin = pd.getPlugin(); plugin.startup(); }
diff --git a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/DefaultPlugin.java b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/DefaultPlugin.java index ea24dbf..ff53603 100644 --- a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/DefaultPlugin.java +++ b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/DefaultPlugin.java
@@ -17,8 +17,6 @@ import org.eclipse.core.runtime.Plugin; public class DefaultPlugin extends Plugin { - public DefaultPlugin() { - } public DefaultPlugin(IPluginDescriptor descriptor) { super(descriptor); }
diff --git a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginClassLoader.java b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginClassLoader.java index 98b3797..cad86b9 100644 --- a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginClassLoader.java +++ b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginClassLoader.java
@@ -17,7 +17,6 @@ import org.eclipse.core.boot.BootLoader; import org.eclipse.core.internal.runtime.InternalPlatform; import org.eclipse.core.runtime.*; -import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException;
diff --git a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginDescriptor.java b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginDescriptor.java index 084779a..e282249 100644 --- a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginDescriptor.java +++ b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginDescriptor.java
@@ -114,7 +114,7 @@ } /** * @return a URL to the install location that does not need to be resolved. - */ + */ public URL getInstallURLInternal() { try { return InternalPlatform.getDefault().resolve(getInstallURL()); @@ -445,55 +445,28 @@ // constructor or startup() method, and waits on those // threads before returning (ie. calls join()). - boolean errorExit = true; - //A backward compatible plugin being started through a call to start on its bundle - if (bundleOsgi.getState() == Bundle.STARTING) { - // check if already activated or pending - if (pluginActivationEnter()) { - try { - internalDoPluginActivation(); - errorExit = false; - } finally { - pluginActivationExit(errorExit); - } + // sanity checking + if ((bundleOsgi.getState() & (Bundle.RESOLVED | Bundle.STARTING | Bundle.ACTIVE)) == 0) + throw new IllegalArgumentException(); + // plug-in hasn't been activated yet - start bundle + if (bundleOsgi.getState() == Bundle.RESOLVED) + try { + bundleOsgi.start(); + } catch (BundleException e) { + throwException(Policy.bind("plugin.startupProblems", e.toString()), e); } + if (pluginObject != null) return; - } - - //A new bundle that someone is trying to use as a plugin - if (bundleOsgi.getState() == Bundle.ACTIVE && pluginObject == null) { - if (pluginActivationEnter()) { - try { - internalDoPluginActivation(); - errorExit = false; - } finally { - pluginActivationExit(errorExit); - } - } - return; - } - - //A backward compatible plugin is being started through PluginDescriptor#getPlugin() - try { - bundleOsgi.start(); - // here we know the bundle is active. If the bundle does not use PluginActivator - // the plug-in activation (and plugin object creation) must be forced by hand - // (otherwise the first case above would handle it) - if (pluginObject == null) { - if (pluginActivationEnter()) { - try { - internalDoPluginActivation(); - errorExit = false; - } finally { - pluginActivationExit(errorExit); - } - } - return; - } - } catch (BundleException e) { - throwException(Policy.bind("plugin.startupProblems",getId()), e); - } - } + boolean errorExit = true; + // check if already activated or pending + if (pluginActivationEnter()) + try { + internalDoPluginActivation(); + errorExit = false; + } finally { + pluginActivationExit(errorExit); + } +} private String getPluginClass() { return (String) bundleOsgi.getHeaders().get("Plugin-class"); @@ -521,7 +494,7 @@ // find the correct constructor Constructor construct = null; try { - construct = runtimeClass.getConstructor(new Class[] { IPluginDescriptor.class }); + construct = runtimeClass.getConstructor(new Class[]{IPluginDescriptor.class}); } catch (NoSuchMethodException eNoConstructor) { errorMsg = Policy.bind("plugin.instantiateClassError", getId(), pluginClassName); //$NON-NLS-1$ throwException(errorMsg, eNoConstructor); @@ -529,7 +502,7 @@ // create a new instance try { - pluginObject = (Plugin) construct.newInstance(new Object[] { this }); + pluginObject = (Plugin) construct.newInstance(new Object[]{this}); } catch (ClassCastException e) { errorMsg = Policy.bind("plugin.notPluginClass", pluginClassName); //$NON-NLS-1$ throwException(errorMsg, e); @@ -539,33 +512,10 @@ } } - public void start() throws CoreException { - // run startup() - final String message = Policy.bind("plugin.startupProblems", getId()); //$NON-NLS-1$ - final MultiStatus multiStatus = new MultiStatus(Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, message, null); - - if (!multiStatus.isOK()) - throw new CoreException(multiStatus); - - ISafeRunnable code = new ISafeRunnable() { - public void run() throws Exception { - pluginObject.startup(); - } - public void handleException(Throwable e) { - multiStatus.add(new Status(IStatus.WARNING, Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, message, e)); - try { - pluginObject.shutdown(); - } catch (Exception ex) { - // Ignore exceptions during shutdown. Since startup failed we are probably - // in a weird state anyway. - } - } - }; - InternalPlatform.getDefault().run(code); - } - public PluginDescriptor(org.osgi.framework.Bundle b) { bundleOsgi = b; + if( (b.getState() & Bundle.ACTIVE) != 0 ) + active = true; } public boolean isLegacy() { return new Boolean((String) bundleOsgi.getHeaders().get("Legacy")).booleanValue(); @@ -578,4 +528,8 @@ public String getLocation() { return getInstallURLInternal().toExternalForm(); } + + public void setPlugin(Plugin object) { + pluginObject = object; + } }
diff --git a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginRegistry.java b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginRegistry.java index be55f72..a0788f0 100644 --- a/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginRegistry.java +++ b/bundles/org.eclipse.core.runtime.compatibility/src-runtime/org/eclipse/core/internal/plugins/PluginRegistry.java
@@ -32,9 +32,6 @@ private HashMap descriptors = new HashMap(); - public IExtensionRegistry getExtensionRegistry() { - return extRegistry; - } public PluginRegistry() { extRegistry = InternalPlatform.getDefault().getRegistry(); }