If you want to execute some code before stopping anything in the container, you can implement a ContainerLifecyclePlugin and add your code in the 

method stopContainer that is called before stopping anything. You can extend the class BaseContainerLifecyclePlugin from the kernel.

Then you need to declare it at the beginning of a configuration file like in this example https://github.com/exodev/kernel/blob/master/exo.kernel.container/src/test/resources/org/exoplatform/container/test-exo-container.xml 


On Thu, Nov 14, 2013 at 5:39 PM, Juraci Paixão Kröhling <jcosta@redhat.com> wrote:
On 11/14/2013 04:01 PM, Nicolas Filotto wrote:
> No there is no bug, it is expected to ensure consistency on shutdown

In that case, I'd have to ask if there would be another event or hook
that I could subscribe to get notified before the repository gets offline.

That's because WSRP needs a fresh list of the consumers running on the
portal that is being shutdown, so that they are unregistered[1].

This list of consumers comes from the persistent storage[2], meaning
that it needs to open a Chromattic session, which in turn needs the
repository to be online[3].

While I can certainly workaround it using a cached list of consumers to
unregister from the federating portlet invoker, I would rather prefer to
be notified about a last chance to talk to the persistent storage.

>From what I'm understanding from this thread, when the stop() method is
called for WSRP, it's already too late to properly stop WSRP, but
perhaps there's another notification that I should be listening to? How
do other components deals with this scenario (getting something from
persistent storage during shutdown)?

1 - http://git.io/ujAGbQ
2 - http://git.io/2B3kLA
3 - http://git.io/yiYuCw

Thanks!
Juca.