karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Baptiste Onofré ...@nanthrax.net>
Subject Re: RFC on proposal to allow hooks into Karaf shutdown
Date Fri, 30 Nov 2012 06:56:58 GMT
Hi Raman,

it's more or less already available. I'm not against enhancement around 
that, but, maybe it's redundant with the following.

You can more or less already do something like this using a 
SynchronousBundleListener (you will received the STOPPING event on 
bundleId 0, so the framework), or a FrameworkListener (to hook on the 
framework).

Regards
JB

On 11/30/2012 05:15 AM, Raman Gupta wrote:
> 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
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Mime
View raw message