I sent this to the users mailing list, but it probably belongs more on dev. I'd like to hook into the Karaf shutdown process at a higher level than the OSGi bundle shutdown. The bundle shutdown starts prematurely shutting down services and such that are necessary for work in progress to complete.
For now, I've implemented this with a custom Karaf command that executes my application shutdown, and then delegates to the Karaf StopCommand to shutdown Karaf itself. However, this is not an ideal solution as it requires my custom command to be explicitly executed. For example, it will not run when a user does a normal kill or Ctrl-D in the console. Ideally, Karaf would have a "ShutdownHook" interface/service I could implement in my bundles -- for each one of these registered, Karaf would execute them before stopping the framework bundles. Based on an initial look at the Karaf source, I'm thinking the best place to do this is: ./main/src/main/java/org/apache/karaf/main/Main.java Just before the call to framework.stop(), we use the BundleContext to obtain and execute a shutdown method on all services that implement a new "FrameworkShutdownHook" interface. Then, proceed to framework.stop(). Thoughts on this approach? If the devs are OK with it, I can implement this. Regards, Raman Gupta Principal VIVO Systems
