I am trying to run OSGi framework (Equinox) in a main method.
Each time I start the framework, when I print BundleContext.getBundles().length
, it says the framework has only 1 Bundle installed on (that is certainly the system bundle).
When I install my first bundle the bundle ID will continue from the last session. let's say if I had 4 bundles last session (and I have stopped and uninstalled all of them before stopping the system bundle), the first Bundle ID is set 5.
Now, I want to know how does the framework choose the bundle ID? Why and how does the framework remembers the last session, even though I had uninstalled all of the bundles? Is it because of Bundle Cache? And if it is, how can I clear the cache (to restart numbering from 1)?
The framework has the last used bundle id somewhere in the persistent store it manages. What this store looks like is a framework implementation detail. When you launch the framework, you can specify the org.osgi.framework.storage.clean
framework configuration property. This will clear all installed bundles but I am not sure if it will reset the last used bundle id.
Deleting the equinox/org.eclipse.osgi
folder resets the numbering. Before the delete make sure that your bundles don't have any important data under this folder.
The bundle
command with a valid bundle id can show the absolute path of the equinox/org.eclipse.osgi
folder:
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
...
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