Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 199682 Details for
Bug 350961
[R4.4] Use new osgi.identity for singleton capabilities passed to resolver hooks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch + test
350961.txt (text/plain), 6.83 KB, created by
Thomas Watson
on 2011-07-14 12:29:12 EDT
(
hide
)
Description:
patch + test
Filename:
MIME Type:
Creator:
Thomas Watson
Created:
2011-07-14 12:29:12 EDT
Size:
6.83 KB
patch
obsolete
>diff --git src/org/eclipse/osgi/tests/resource/AllTests.java src/org/eclipse/osgi/tests/resource/AllTests.java >index 8a9cb34..a0d0fc7 100644 >--- src/org/eclipse/osgi/tests/resource/AllTests.java >+++ src/org/eclipse/osgi/tests/resource/AllTests.java >@@ -17,6 +17,7 @@ > public static Test suite() { > TestSuite suite = new TestSuite(AllTests.class.getName()); > suite.addTest(BasicTest.suite()); >+ suite.addTest(ResolverHookTests.suite()); > return suite; > } > } >diff --git src/org/eclipse/osgi/tests/resource/ResolverHookTests.java src/org/eclipse/osgi/tests/resource/ResolverHookTests.java >new file mode 0 >index 0000000..743da80 0 >--- /dev/null >+++ src/org/eclipse/osgi/tests/resource/ResolverHookTests.java >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 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.tests.resource; >+ >+import java.util.*; >+import junit.framework.Test; >+import junit.framework.TestSuite; >+import org.osgi.framework.Bundle; >+import org.osgi.framework.ServiceRegistration; >+import org.osgi.framework.hooks.resolver.ResolverHook; >+import org.osgi.framework.hooks.resolver.ResolverHookFactory; >+import org.osgi.framework.wiring.*; >+ >+public class ResolverHookTests extends AbstractResourceTest { >+ >+ public static Test suite() { >+ return new TestSuite(ResolverHookTests.class); >+ } >+ >+ public ResolverHookTests(String name) { >+ super(name); >+ } >+ >+ public void testSingletonIdentity() throws Exception { >+ final RuntimeException error[] = {null}; >+ final boolean called[] = {false}; >+ ResolverHookFactory resolverHookFactory = new ResolverHookFactory() { >+ public ResolverHook begin(Collection triggers) { >+ return new ResolverHook() { >+ >+ public void filterSingletonCollisions(BundleCapability singleton, Collection collisionCandidates) { >+ if (error[0] != null) >+ return; >+ called[0] = true; >+ try { >+ assertEquals("Wrong namespace", ResourceConstants.IDENTITY_NAMESPACE, singleton.getNamespace()); >+ assertEquals("Wrong singleton directive", "true", singleton.getDirectives().get(ResourceConstants.IDENTITY_SINGLETON_DIRECTIVE)); >+ String symbolicName = (String) singleton.getAttributes().get(ResourceConstants.IDENTITY_NAMESPACE); >+ for (Iterator iCandidates = collisionCandidates.iterator(); iCandidates.hasNext();) { >+ BundleCapability candidate = (BundleCapability) iCandidates.next(); >+ assertEquals("Wrong namespace", ResourceConstants.IDENTITY_NAMESPACE, candidate.getNamespace()); >+ assertEquals("Wrong singleton directive", "true", candidate.getDirectives().get(ResourceConstants.IDENTITY_SINGLETON_DIRECTIVE)); >+ assertEquals("Wrong symbolic name", symbolicName, (String) candidate.getAttributes().get(ResourceConstants.IDENTITY_NAMESPACE)); >+ } >+ } catch (RuntimeException e) { >+ error[0] = e; >+ } >+ } >+ >+ public void filterResolvable(Collection candidates) { >+ // nothing >+ } >+ >+ public void filterMatches(BundleRequirement requirement, Collection candidates) { >+ // nothing >+ } >+ >+ public void end() { >+ // nothing >+ } >+ }; >+ } >+ }; >+ >+ ServiceRegistration hookReg = getContext().registerService(ResolverHookFactory.class, resolverHookFactory, null); >+ >+ try { >+ Bundle tb1v1 = installer.installBundle("singleton.tb1v1"); >+ Bundle tb1v2 = installer.installBundle("singleton.tb1v2"); >+ assertFalse(((FrameworkWiring) getContext().getBundle(0).adapt(FrameworkWiring.class)).resolveBundles(Arrays.asList(new Bundle[] {tb1v1, tb1v2}))); >+ assertTrue("ResolverHook was not called", called[0]); >+ if (error[0] != null) >+ throw error[0]; >+ } finally { >+ hookReg.unregister(); >+ } >+ } >+ >+} >diff --git test_files/wiringTests/bundles/singleton.tb1v1/META-INF/MANIFEST.MF test_files/wiringTests/bundles/singleton.tb1v1/META-INF/MANIFEST.MF >new file mode 0 >index 0000000..768d240 0 >--- /dev/null >+++ test_files/wiringTests/bundles/singleton.tb1v1/META-INF/MANIFEST.MF >@@ -0,0 +1,4 @@ >+Manifest-Version: 1.0 >+Bundle-ManifestVersion: 2 >+Bundle-SymbolicName: singleton.tb1; singleton:=true >+Bundle-Version: 1.0.0 >diff --git test_files/wiringTests/bundles/singleton.tb1v2/META-INF/MANIFEST.MF test_files/wiringTests/bundles/singleton.tb1v2/META-INF/MANIFEST.MF >new file mode 0 >index 0000000..330157e 0 >--- /dev/null >+++ test_files/wiringTests/bundles/singleton.tb1v2/META-INF/MANIFEST.MF >@@ -0,0 +1,4 @@ >+Manifest-Version: 1.0 >+Bundle-ManifestVersion: 2 >+Bundle-SymbolicName: singleton.tb1; singleton:=true >+Bundle-Version: 2.0.0 >diff --git resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java >index 78123eb..0f4d7b6 100644 >--- resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java >+++ resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java >@@ -27,8 +27,7 @@ > import org.osgi.framework.Filter; > import org.osgi.framework.InvalidSyntaxException; > import org.osgi.framework.hooks.resolver.ResolverHook; >-import org.osgi.framework.wiring.BundleCapability; >-import org.osgi.framework.wiring.BundleRevision; >+import org.osgi.framework.wiring.*; > > public class ResolverImpl implements Resolver { > // Debug fields >@@ -661,15 +660,20 @@ > if (collision == singleton || !collision.getBundleDescription().isSingleton() || !collision.isResolvable()) > continue; // Ignore the bundle we are checking and non-singletons and non-resolvable > collisionCandidates.add(collision); >- capabilities.add(collision.getCapability()); >+ capabilities.add(getIdentity(collision)); > } > if (hook != null) >- hook.filterSingletonCollisions(singleton.getCapability(), asCapabilities(new ArrayMap<BundleCapability, ResolverBundle>(capabilities, collisionCandidates))); >+ hook.filterSingletonCollisions(getIdentity(singleton), asCapabilities(new ArrayMap<BundleCapability, ResolverBundle>(capabilities, collisionCandidates))); > result.put(singleton, collisionCandidates); > } > return result; > } > >+ private BundleCapability getIdentity(ResolverBundle bundle) { >+ List<BundleCapability> identities = bundle.getBundleDescription().getDeclaredCapabilities(ResourceConstants.IDENTITY_NAMESPACE); >+ return identities.size() == 1 ? identities.get(0) : bundle.getCapability(); >+ } >+ > private void resolveBundles0(ResolverBundle[] bundles, Dictionary<Object, Object>[] platformProperties) { > if (developmentMode) > // need to sort bundles to keep consistent order for fragment attachment (bug 174930)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 350961
: 199682