0

Is there any way to abort the startup of Knoplerfish if a specific bundle fails to initialize? By default, a FrameworkErrorEvent is printed to the console and the framework continues to load.

init.xargs

-initlevel 80
-istart my-required-bundle.jar

console output

[stdout] Installed and started: file:jars/my-required-bundle.jar (id#34)
[stdout] ## DEBUG: errors - FrameworkErrorEvent bundle #34
[stdout] ## DEBUG: errors - FrameworkErrorEvent throwable:
[stderr] org.osgi.framework.BundleException: BundleActivator start failed
Brian
  • 2,375
  • 4
  • 24
  • 35

1 Answers1

0

There is no standard OSGi way to do this, since there is no standard way to tell the framework what bundles to install (that is up to a launcher). There is also no standard way to get notified of this event, so you can act on it. If Knopflerfish does not provide a specific system property or something similar to handle this, I see two routes you could take.

  • Build your own launcher. Instantiate a org.knopflerfish.framework.Main, configure it (there is some information in the readme on this), and install the bundles by getting a BundleContext from the framework. You can then catch BundleExceptions that come from the bundle's start() method, and abort the startup when it has type RESOLVE_ERROR.
  • Create a bundle that waits a specific amount of time, and then inspects the framework to see whether all bundles have started (you can get a list of all currently installed bundles from the BundleContext). If one of them is not in state INSTALLED, you can stop the framework by stopping the system bundle (i.e., bundle 0).
Angelo van der Sijpt
  • 3,611
  • 18
  • 24