I have some resources that I allocate when my web service is created that I need to be released (for example, I need to flush and close file streams when the servlet is being shut down). How can I have code executed when the JAX-WS servlet's destroy() method is called?
views:
30answers:
1
A:
I suggest using a ServletContextListener for this. Write a custom implementarion of that interface which does what you want, and then hook it into your web.xml using the <listener> element (example).
This lifecycle doesn't exactly match that of the servlet, but it should be close enough for your purposes.
skaffman
2010-09-27 14:52:27