Thomas Kagan
Thomas Kagan

Reputation: 438

How to get the name of an OSGI bundle from a bundle context in karaf

I'm loading 3 small OSGI bundles with Karaf (bundles A, B, C). Each bundle is composed of one Activator class which implements the start and stop methods. From bundle A's start method I would like to print out a list of all installed bundles.

output: Bundle A's name, Bundle B's name, Bundle C's name

How would I do this?

Upvotes: 2

Views: 1302

Answers (1)

Balazs Zsoldos
Balazs Zsoldos

Reputation: 6046

for (Bundle bundle : bundleContext.getBundles()) {
    System.out.println("Symbolic-Name: " + bundle.getSymbolicName());
    System.out.println("  Version: " + bundle.getVersion());
    // And printing other info
}

Upvotes: 3

Related Questions