Reputation: 351
I tried the following code in the fragment bundle
Bundle bundle = FrameworkUtil.getBundle( getClass() ) ;
but the bundle object still represents the host bundle, how to get the Bundle object representing the fragment bundle ?
Upvotes: 1
Views: 167
Reputation: 9384
Classes are always loaded by the host bundle. So it is not possible to get a Bundle object for a fragment which contains a class using FrameworkUtil.getBundle(Class)
.
Given the host Bundle object, you can then find the attached fragments. See https://docs.osgi.org/specification/osgi.core/8.0.0/framework.wiring.html#d0e13920.
Upvotes: 1