In OSGi (Apache Felix 4.2.1), I want my bundles to check for updates automatically on startup.
I do this with the following code (in my "management agent"). How can I tell whether a bundle was updated?
Bundle[] bundles = context.getBundles();
for (int i = 0; i < bundles.length; i++) {
Bundle bundle = bundles[i];
bundle.update();
}
// which bundle was updated?
I want to refresh the bundles automatically (using FrameworkWiring
), but only if one of the .update()
calls actually resulted in a new deployment from my server.
As I'm deploying from Maven to my OBR, my SNAPSHOT version have all the same number. From gogo, I can see that the Bnd-LastModified
header changes, but how to automate this?
PS: If easy solutions exist which solve the whole update thing more nicely than rolling my own, I'm interested as well. It needs to be lean. (Apache Karaf?, Apache ACE? others?)
If you want to learn a bit more about Apache ACE, I can recommend reading the following two articles on the ACE website:
To be honest, if all you want is to updated a set of bundles on startup, then ACE is a bit overkill. It can be used to manage multiple "targets" (frameworks running OSGi) from a central server, automatically pushing updates to it and managing large sets of bundles and other artifacts, grouping them in features and distributions.