You can register an EventObserver with the LocalManagementMBean:
The ApplicationUndeployedEvent happens during undeployment, but this is after services have been unregistered, etc. Are you looking to invoke a bean service when an application is shutting down? There's not really a hook for doing that now. An alternative option wold be to expose the method through a binding and invoke that with a script as part of your shutdown process.
Hey Keith, thanks for this.
I exposed the method, but could not find a way of invoking. Which script type are you thinking about?
I was just thinking about using something like 'curl' to poke the service from bash. But that's just an example of something simple that should be easy to incorporate into a shutdown script.