Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the OSGi framework set the Bundle ID?

Tags:

osgi

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)?

like image 717
Reza Avatar asked Sep 22 '11 20:09

Reza


2 Answers

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.

like image 147
BJ Hargrave Avatar answered Sep 22 '22 13:09

BJ Hargrave


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
...
like image 43
palacsint Avatar answered Sep 21 '22 13:09

palacsint