summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2012-09-06 10:59:15 (EDT)
committer Thomas Watson2012-09-06 10:59:15 (EDT)
commitb89784d3c1750372551dd77c25868293f67ee3d0 (patch)
tree6c9211775740a9814853f0b206ea961255d6461a
parent869e2ef794c4cabc62e3e931f3ef73493d2e21ab (diff)
downloadrt.equinox.framework-b89784d3c1750372551dd77c25868293f67ee3d0.zip
rt.equinox.framework-b89784d3c1750372551dd77c25868293f67ee3d0.tar.gz
rt.equinox.framework-b89784d3c1750372551dd77c25868293f67ee3d0.tar.bz2
Bug 388143 - New framework implementation must provide detailed
information regarding resolution failures.
-rw-r--r--bundles/org.eclipse.osgi.container.tests/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java90
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java101
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java9
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java7
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java29
-rw-r--r--bundles/org.eclipse.osgi/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java22
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java48
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java21
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java26
16 files changed, 367 insertions, 34 deletions
diff --git a/bundles/org.eclipse.osgi.container.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.container.tests/META-INF/MANIFEST.MF
index 8bbb846..6d845e6 100644
--- a/bundles/org.eclipse.osgi.container.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi.container.tests/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Require-Bundle: org.junit;bundle-version="4.8.2"
Import-Package: org.eclipse.osgi.container;version="1.0.0",
org.eclipse.osgi.container.builders;version="1.0.0",
org.eclipse.osgi.container.namespaces;version="1.0.0",
+ org.eclipse.osgi.framework.report;version="1.0",
org.eclipse.osgi.util;version="1.1.0",
org.osgi.framework;version="1.7.0",
org.osgi.framework.hooks.bundle;version="1.1.0",
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java
new file mode 100644
index 0000000..e44674b
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.container.tests;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+import junit.framework.Assert;
+import org.eclipse.osgi.container.*;
+import org.eclipse.osgi.container.builders.OSGiManifestBuilderFactory;
+import org.eclipse.osgi.container.tests.dummys.*;
+import org.eclipse.osgi.util.ManifestElement;
+import org.junit.After;
+import org.junit.Before;
+import org.osgi.framework.*;
+
+public abstract class AbstractTest {
+ protected Set<ServiceRegistration<?>> serviceRegistrations;
+
+ @Before
+ public void setUp() {
+ serviceRegistrations = new HashSet<ServiceRegistration<?>>();
+ }
+
+ @After
+ public void tearDown() {
+ for (ServiceRegistration<?> serviceRegistration : serviceRegistrations) {
+ try {
+ serviceRegistration.unregister();
+ } catch (IllegalStateException e) {
+ // Service was already unregistered.
+ }
+ }
+ }
+
+ protected DummyContainerAdaptor createDummyAdaptor() {
+ return new DummyContainerAdaptor(new DummyCollisionHook(false), new DummyResolverHookFactory(), Collections.<String, String> emptyMap());
+ }
+
+ protected Bundle getBundle() {
+ return ((BundleReference) getClass().getClassLoader()).getBundle();
+ }
+
+ protected BundleContext getBundleContext() {
+ return getBundle().getBundleContext();
+ }
+
+ protected Map<String, String> getManifest(String manifestFile) throws IOException, BundleException {
+ URL manifest = getBundle().getEntry("/manifests/" + manifestFile);
+ Assert.assertNotNull("Could not find manifest: " + manifestFile, manifest);
+ return ManifestElement.parseBundleManifest(manifest.openStream(), null);
+ }
+
+ protected Bundle getSystemBundle() {
+ return getBundleContext().getBundle(0);
+ }
+
+ protected BundleContext getSystemBundleContext() {
+ return getSystemBundle().getBundleContext();
+ }
+
+ protected Module installDummyModule(String manifestFile, String location, ModuleContainer container) throws BundleException, IOException {
+ return installDummyModule(manifestFile, location, null, null, null, container);
+ }
+
+ protected Module installDummyModule(String manifestFile, String location, String alias, String extraExports, String extraCapabilities, ModuleContainer container) throws BundleException, IOException {
+ Map<String, String> manifest = getManifest(manifestFile);
+ ModuleRevisionBuilder builder = OSGiManifestBuilderFactory.createBuilder(manifest, alias, extraExports, extraCapabilities);
+ Module system = container.getModule(0);
+ return container.install(system, location, builder, null);
+ }
+
+ protected void registerService(Class<?> clazz, Object service) {
+ serviceRegistrations.add(getSystemBundleContext().registerService(clazz.getName(), service, null));
+ }
+
+ protected void unregisterService(Object service) {
+ for (ServiceRegistration<?> serviceRegistration : serviceRegistrations)
+ if (getSystemBundleContext().getService(serviceRegistration.getReference()).equals(service))
+ serviceRegistration.unregister();
+ }
+}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
new file mode 100644
index 0000000..e03a0f8
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.container.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.eclipse.osgi.container.Module;
+import org.eclipse.osgi.container.ModuleContainer;
+import org.eclipse.osgi.container.tests.dummys.DummyContainerAdaptor;
+import org.eclipse.osgi.container.tests.dummys.DummyResolverHookFactory;
+import org.eclipse.osgi.framework.report.ResolutionReport;
+import org.eclipse.osgi.framework.report.ResolutionReportReader;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.*;
+
+public class ResolutionReportTest extends AbstractTest {
+ private static class ResolverHookFactory implements org.osgi.framework.hooks.resolver.ResolverHookFactory {
+ private AtomicBoolean receivedCallback;
+
+ public ResolverHookFactory(AtomicBoolean receivedCallback) {
+ this.receivedCallback = receivedCallback;
+ }
+
+ @Override
+ public org.osgi.framework.hooks.resolver.ResolverHook begin(Collection<BundleRevision> triggers) {
+ return new ResolverHook(receivedCallback);
+ }
+ }
+
+ private static class ResolverHook implements org.osgi.framework.hooks.resolver.ResolverHook, ResolutionReportReader {
+ private final AtomicBoolean receivedCallback;
+
+ public ResolverHook(AtomicBoolean receivedCallback) {
+ this.receivedCallback = receivedCallback;
+ }
+
+ @Override
+ public void end() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void filterResolvable(Collection<BundleRevision> candidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void read(ResolutionReport report) {
+ receivedCallback.set(true);
+ }
+ }
+
+ @Test
+ public void testResolutionReportReadCallback() throws Exception {
+ AtomicBoolean receivedCallback = new AtomicBoolean(false);
+ registerService(org.osgi.framework.hooks.resolver.ResolverHookFactory.class, new ResolverHookFactory(receivedCallback));
+
+ getSystemBundle().adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(getSystemBundle()));
+
+ // DummyContainerAdaptor adaptor = createDummyAdaptor();
+ // ModuleContainer container = adaptor.getContainer();
+ // Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
+ // container.resolve(Arrays.asList(systemBundle), true);
+ assertTrue("Did not receive a resolution report callback", receivedCallback.get());
+ }
+
+ @Test
+ public void testResolutionReportWriteCallback() throws Exception {
+ DummyContainerAdaptor adaptor = createDummyAdaptor();
+ ModuleContainer container = adaptor.getContainer();
+ Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
+ container.resolve(Arrays.asList(systemBundle), true);
+ assertEquals("No resolution report write callback", 1, ((DummyResolverHookFactory) adaptor.getResolverHookFactory()).getWriteCount());
+ }
+}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
index 0a3586a..575026f 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
@@ -30,7 +30,6 @@ import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.*;
@@ -416,10 +415,10 @@ public class TestModuleContainer {
@Test
public void testSingleton02() throws BundleException, IOException, ResolutionException {
- ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
+ ModuleResolverHookFactory resolverHookFactory = new ModuleResolverHookFactory() {
@Override
- public ResolverHook begin(Collection<BundleRevision> triggers) {
+ public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
return new ResolverHook() {
@Override
@@ -483,10 +482,10 @@ public class TestModuleContainer {
@Test
public void testSingleton04() throws BundleException, IOException, ResolutionException {
final Collection<BundleRevision> disabled = new ArrayList<BundleRevision>();
- ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
+ ModuleResolverHookFactory resolverHookFactory = new ModuleResolverHookFactory() {
@Override
- public ResolverHook begin(Collection<BundleRevision> triggers) {
+ public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
return new ResolverHook() {
@Override
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
index 0cb13e3..1f014d4 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
@@ -17,17 +17,16 @@ import org.eclipse.osgi.container.Module.Settings;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyContainerEvent;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyModuleEvent;
import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
public class DummyContainerAdaptor extends ModuleContainerAdaptor {
private final ModuleCollisionHook collisionHook;
- private final ResolverHookFactory resolverHookFactory;
+ private final ModuleResolverHookFactory resolverHookFactory;
private final Map<String, String> configuration;
private final DummyModuleDatabase moduleDatabase;
private final ModuleContainer container;
- public DummyContainerAdaptor(ModuleCollisionHook collisionHook, ResolverHookFactory resolverHookFactory, Map<String, String> configuration) {
+ public DummyContainerAdaptor(ModuleCollisionHook collisionHook, ModuleResolverHookFactory resolverHookFactory, Map<String, String> configuration) {
this.collisionHook = collisionHook;
this.resolverHookFactory = resolverHookFactory;
this.configuration = configuration;
@@ -41,7 +40,7 @@ public class DummyContainerAdaptor extends ModuleContainerAdaptor {
}
@Override
- public ResolverHookFactory getResolverHookFactory() {
+ public ModuleResolverHookFactory getResolverHookFactory() {
return resolverHookFactory;
}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
index 66e132b..7188a39 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
@@ -11,36 +11,45 @@
package org.eclipse.osgi.container.tests.dummys;
import java.util.Collection;
+import org.eclipse.osgi.container.ModuleResolverHookFactory;
+import org.eclipse.osgi.container.ResolutionReportBuilder;
import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.wiring.*;
-public class DummyResolverHookFactory implements ResolverHookFactory {
+public class DummyResolverHookFactory implements ModuleResolverHookFactory {
+ private int writeCount;
@Override
- public ResolverHook begin(Collection<BundleRevision> triggers) {
+ public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
+ writeCount++;
return new ResolverHook() {
-
@Override
- public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
- // nothing
+ public void filterResolvable(Collection<BundleRevision> candidates) {
+ // TODO Auto-generated method stub
+
}
@Override
- public void filterResolvable(Collection<BundleRevision> candidates) {
- // nothing
+ public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+ // TODO Auto-generated method stub
+
}
@Override
public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
- // nothing
+ // TODO Auto-generated method stub
+
}
@Override
public void end() {
- // nothing
+ // TODO Auto-generated method stub
+
}
};
}
+ public int getWriteCount() {
+ return writeCount;
+ }
}
diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
index b51cd06..3bd6dfb 100644
--- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Export-Package: org.eclipse.core.runtime.adaptor;x-friends:="org.eclipse.core.ru
org.eclipse.osgi.framework.internal.core;x-internal:=true,
org.eclipse.osgi.framework.internal.reliablefile;x-internal:=true,
org.eclipse.osgi.framework.log;version="1.1",
+ org.eclipse.osgi.framework.report;version="1.0",
org.eclipse.osgi.framework.util;x-internal:=true,
org.eclipse.osgi.internal.baseadaptor;x-internal:=true,
org.eclipse.osgi.internal.debug;x-internal:=true,
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index 20684ff..877fc10 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
@@ -17,7 +17,6 @@ import org.apache.felix.resolver.ResolverImpl;
import org.eclipse.osgi.container.Module.Settings;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.service.resolver.Resolver;
/**
@@ -97,7 +96,7 @@ public abstract class ModuleContainerAdaptor {
* Returns the resolver hook factory the container will use.
* @return the resolver hook factory the container will use.
*/
- public abstract ResolverHookFactory getResolverHookFactory();
+ public abstract ModuleResolverHookFactory getResolverHookFactory();
/**
* Publishes the specified container event.
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 78ba471..87ceac6 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -585,7 +585,7 @@ final class ModuleResolver {
threadResolving.set(Boolean.TRUE);
try {
try {
- hook = adaptor.getResolverHookFactory().begin(Converters.asListBundleRevision((List<? extends BundleRevision>) triggers));
+ hook = adaptor.getResolverHookFactory().begin(Converters.asListBundleRevision((List<? extends BundleRevision>) triggers), null);
} catch (RuntimeException e) {
if (e.getCause() instanceof BundleException) {
BundleException be = (BundleException) e.getCause();
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java
new file mode 100644
index 0000000..4181e07
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.container;
+
+import java.util.Collection;
+import org.osgi.framework.hooks.resolver.ResolverHook;
+import org.osgi.framework.wiring.BundleRevision;
+
+/**
+ * @since 3.10
+ */
+public interface ModuleResolverHookFactory {
+ public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder);
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java
new file mode 100644
index 0000000..ab8ec09
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.container;
+
+import org.eclipse.osgi.framework.report.ResolutionReport;
+import org.eclipse.osgi.framework.report.ResolutionReportEntry;
+import org.osgi.resource.Resource;
+
+/**
+ * @since 3.10
+ */
+public class ResolutionReportBuilder {
+ public ResolutionReport build() {
+ return new ResolutionReport() {
+ @Override
+ public boolean hasNext() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ResolutionReportEntry next() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void remove() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public ResolutionReportEntry getResolutionReport(Resource resource) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java
new file mode 100644
index 0000000..59abd8c
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.framework.report;
+
+import java.util.Iterator;
+import org.osgi.resource.Resource;
+
+/**
+ * @since 3.10
+ */
+public interface ResolutionReport extends Iterator<ResolutionReportEntry> {
+ public ResolutionReportEntry getResolutionReport(Resource resource);
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java
new file mode 100644
index 0000000..d00e718
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.framework.report;
+
+import org.osgi.resource.Resource;
+
+/**
+ * @since 3.10
+ */
+public interface ResolutionReportEntry {
+ public Resource getResource();
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java
new file mode 100644
index 0000000..93c0709
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.framework.report;
+
+/**
+ * @since 3.10
+ */
+public interface ResolutionReportReader {
+ public void read(ResolutionReport report);
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index db11fa3..6878d6a 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -17,7 +17,6 @@ import org.eclipse.osgi.internal.loader.*;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.eclipse.osgi.storage.Storage;
import org.osgi.framework.*;
-import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.service.resolver.ResolutionException;
@@ -65,7 +64,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
}
@Override
- public ResolverHookFactory getResolverHookFactory() {
+ public ModuleResolverHookFactory getResolverHookFactory() {
return hooks.getResolverHookFactory();
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
index 3057cc0..30b1f6c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
@@ -13,10 +13,11 @@ package org.eclipse.osgi.internal.framework;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import org.eclipse.osgi.container.Module;
-import org.eclipse.osgi.container.ModuleCollisionHook;
+import org.eclipse.osgi.container.*;
import org.eclipse.osgi.container.namespaces.EquinoxNativeCodeNamespace;
import org.eclipse.osgi.framework.internal.core.Msg;
+import org.eclipse.osgi.framework.report.ResolutionReport;
+import org.eclipse.osgi.framework.report.ResolutionReportReader;
import org.eclipse.osgi.internal.baseadaptor.ArrayMap;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.serviceregistry.*;
@@ -29,7 +30,7 @@ import org.osgi.framework.wiring.*;
class OSGiFrameworkHooks {
static final String collisionHookName = CollisionHook.class.getName();
- private final ResolverHookFactory resolverHookFactory;
+ private final ModuleResolverHookFactory resolverHookFactory;
private final ModuleCollisionHook collisionHook;
OSGiFrameworkHooks(EquinoxContainer container) {
@@ -37,7 +38,7 @@ class OSGiFrameworkHooks {
collisionHook = new BundleCollisionHook(container);
}
- public ResolverHookFactory getResolverHookFactory() {
+ public ModuleResolverHookFactory getResolverHookFactory() {
return resolverHookFactory;
}
@@ -126,7 +127,7 @@ class OSGiFrameworkHooks {
* This class is not thread safe and expects external synchronization.
*
*/
- static class CoreResolverHookFactory implements ResolverHookFactory {
+ static class CoreResolverHookFactory implements ModuleResolverHookFactory {
// need a tuple to hold the service reference and hook object
// do not use a map for performance reasons; no need to hash based on a key.
static class HookReference {
@@ -170,13 +171,13 @@ class OSGiFrameworkHooks {
}
}
- public ResolverHook begin(Collection<BundleRevision> triggers) {
+ public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
if (debug.DEBUG_HOOKS) {
Debug.println("ResolverHook.begin"); //$NON-NLS-1$
}
ServiceRegistry registry = container.getServiceRegistry();
if (registry == null) {
- return new CoreResolverHook(Collections.<HookReference> emptyList());
+ return new CoreResolverHook(Collections.<HookReference> emptyList(), builder);
}
Module systemModule = container.getStorage().getModuleContainer().getModule(0);
BundleContextImpl context = (BundleContextImpl) EquinoxContainer.secureAction.getContext(systemModule.getBundle());
@@ -195,7 +196,7 @@ class OSGiFrameworkHooks {
} catch (Throwable t) {
// need to force an end call on the ResolverHooks we got and release them
try {
- new CoreResolverHook(hookRefs).end();
+ new CoreResolverHook(hookRefs, builder).end();
} catch (Throwable endError) {
// we are already in failure mode; just continue
}
@@ -204,14 +205,16 @@ class OSGiFrameworkHooks {
}
}
}
- return new CoreResolverHook(hookRefs);
+ return new CoreResolverHook(hookRefs, builder);
}
class CoreResolverHook implements ResolverHook {
+ private final ResolutionReportBuilder builder;
private final List<HookReference> hooks;
- CoreResolverHook(List<HookReference> hooks) {
+ CoreResolverHook(List<HookReference> hooks, ResolutionReportBuilder builder) {
this.hooks = hooks;
+ this.builder = builder;
}
public void filterResolvable(Collection<BundleRevision> candidates) {
@@ -307,6 +310,7 @@ class OSGiFrameworkHooks {
HookReference missingHook = null;
Throwable endError = null;
HookReference endBadHook = null;
+ ResolutionReport report = null;
for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) {
HookReference hookRef = iHooks.next();
// We do not remove unregistered services here because we are going to remove all of them at the end
@@ -315,6 +319,8 @@ class OSGiFrameworkHooks {
missingHook = hookRef;
} else {
try {
+ if (hookRef.hook instanceof ResolutionReportReader)
+ ((ResolutionReportReader) hookRef.hook).read(report);
hookRef.hook.end();
} catch (Throwable t) {
// Must continue on to the next hook.end method