You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Martin Lichtin <li...@yahoo.com> on 2016/07/11 14:22:04 UTC

Best way to intercept "shutdown" command

Hi All

What is the best approach to intercept the Karaf "shutdown" command, before it starts shutting down any bundles?
Karaf does a getBundle(0).stop() on receiving a "shutdown" command.

There's no FrameworkEvent raised on bundle(0).stop afaics.
A bundle listener on bundle 0 should work, but does not seem to, it's not called with a STOPPING or STOPPED event.

I do see the event in the log as the first thing after "shutdown":

2016-07-11 16:02:17,096 | DEBUG | FelixShutdown    | framework                        | 0 - org.apache.felix.framework - 4.2.1 | BundleEvent STOPPING - org.apache.felix.framework


However that event never makes it to my bundle listener.

Any help appreciated :)
- Martin

Re: Best way to intercept "shutdown" command

Posted by Martin Lichtin <li...@yahoo.com>.
A bundle listener can be used, but one needs to use the "SynchronousBundleListener" interface.
Only with this interface does one receive the 'STOPPING' events.

On 11.07.2016 16:22, Martin Lichtin wrote:
> Hi All
>
> What is the best approach to intercept the Karaf "shutdown" command, before it starts shutting down any bundles?
> Karaf does a getBundle(0).stop() on receiving a "shutdown" command.
>
> There's no FrameworkEvent raised on bundle(0).stop afaics.
> A bundle listener on bundle 0 should work, but does not seem to, it's not called with a STOPPING or STOPPED event.
>
> I do see the event in the log as the first thing after "shutdown":
>
> 2016-07-11 16:02:17,096 | DEBUG | FelixShutdown    | framework                        | 0 - org.apache.felix.framework - 4.2.1 | BundleEvent STOPPING - org.apache.felix.framework
>
> However that event never makes it to my bundle listener.
>
> Any help appreciated :)
> - Martin