Does Spring's Controller
have any sort of destroy/cleanup method? I couldn't find anything in the JavaDocs for Controller
and AbstractController
. I'm looking for the equivalent of javax.servlet.Servlet
's destroy()
method.
The reason for this is that I'm starting a thread in my Spring controller. I want the thread to terminate whenever the controller is taken out of server (such as when the container is shutdown).
Best Solution
Just use the regular spring lifecycle methods. Because all Spring Controllers are Spring beans they will follow the regular lifecycle.
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-lifecycle-disposablebean