How does the OSGi environment set the bundle identifier?

I am trying to run the OSGi framework (Equinox) in the main method. Every time I start the framework, when I print BundleContext.getBundles().length, it says that only 1 Bundle is installed in the framework (this, of course, is a system package). When I install my first package, the package identifier will continue from the last session. let's say if I had 4 packages of the last session (and I stopped and deleted them all before stopping the system package), the first package identifier is set to 5. Now, I want to know how the structure selects the package identifier? Why and how does the infrastructure remember the last session, although I deleted all the packages? Is it because of the bundle cache? And if so, how can I clear the cache (restart numbering from 1)?

+5
source share
2 answers

The framework uses the last used package identifier somewhere in the persistent storage that it manages. What this store looks like is a detail of the infrastructure implementation. When you start the framework, you can specify a shell configuration property org.osgi.framework.storage.clean. This will clear all installed packages, but I'm not sure if this will reset the last used package identifier.

+6
source

Deleting a folder equinox/org.eclipse.osgiresets numbering. Before uninstalling, make sure that your packages do not have important data in this folder.

A command bundlewith a valid package identifier can show the absolute path in the folder equinox/org.eclipse.osgi:

osgi> bundle 7
slf4j.api_1.6.1 [7]
  Id=7, Status=ACTIVE      Data Root=D:\temp\test\equinox\org.eclipse.osgi\bundles\7\data
...
+2
source

All Articles