I’m tracking OSGi bundles like this:
BundleTracker<Foo> bundleTracker = new BundleTracker<>(context, Bundle.ACTIVE,
new BundleTrackerCustomizer<Foo>(){
@Override
public Foo addingBundle(Bundle bundle, BundleEvent event) {
...
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Foo foo) {
...
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Foo foo) {
...
}
});
Now, if a bundle B has a dependency A and B is started, then as I understand first bundle A will be activated. Is this correct?
The issue is that I’m sometimes get notified about some bundles before I get notified about their dependent bundles. So, how can I get notified in dependency order (if B depends on A, then first get notified about A then about B)?
Code dependencies (import package or require bundle) between bundles do not (in general) have any affect on the start ordering of bundles. The is some interaction between bundles using lazy activation.
So once A and B are resolved, starting B has no bearing on starting A.
The important thing to note here is that module layer dependencies do not affect the start order of bundles.