1
votes

I'm just trying to resolve my understanding of what happens when a bundle is stopped and the consequences for bundles that depend on them.

For example, if there are two bundles A and B. Bundle A has no dependencies (other than an OSGi framework) but exports some packages. Bundle B imports packages from A and subsequently uses classes from them but NOT services (if any). Both bundles are installed in an OSGi framework and report their status as 'Active'.

Now the situation occurs Bundle A is stopped (but NOT restarted) so if I understand correctly bundle A transitions to the 'resolved' state. Does this mean that any exports in bundle A are NOT available and if so should bundle B also be stopped (automatically by the framework) when A does?

2

2 Answers

1
votes

When bundle B is started, bundle A is started as well (before). However, if bundle A is stopped, bundle B will not be stopped. There can be three reasons why bundle B would stop:

  • Stop is called on bundle B
  • Framework start level becomes lower than the start level of bundle B
  • bundle B becomes unresolved

Additionally: if uninstall is called on bundle A, bundle B will be still active. The reason is that bundle A will get a "marked for removal" state, but it will not be removed completely until anything wires to it. The wiring is removed if a refresh is called on bundle B.

1
votes

The difference between the resolved state and the active state is only the execution of the start / stop methods of the activator. So stopping bundle A will not affect bundle B as long as it only uses classes from bundle A and no services which would be deregistered.

In fact if bundle A does not have a BundleActivator the bundle will transition from resolved -> active or active -> resolved without anything changing at all.