I don't know of any such mechanism. I imagine you'll have to implement an MBean and do your cleanup in the stopService method, but I don't know if the MBean shutdown order is deterministic. This means that access to the resources you need to clean up may not be there by the time the stopService() gets invoked. Alternatively, the only way I can think of is to extend Server or Shutdown classes.
If I may ask - what kind of cleanup are you doing? There may be a 'better way'...
I have the same problem as rvaneperen.
My application is establishing dialup connections and I want to disconnect all active connections during JBoss shutdown.
I've tried to use MBean stopService method but it's executed after undeployment of some resources I need to access to perform cleanup.
Any other suggestion?
Then you need to have a depends on those resources so that you are shutdown before them.
if you are deploying web application with jboss then you can use ServletContextListener for this
Thank you, setting dependecies helped.