Documentation for BundleContext says it lets you
However, there is no getBundle(String symbolicName) method, only getBundle(long id) (and the unsuitable getBundle(String location). Of course, it's possible to call getBundles() and iterate over the returned array, but is there a better way?
I think iterating through the array of getBundles() is fine. Maybe it shouldn't exist at all because the symbolic name does not identify uniquely a bundle. Maybe getBundles(String symbolicName)...
From OSGi Service Platform Core Specification, Release 4, Version 4.3:
3.6.2 Bundle-SymbolicName
The
Bundle-SymbolicNamemanifest header is a mandatory header. The bundle symbolic name and bundle version identify a unique bundle. This does not always imply that this pair is unique in a framework, in certain cases the same bundle can be installed multiple times in the same framework, see Bundle Identifiers on page 89.
The referred page 89 (which actually is page 95):
4.4.1 Bundle Identifiers
[...]
Though the pair is unique, it is possible to install the same bundle multiple times if the
org.osgi.framework.bsnversionframework launching property is set to multiple.
I have never seen an example on how to do that. But there is the PackageAdmin service, maybe you want to have a look at this, but it seems to be deprecated. The replacement package org.osgi.framework.wiring does not seem to provide such a method.
And to clarify: What is your purpose of having an instance of a Bundle?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With