diff options
author | Thomas Watson | 2016-02-09 19:16:57 +0000 |
---|---|---|
committer | Thomas Watson | 2016-02-09 19:16:57 +0000 |
commit | a6b9ae00892db788d5f5d670bfe72414be275791 (patch) | |
tree | ee52fc7f9288889a124a728fa23aa71086172d6d | |
parent | 2e8bca2fc054584f7f881cf68d4d782a6b421bd9 (diff) | |
download | rt.equinox.framework-a6b9ae00892db788d5f5d670bfe72414be275791.tar.gz rt.equinox.framework-a6b9ae00892db788d5f5d670bfe72414be275791.tar.xz rt.equinox.framework-a6b9ae00892db788d5f5d670bfe72414be275791.zip |
Bug 487537 - Resolving multiple framework extensions should add content
of all before starting any extension activators
Change-Id: Ie44f992bcbc055f09aeaa14616bba37127d9c9d7
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
3 files changed, 39 insertions, 35 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java index f28d7b112..926072e8a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/SystemBundleLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2014 IBM Corporation and others. + * Copyright (c) 2003, 2016 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 @@ -125,12 +125,10 @@ public class SystemBundleLoader extends BundleLoader { @Override public void loadFragments(Collection<ModuleRevision> fragments) { Module systemModule = getWiring().getRevision().getRevisions().getModule(); - for (ModuleRevision fragment : fragments) { - try { - this.getGeneration().getBundleInfo().getStorage().getExtensionInstaller().addExtensionContent(fragment, systemModule); - } catch (BundleException e) { - systemModule.getContainer().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, systemModule, e); - } + try { + this.getGeneration().getBundleInfo().getStorage().getExtensionInstaller().addExtensionContent(fragments, systemModule); + } catch (BundleException e) { + systemModule.getContainer().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, systemModule, e); } getClasspathManager().loadFragments(fragments); } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java index 0b5c8a6ce..9c39e245b 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2013, 2016 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 @@ -16,8 +16,7 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.security.*; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import org.eclipse.osgi.container.*; import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace; import org.eclipse.osgi.framework.util.ArrayMap; @@ -73,15 +72,15 @@ public class FrameworkExtensionInstaller { this.configuration = configuraiton; } - public void addExtensionContent(final ModuleRevision revision, final Module systemModule) throws BundleException { + public void addExtensionContent(final Collection<ModuleRevision> revisions, final Module systemModule) throws BundleException { if (System.getSecurityManager() == null) { - addExtensionContent0(revision, systemModule); + addExtensionContent0(revisions, systemModule); } else { try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws BundleException { - addExtensionContent0(revision, systemModule); + addExtensionContent0(revisions, systemModule); return null; } }); @@ -91,26 +90,29 @@ public class FrameworkExtensionInstaller { } } - void addExtensionContent0(ModuleRevision revision, Module systemModule) throws BundleException { + void addExtensionContent0(Collection<ModuleRevision> revisions, Module systemModule) throws BundleException { if (CL == null || ADD_FWK_URL_METHOD == null) { return; } - File[] files = getExtensionFiles(revision); - if (files == null) { - return; - } - for (int i = 0; i < files.length; i++) { - if (files[i] == null) - continue; - try { - callAddURLMethod(StorageUtil.encodeFileURL(files[i])); - } catch (InvocationTargetException e) { - throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ - } catch (MalformedURLException e) { - throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ + for (ModuleRevision revision : revisions) { + File[] files = getExtensionFiles(revision); + if (files == null) { + return; + } + for (int i = 0; i < files.length; i++) { + if (files[i] == null) + continue; + try { + callAddURLMethod(StorageUtil.encodeFileURL(files[i])); + } catch (InvocationTargetException e) { + throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ + } catch (MalformedURLException e) { + throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$ + } } } + try { // initialize the new urls CL.loadClass("thisIsNotAClass"); //$NON-NLS-1$ @@ -119,8 +121,10 @@ public class FrameworkExtensionInstaller { } if (systemModule != null) { BundleContext systemContext = systemModule.getBundle().getBundleContext(); - if (systemContext != null) { - startExtensionActivator(revision, systemContext); + for (ModuleRevision revision : revisions) { + if (systemContext != null) { + startExtensionActivator(revision, systemContext); + } } } } @@ -215,7 +219,7 @@ public class FrameworkExtensionInstaller { Class<?> activatorClass = Class.forName(activatorName); activator = (BundleActivator) activatorClass.newInstance(); startActivator(activator, context, extensionRevision.getBundle()); - } catch (Exception e) { + } catch (Throwable e) { BundleException eventException; if (activator == null) { eventException = new BundleException(Msg.BundleContextImpl_LoadActivatorError, BundleException.ACTIVATOR_ERROR, e); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index 4ef8691dc..a2d68b337 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -185,12 +185,14 @@ public class Storage { if (systemWiring == null) { return; } + Collection<ModuleRevision> fragments = new ArrayList<ModuleRevision>(); for (ModuleWire hostWire : systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE)) { - try { - getExtensionInstaller().addExtensionContent(hostWire.getRequirer(), null); - } catch (BundleException e) { - getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, e.getMessage(), e); - } + fragments.add(hostWire.getRequirer()); + } + try { + getExtensionInstaller().addExtensionContent(fragments, null); + } catch (BundleException e) { + getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, e.getMessage(), e); } } |