views:

769

answers:

2

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).

+2  A: 

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

squiddle
A: 

I don't think that starting a thread in a controller is a good idea. That's not what they're for, IMO.

duffymo